From 455a088cd62a5116453a5cf3d26d08a6291b257d 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: Fri, 28 Jun 2019 11:40:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D1=80=D1=83=D0=B3=D0=B0=D1=8F=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B6?= =?UTF-8?q?=D0=B0=D0=B4=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=B0=D0=BB=D0=B3=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D1=82=D0=BC=D0=B0.=20=D0=9F=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=D0=B4=D0=BD=D0=B8=D0=B9=20=D1=82=D0=B5=D1=81=D1=82,=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D0=BE=D0=BC=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20-=202=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D1=87=D0=B0=D0=BB=D0=B0,=201=20=D1=81=D1=83?= =?UTF-8?q?=D0=B4=D0=BD=D0=BE.=20=D0=A1=D1=83=D0=B4=D0=BD=D0=BE=20=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D1=82=20=D0=BD=D0=B0=20=D0=B2=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=BF=D1=80=D0=B8=D1=87=D0=B0=D0=BB,=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B0=D0=B5=D1=82=D1=81=D1=8F,?= =?UTF-8?q?=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F.=20=D0=92=D1=81=D0=B5=20=D0=B4=D0=B5=D0=B9=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=81=D0=B5=D0=BA=D1=83=D0=BD=D0=B4=D0=B5.=20?= =?UTF-8?q?=D0=93=D0=BE=D1=80=D0=B8=D0=B7=D0=BE=D0=BD=D1=82=20=D0=BF=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?6=20-=20=D0=B5=D1=89=D1=91=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82,=2010=20-=20=D1=81=D0=BB=D0=B8=D1=88=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=20=D0=B4=D0=BE=D0=BB=D0=B3=D0=BE=20=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=87=D0=B8=D0=BD=D0=B0=D0=B5=D1=82=20=D1=80=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D0=B8=20=D0=BF=D0=B0=D0=BC=D1=8F=D1=82=D1=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constraints/conversion_2_greedy.mzn | 95 +++++++++++++++++++------ 1 file changed, 72 insertions(+), 23 deletions(-) diff --git a/src/constraints/conversion_2_greedy.mzn b/src/constraints/conversion_2_greedy.mzn index bec3fdd..bbb1006 100644 --- a/src/constraints/conversion_2_greedy.mzn +++ b/src/constraints/conversion_2_greedy.mzn @@ -345,7 +345,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац array [1..n_loading_op] of 1..n_operations : loading_op_n; % Номера среди общего списка операций. array [1..n_all_storage_sections] of set of 1..n_loading_op : involved_operations; - + array [1..n_moving_obj] of set of 1..n_all_storage_sections : sections_of_moving_obj; + array [1..n_moving_obj] of bool : is_sections_of_moving_obj_empty; array [0..n_all_storage_sections] of int : storage_greedy_upper_limit; array [0..n_all_storage_sections] of int : storage_greedy_lower_limit; @@ -358,13 +359,14 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац array [0..n_sections_of_real_storage_and_bunkers, 0..max_number_of_connected_sections, 1..(n_intervals + 1)] of var int : nominal_cargo_value; array [0..n_sections_of_real_storage_and_bunkers, 0..(max_number_of_connected_sections + 1), 1..(n_intervals + 1)] of var int : cargo_overflow_remains; array [0..n_sections_of_real_storage_and_bunkers, 0..max_number_of_connected_sections, 1..(n_intervals + 1)] of var int : real_cargo_value; + array [0..n_sections_of_real_storage_and_bunkers, 1..(n_intervals + 1)] of var int : total_sum; % Определение real_cargo_value array [0..n_operations] of 0..n_all_storage_sections : operations_main_stor_no_in_secondary; array [0..n_operations] of 0..n_all_storage_sections : operations_secondary_stor_no_in_main; array [0..n_sections_of_real_storage_and_bunkers, 0..max_number_of_connected_sections] of set of 1..n_operations : connected_op_to_pair_of_sections; - +/* array [0..n_sections_of_real_storage_and_bunkers, 0..max_number_of_connected_sections, 1..(n_intervals + 1)] of var int : debug_1; constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1) where operations_main_stor_no_in_secondary[op] != 0) ( op_status[op, t] -> ( @@ -381,19 +383,41 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац -> (debug_1[section_1, section_2, t] = 0) ); - - - - +*/ % Определение nominal_cargo_value % Операция грузообработки активна -> нужные номинальные значения согласованы с ней. - constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1) where operations_main_stor_no_in_secondary[op] != 0) ( - op_status[op, t] -> ( - nominal_cargo_value[operations_secondary_stor[op], operations_main_stor_no_in_secondary[op], t] = - -max( - min(storage_greedy_upper_limit[operations_main_stor[op]] - storage_used_volume[operations_main_stor[op], t - 1], - loading_op_delta_of_main_obj[op]), - storage_greedy_lower_limit[operations_main_stor[op]] - storage_used_volume[operations_main_stor[op], t - 1]) + constraint forall (op in 1..n_operations, + t in 1..(n_intervals + 1), + section_1 = operations_main_stor[op], + section_2 = operations_secondary_stor[op], + pos = operations_main_stor_no_in_secondary[op] + where pos != 0) ( + let {var int : total_vol = storage_used_volume[section_1, t - 1] + loading_op_delta_of_main_obj[op];} in + (op_status[op, t] /\ total_vol > storage_greedy_upper_limit[section_1]) -> ( + nominal_cargo_value[section_2, pos, t] = -(loading_op_delta_of_main_obj[op] - (total_vol - storage_greedy_upper_limit[section_1])) + ) + ); + constraint forall (op in 1..n_operations, + t in 1..(n_intervals + 1), + section_1 = operations_main_stor[op], + section_2 = operations_secondary_stor[op], + pos = operations_main_stor_no_in_secondary[op] + where pos != 0) ( + let {var int : total_vol = storage_used_volume[section_1, t - 1] + loading_op_delta_of_main_obj[op];} in + (op_status[op, t] /\ total_vol < storage_greedy_lower_limit[section_1]) -> ( + nominal_cargo_value[section_2, pos, t] = -(loading_op_delta_of_main_obj[op] - (total_vol - storage_greedy_lower_limit[section_1])) + ) + ); + constraint forall (op in 1..n_operations, + t in 1..(n_intervals + 1), + section_1 = operations_main_stor[op], + section_2 = operations_secondary_stor[op], + pos = operations_main_stor_no_in_secondary[op] + where pos != 0) ( + let {var int : total_vol = storage_used_volume[section_1, t - 1] + loading_op_delta_of_main_obj[op];} in + (op_status[op, t] /\ (total_vol >= storage_greedy_lower_limit[section_1]) + /\ (total_vol <= storage_greedy_upper_limit[section_1])) -> ( + nominal_cargo_value[section_2, pos, t] = -loading_op_delta_of_main_obj[op] ) ); @@ -422,16 +446,34 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ); % Определение cargo_overflow_remains. - % Переполнение. + % array [0..n_sections_of_real_storage_and_bunkers, 1..(n_intervals + 1)] of var int : total_sum; constraint forall (t in 1..(n_intervals + 1), section in 1..n_sections_of_real_storage_and_bunkers) ( - let {var int : delta = sum (i in 1..number_of_connected_sections[section]) (nominal_cargo_value[section, i, t]); - var int : real_delta = min(max(delta, - storage_greedy_lower_limit[section] - storage_used_volume[section, t - 1]), - storage_greedy_upper_limit[section] - storage_used_volume[section, t - 1]); - } in ( - cargo_overflow_remains[section, number_of_connected_sections[section] + 1, t] = (delta - real_delta) - ) + total_sum[section, t] = sum (i in 1..number_of_connected_sections[section]) (nominal_cargo_value[section, i, t]) ); + constraint forall (t in 1..(n_intervals + 1)) (total_sum[0, t] = 0); + + % Переполнение. + constraint forall (t in 1..(n_intervals + 1), section in 1..n_sections_of_real_storage_and_bunkers) ( + (total_sum[section, t] + storage_used_volume[section, t - 1] > storage_greedy_upper_limit[section]) + -> + (cargo_overflow_remains[section, number_of_connected_sections[section] + 1, t] = + total_sum[section, t] + storage_used_volume[section, t - 1] - storage_greedy_upper_limit[section] + ) + ); + constraint forall (t in 1..(n_intervals + 1), section in 1..n_sections_of_real_storage_and_bunkers) ( + (total_sum[section, t] + storage_used_volume[section, t - 1] < storage_greedy_lower_limit[section]) + -> + (cargo_overflow_remains[section, number_of_connected_sections[section] + 1, t] = + total_sum[section, t] + storage_used_volume[section, t - 1] - storage_greedy_lower_limit[section] + ) + ); + constraint forall (t in 1..(n_intervals + 1), section in 1..n_sections_of_real_storage_and_bunkers) ( + let {var int : total = total_sum[section, t] + storage_used_volume[section, t - 1]} in + ((storage_greedy_lower_limit[section] <= total) /\ (total <= storage_greedy_upper_limit[section])) + -> + (cargo_overflow_remains[section, number_of_connected_sections[section] + 1, t] = 0) + ); + % Избавляемся от лишнего. % Если остаток переполнения и номналное значение одного знака, то полностью отменяем это номинальное значение. @@ -566,6 +608,7 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац array [1..n_fixed_op] of int : fixed_op_intensity; array [0..n_operations, 0..n_intervals] of bool : is_fixed; + array [0..n_moving_obj, 0..(n_intervals + 1)] of bool : is_obj_involved_in_fixed_op; constraint forall (no in 1..n_fixed_op, op = fixed_op[no]) ( forall (t in fixed_op_start[no]..fixed_op_end[no]) ( @@ -654,6 +697,9 @@ 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] ); */ + + array [1..n_moving_obj, 1..n_locations, 1..n_intervals] of bool : is_fixed_op_planned_in_future; + % Критерий оптимизации array [1..(n_intervals + 1)] of var bool : is_not_terminated; % В конце всё остановится. @@ -690,10 +736,13 @@ output [show(sum(is_not_terminated)), "\n", "cargo_overflow_remains {", show(max_number_of_connected_sections + 2), " ", show(n_intervals + 1), "} = ", show(cargo_overflow_remains), "\n\n", "real_cargo_value {", show(max_number_of_connected_sections + 1), " ", show(n_intervals + 1), "} = ", show(real_cargo_value), "\n\n", - "debug_1 {", show(max_number_of_connected_sections + 1), " ", show(n_intervals + 1), "} = ", show(debug_1), "\n\n", + % "debug_1 {", show(max_number_of_connected_sections + 1), " ", show(n_intervals + 1), "} = ", show(debug_1), "\n\n", + + + % "debug_storage_used_volume = ", show(debug_storage_used_volume), "\n\n", + "total_sum {", show(n_intervals + 1), "} = ", show(total_sum), "\n\n", - "debug_storage_used_volume = ", show(debug_storage_used_volume), "\n\n", /* "is_op_possible {", show(n_intervals), "} = ", show(is_op_possible), "\n\n", -- GitLab