From 4746f729d306409089b8524b5c86ec0e31fcba0d 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: Tue, 14 May 2019 16:38:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=95=D1=89=D1=91=20=D0=BE=D0=BF=D1=82=D0=B8?= =?UTF-8?q?=D0=BC=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ersion_2_with_partial_cargo_operations.mzn | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/constraints/conversion_2_with_partial_cargo_operations.mzn b/src/constraints/conversion_2_with_partial_cargo_operations.mzn index 0b6e9c9..cfcaaf7 100644 --- a/src/constraints/conversion_2_with_partial_cargo_operations.mzn +++ b/src/constraints/conversion_2_with_partial_cargo_operations.mzn @@ -429,6 +429,22 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ) ); + array [1..n_operations, 1..n_intervals] of var bool : is_cargo_op_not_exceeds_storage_limits; + constraint forall (op in 1..n_operations, t in 1..n_intervals) ( + is_cargo_op_not_exceeds_storage_limits[op, t] = + ((not is_moving_operation[op]) -> ( + let {1..n_obj_with_storage : m_stor = operations_main_stor[op]; + 1..n_obj_with_storage : s_stor = operations_secondary_stor[op]; + 1..n_cargo_types : cargo = operations_cargo_t[op]; + int : delta = loading_op_direction[op]; + } in + (storage_used_volume[m_stor, t, cargo] + delta >= 0) /\ + ((sum (c in 1..n_cargo_types) (storage_used_volume[m_stor, t, c])) + delta <= max_storage_vol[m_stor]) /\ + (storage_used_volume[s_stor, t, cargo] - delta >= 0) /\ + ((sum (c in 1..n_cargo_types) (storage_used_volume[s_stor, t, c])) - delta <= max_storage_vol[s_stor]) + )) + ); + % Определение is_op_possible. constraint forall (op in 1..n_operations, t in 1..n_intervals) ( is_op_possible[op, t] = ( @@ -447,18 +463,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац current_moored_obj[operations_destination[op], t] = 0) ) /\ % Если это операция пришвартовки, то в этот интервал % причал должен быть свободным. - ((not is_moving_operation[op]) -> ( - let {1..n_obj_with_storage : m_stor = operations_main_stor[op]; - 1..n_obj_with_storage : s_stor = operations_secondary_stor[op]; - 1..n_cargo_types : cargo = operations_cargo_t[op]; - int : delta = loading_op_direction[op]; - } in - (storage_used_volume[m_stor, t, cargo] + delta >= 0) /\ - ((sum (c in 1..n_cargo_types) (storage_used_volume[m_stor, t, c])) + delta <= max_storage_vol[m_stor]) /\ - (storage_used_volume[s_stor, t, cargo] - delta >= 0) /\ - ((sum (c in 1..n_cargo_types) (storage_used_volume[s_stor, t, c])) - delta <= max_storage_vol[s_stor]) - )) /\ % Если это операция грузообработки, то она не выведет - % объём берегового хранилища и хранилища судна за + (is_cargo_op_not_exceeds_storage_limits[op, t]) % Если это операция грузообработки, то она не выведет + /\ % объём берегового хранилища и хранилища судна за % границы дозволенного (если исполнится при минимальной % интенсивности 1). (((not is_moving_operation[op]) /\ (main_obj_start_loc[op] mod 2 = 1)) -> @@ -480,6 +486,16 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац (op_start[op, t] /\ (not is_fixed[op, t])) -> not is_op_possible[op, t - 1] ); +% Оптимизация - есть две соседние операции погрузки - первая операция должна быть максимально загруженной. + constraint forall (op in 1..n_operations, t in 2..n_intervals) ( + ((cargo_op_intensity[op, t - 1] != 0) /\ (cargo_op_intensity[op, t] != 0)) -> ( + (cargo_op_intensity[op, t - 1] = loading_op_abs_delta[op]) \/ % Операция достигла предела интенсивности. + (not is_cargo_op_not_exceeds_storage_limits[op, t - 1]) % Или операция нарушит границы хранилищ + \/ % при увеличении интенсивности. + (is_fixed[op, t]) % Или операция фиксирована. + ) + ); + % Критерий оптимизации array [1..(n_intervals + 1)] of var bool : is_not_terminated; % В конце всё остановится. -- GitLab