From a3b849d8a237985d842b21e03a1c70828d4e528e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=81=D0=B5=D0=BB=D1=91=D0=B2=20=D0=92=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2?= Date: Mon, 19 Nov 2018 23:06:12 +0300 Subject: [PATCH] constraints updated --- constraints/conversion_0.mzn | 63 +++++++++++------------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/constraints/conversion_0.mzn b/constraints/conversion_0.mzn index ac29d48..ed1d547 100644 --- a/constraints/conversion_0.mzn +++ b/constraints/conversion_0.mzn @@ -46,44 +46,19 @@ constraint forall (i in 1..n_operations, j in 1..n_intervals ) (op_fin [i, array [1..n_operations] of var int : operations_duration; array [1..n_operations] of var bool : is_continuous_operation; -% TODO -%constraint forall (i in 1..n_operations) ( -% if (is_continuous_operation[i]) then ( -% forall (j in 1..n_intervals) ( -% let {var int : len = operations_duration[i]} in -% if (j + len > n_intervals + 1) then -% op_start[i, j] == 0 -% else ( -% (op_start[i, j] == 1) -> ( -% (forall (k in 1..(len - 1)) -% (op_status[i, j + k] == 1) -% ) /\ -% (op_status[i, j + len] == 0) -% ) -% ) -% endif -% ) -% ) else true -% endif -%); - - -constraint forall (i in 1..n_operations) ( - if (is_continuous_operation[i]) then ( - let {var int : len = operations_duration[i]} in - (forall (j in 1..(n_intervals - len + 1)) ( - (op_start[i, j] == 1) -> ( - (forall (k in 1..(len - 1)) - (op_status[i, j + k] == 1) - ) /\ - (op_status[i, j + len] == 0) - ) - )) /\ - (forall (j in (n_intervals - len + 2)..(n_intervals + 1)) - (op_start[i, j] == 0) +constraint forall (i in 1..n_operations where is_continuous_operation[i]) ( + let {var int : len = operations_duration[i]} in + (forall (j in 1..(n_intervals - len + 1)) ( + (op_start[i, j] == 1) -> ( + (forall (k in 1..(len - 1)) + (op_status[i, j + k] == 1) + ) /\ + (op_status[i, j + len] == 0) ) - ) else true - endif + )) /\ + (forall (j in (n_intervals - len + 2)..(n_intervals + 1)) + (op_start[i, j] == 0) + ) ); % Наличие всех ресурсов на месте во время начала операции перемещения. @@ -104,8 +79,6 @@ array [1..n_conflicting_op] of 1..n_operations : confl_op_2; constraint forall (t in 0..(n_intervals + 1), i in 1..n_conflicting_op) ( (op_status[confl_op_1[i], t] -> not op_status[confl_op_2[i], t]) - /\ - (op_status[confl_op_2[i], t] -> not op_status[confl_op_1[i], t]) ); % Окна непогоды. @@ -114,11 +87,11 @@ array [1..n_bad_weather_windows] of 1..n_operations : bw_op; array [1..n_bad_weather_windows] of 0..(n_intervals + 1) : bw_start; array [1..n_bad_weather_windows] of 0..(n_intervals + 1) : bw_fin; % Включительно. -constraint forall (i in 1..n_bad_weather_windows) ( - forall (t in bw_start[i]..bw_fin[i]) (op_status[bw_op[i], t] == 0) +constraint forall (i in 1..n_bad_weather_windows, t in bw_start[i]..bw_fin[i]) ( + op_status[bw_op[i], t] == 0 ); -% Грузоообработка. +% Грузообработка. int : n_cargo_types; int : n_obj_with_storage; array [1..n_obj_with_storage, 0..(n_intervals + 1), 1..n_cargo_types] of var int : storage_used_volume; % Первые n_moving_obj соответствуют наполненности соответствующих движущихся объектов. @@ -135,11 +108,10 @@ constraint forall (storage in 1..n_obj_with_storage, t in 0..(n_intervals + 1)) 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]) + (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) ); @@ -164,9 +136,10 @@ constraint forall (storage in 1..n_obj_with_storage, cargo in 1..n_cargo_types, % Критерий оптимизации array [0..(n_intervals + 1)] of var bool : is_not_terminated; constraint (is_not_terminated[0] == 0 /\ is_not_terminated[n_intervals + 1] == 0); + constraint forall (t in 1..n_intervals) ( is_not_terminated[t] == ( - (not (forall (op in 1..n_operations) (op_status[op, t] == 0))) + (exists (op in 1..n_operations) (op_status[op, t] == 1)) \/ is_not_terminated[t + 1] ) -- GitLab