From 49424e24b3c6a96966b7de390dbc63ef2d0d805e Mon Sep 17 00:00:00 2001 From: Vlad_kv Date: Tue, 27 Nov 2018 22:32:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BF=D1=80=D0=B5=D0=B4=D1=81=D1=82=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constraints/conversion_0.mzn | 39 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/constraints/conversion_0.mzn b/constraints/conversion_0.mzn index 76f22b1..b0b9099 100644 --- a/constraints/conversion_0.mzn +++ b/constraints/conversion_0.mzn @@ -20,7 +20,7 @@ constraint forall (obj in 1..n_moving_obj, j in 1..(n_intervals + 1)) ((m_obj_loc[obj, j] != 0) -> ( (m_obj_loc[obj, j] == m_obj_loc[obj, j - 1] /\ (forall (k in departure_op[obj, m_obj_loc[obj, j]]) (op_status[k, j - 1] == 0))) \/ - (not (forall (k in arrival_op[obj, m_obj_loc[obj, j]]) (op_fin[k, j - 1] == 0))) + (exists (k in arrival_op[obj, m_obj_loc[obj, j]]) (op_fin[k, j - 1] != 0)) )); % Начальное состояние. @@ -98,23 +98,26 @@ array [1..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of var int % Ограничения на вместимость. array [1..n_obj_with_storage] of int : max_storage_vol; -constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1)) ( - (sum (cargo in 1..n_cargo_types) (storage_used_volume[storage, t, cargo]) <= max_storage_vol[storage]) - /\ - (forall (cargo in 1..n_cargo_types) (0 <= storage_used_volume[storage, t, cargo])) +constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1)) ( % Масимальный объём. + sum (cargo in 1..n_cargo_types) (storage_used_volume[storage, t, cargo]) <= max_storage_vol[storage] +); +constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1), cargo in 1..n_cargo_types) ( % Неотрицательность объёма. + 0 <= storage_used_volume[storage, t, cargo] ); % Ограничения на граничные значения. array [1..n_obj_with_storage, 1..n_cargo_types] of int : initial_storage_vol; array [1..n_obj_with_storage, 1..n_cargo_types] of int : final_storage_vol; -constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types) ( - (storage_used_volume[storage, 0, cargo] = initial_storage_vol[storage, cargo]) - /\ - (if final_storage_vol[storage, cargo] >= 0 then - (storage_used_volume[storage, (n_intervals + 1), cargo] == final_storage_vol[storage, cargo]) - else - true - endif) + +constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types) ( % Initial values. + storage_used_volume[storage, 0, cargo] = initial_storage_vol[storage, cargo] +); + +constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types) ( % Final values. + if final_storage_vol[storage, cargo] >= 0 then + storage_used_volume[storage, n_intervals + 1, cargo] == final_storage_vol[storage, cargo] + else true + endif ); % Изменение грузов в хранилищах. @@ -212,11 +215,11 @@ array [1..n_moving_obj, 0..(n_intervals + 1)] of var bool : is_interval_useful; ); constraint forall (obj in 1..n_moving_obj, t in 0..n_intervals) ( % Само ограничение. - if ((m_obj_loc[obj, t] != 0) /\ (next_m_obj_loc[obj, t + 1] != 0) /\ (m_obj_loc[obj, t + 1] == 0)) then - if (next_m_obj_loc[obj, t + 1] == prev_m_obj_loc[obj, t]) then - is_interval_useful[obj, t] == true - endif - endif + (( m_obj_loc[obj, t] != 0) /\ + (prev_m_obj_loc[obj, t] != 0) /\ + ( m_obj_loc[obj, t + 1] == 0) /\ + (next_m_obj_loc[obj, t + 1] == prev_m_obj_loc[obj, t]) + ) -> is_interval_useful[obj, t] ); solve minimize sum(is_not_terminated); -- GitLab