Commit e5a324ff authored by Vladislav Kiselev's avatar Vladislav Kiselev

Жадная реализация переделана для работы с flatZinc решателями.

parent 1797d322
...@@ -59,8 +59,8 @@ array [0..n_moving_obj, 0..n_operations] of bool : moving_op_of_obj; ...@@ -59,8 +59,8 @@ array [0..n_moving_obj, 0..n_operations] of bool : moving_op_of_obj;
array [0..n_locations, 0..n_moving_obj, 1..op_with_nominally_mooring_max_size] of 1..n_operations : op_with_nominally_mooring; array [0..n_locations, 0..n_moving_obj, 1..op_with_nominally_mooring_max_size] of 1..n_operations : op_with_nominally_mooring;
% current_moored_obj соответствуе какому-либо реально пришвартованному объекту. % current_moored_obj соответствуе какому-либо реально пришвартованному объекту.
constraint forall (loc in 1..n_locations, t in 1..n_intervals, obj = current_moored_obj[loc, t] constraint forall (loc in 1..n_locations, t in 1..n_intervals where loc mod 2 = 0) (
where loc mod 2 = 0) ( let {var 0..n_moving_obj : obj = current_moored_obj[loc, t]} in
(obj != 0) -> ((m_obj_loc[obj, t] = loc) \/ (obj != 0) -> ((m_obj_loc[obj, t] = loc) \/
(exists (op in [op_with_nominally_mooring[loc, obj, id] | id in 1..op_with_nominally_mooring_sizes[loc, obj]]) (exists (op in [op_with_nominally_mooring[loc, obj, id] | id in 1..op_with_nominally_mooring_sizes[loc, obj]])
(op_status[op, t])) (op_status[op, t]))
...@@ -68,7 +68,8 @@ array [0..n_moving_obj, 0..n_operations] of bool : moving_op_of_obj; ...@@ -68,7 +68,8 @@ array [0..n_moving_obj, 0..n_operations] of bool : moving_op_of_obj;
); );
% Если объект пришвартован или швартуется, то current_moored_obj об это знает. % Если объект пришвартован или швартуется, то current_moored_obj об это знает.
constraint forall (obj in 1..n_moving_obj, t in 1..n_intervals, loc = m_obj_loc[obj, t]) ( constraint forall (obj in 1..n_moving_obj, t in 1..n_intervals) (
let {var 0..n_locations : loc = m_obj_loc[obj, t]} in
(loc mod 2 = 0) -> (current_moored_obj[loc, t] = obj) (loc mod 2 = 0) -> (current_moored_obj[loc, t] = obj)
); );
...@@ -258,23 +259,24 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -258,23 +259,24 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
% Наличие главных объектов на месте. % Наличие главных объектов на месте.
constraint forall (op in 1..n_operations, constraint forall (op in 1..n_operations,
t in 1..n_intervals, t in 1..n_intervals) (
obj = main_obj_of_operation[op]) ( let {1..n_moving_obj : obj = main_obj_of_operation[op]} in
op_start[op, t] -> (m_obj_loc[obj, t] == main_obj_start_loc[op]) op_start[op, t] -> (m_obj_loc[obj, t] == main_obj_start_loc[op])
); );
% Наличие бункеровщиков на месте. % Наличие бункеровщиков на месте.
constraint forall (op in 1..n_operations, constraint forall (op in 1..n_operations,
t in 1..n_intervals, t in 1..n_intervals
obj = bunker_of_cargo_op[op] where obj != 0) ( where bunker_of_cargo_op[op] != 0) (
op_start[op, t] -> (m_obj_loc[obj, t] == bunker_start_loc[op]) op_start[op, t] -> (m_obj_loc[bunker_of_cargo_op[op], t] == bunker_start_loc[op])
); );
% Непрерывность перемещения и швартовки. % Непрерывность перемещения и швартовки.
array [0..n_operations] of int : operations_duration; array [0..n_operations] of int : operations_duration;
array [0..n_operations] of bool : is_continuous_operation; array [0..n_operations] of bool : is_continuous_operation;
constraint forall (i in 1..n_operations, len = operations_duration[i] where is_continuous_operation[i]) ( constraint forall (i in 1..n_operations where is_continuous_operation[i]) (
let {int : len = operations_duration[i]} in
(forall (j in 1..(n_intervals - len + 1)) ( (forall (j in 1..(n_intervals - len + 1)) (
(op_start[i, j] == 1) -> ( (op_start[i, j] == 1) -> (
(forall (k in 1..(len - 1)) (op_status[i, j + k])) (forall (k in 1..(len - 1)) (op_status[i, j + k]))
...@@ -397,34 +399,37 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -397,34 +399,37 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
% Определение nominal_cargo_value % Определение nominal_cargo_value
% Операция грузообработки активна -> нужные номинальные значения согласованы с ней. % Операция грузообработки активна -> нужные номинальные значения согласованы с ней.
constraint forall (op in 1..n_operations, constraint forall (op in 1..n_operations,
t in 1..(n_intervals + 1), t in 1..(n_intervals + 1)
section_1 = operations_main_stor[op], where operations_main_stor_no_in_secondary[op] != 0) (
section_2 = operations_secondary_stor[op], let {
pos = operations_main_stor_no_in_secondary[op] var 1..n_all_storage_sections : section_1 = operations_main_stor[op];
where pos != 0) ( var 1..n_all_storage_sections : section_2 = operations_secondary_stor[op];
let {var int : total_vol = storage_used_volume[section_1, t - 1] + loading_op_delta_of_main_obj[op];} in 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]) -> ( (op_status[op, t] /\ total_vol > storage_greedy_upper_limit[section_1]) -> (
nominal_cargo_value[op, t] = -(loading_op_delta_of_main_obj[op] - (total_vol - storage_greedy_upper_limit[section_1])) nominal_cargo_value[op, t] = -(loading_op_delta_of_main_obj[op] - (total_vol - storage_greedy_upper_limit[section_1]))
) )
); );
constraint forall (op in 1..n_operations, constraint forall (op in 1..n_operations,
t in 1..(n_intervals + 1), t in 1..(n_intervals + 1)
section_1 = operations_main_stor[op], where operations_main_stor_no_in_secondary[op] != 0) (
section_2 = operations_secondary_stor[op], let {
pos = operations_main_stor_no_in_secondary[op] var 1..n_all_storage_sections : section_1 = operations_main_stor[op];
where pos != 0) ( var 1..n_all_storage_sections : section_2 = operations_secondary_stor[op];
let {var int : total_vol = storage_used_volume[section_1, t - 1] + loading_op_delta_of_main_obj[op];} in 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]) -> ( (op_status[op, t] /\ total_vol < storage_greedy_lower_limit[section_1]) -> (
nominal_cargo_value[op, t] = -(loading_op_delta_of_main_obj[op] - (total_vol - storage_greedy_lower_limit[section_1])) nominal_cargo_value[op, t] = -(loading_op_delta_of_main_obj[op] - (total_vol - storage_greedy_lower_limit[section_1]))
) )
); );
constraint forall (op in 1..n_operations, constraint forall (op in 1..n_operations,
t in 1..(n_intervals + 1), t in 1..(n_intervals + 1)
section_1 = operations_main_stor[op], where operations_main_stor_no_in_secondary[op] != 0) (
section_2 = operations_secondary_stor[op], let {
pos = operations_main_stor_no_in_secondary[op] var 1..n_all_storage_sections : section_1 = operations_main_stor[op];
where pos != 0) ( var 1..n_all_storage_sections : section_2 = operations_secondary_stor[op];
let {var int : total_vol = storage_used_volume[section_1, t - 1] + loading_op_delta_of_main_obj[op];} in 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]) (op_status[op, t] /\ (total_vol >= storage_greedy_lower_limit[section_1])
/\ (total_vol <= storage_greedy_upper_limit[section_1])) -> ( /\ (total_vol <= storage_greedy_upper_limit[section_1])) -> (
nominal_cargo_value[op, t] = -loading_op_delta_of_main_obj[op] nominal_cargo_value[op, t] = -loading_op_delta_of_main_obj[op]
...@@ -452,8 +457,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -452,8 +457,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
); );
% Нецелая операция. % Нецелая операция.
% Переполнение за нижнюю границу. % Переполнение за нижнюю границу.
constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1), constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1)) ( % Нецелая операция.
section = operations_secondary_stor[op]) ( % Нецелая операция. let {1..n_all_storage_sections : section = operations_secondary_stor[op]} in
( (current_partial_cargo_op[section, t] == op) ( (current_partial_cargo_op[section, t] == op)
/\ (nominal_cargo_value[op, t] < 0) /\ (nominal_cargo_value[op, t] < 0)
/\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] < storage_greedy_lower_limit[section]) /\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] < storage_greedy_lower_limit[section])
...@@ -465,8 +470,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -465,8 +470,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
) )
); );
% Переполнение за верхнюю границу. % Переполнение за верхнюю границу.
constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1), constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1)) ( % Нецелая операция.
section = operations_secondary_stor[op]) ( % Нецелая операция. let {1..n_all_storage_sections : section = operations_secondary_stor[op]} in
( (current_partial_cargo_op[section, t] == op) ( (current_partial_cargo_op[section, t] == op)
/\ (nominal_cargo_value[op, t] > 0) /\ (nominal_cargo_value[op, t] > 0)
/\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] > storage_greedy_upper_limit[section]) /\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] > storage_greedy_upper_limit[section])
...@@ -478,16 +483,16 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -478,16 +483,16 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
) )
); );
% Переполнения нет. % Переполнения нет.
constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1), constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1)) ( % Нецелая операция.
section = operations_secondary_stor[op]) ( % Нецелая операция. let {1..n_all_storage_sections : section = operations_secondary_stor[op]} in
( (current_partial_cargo_op[section, t] == op) ( (current_partial_cargo_op[section, t] == op)
/\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] <= storage_greedy_upper_limit[section]) /\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] <= storage_greedy_upper_limit[section])
/\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] >= storage_greedy_lower_limit[section]) /\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] >= storage_greedy_lower_limit[section])
) -> (real_cargo_value[op, t] = nominal_cargo_value[op, t]) ) -> (real_cargo_value[op, t] = nominal_cargo_value[op, t])
); );
% Неустранимое переполнение за нижнюю границу. % Неустранимое переполнение за нижнюю границу.
constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1), constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1)) ( % Нецелая операция.
section = operations_secondary_stor[op]) ( % Нецелая операция. let {1..n_all_storage_sections : section = operations_secondary_stor[op]} in
( (current_partial_cargo_op[section, t] == op) ( (current_partial_cargo_op[section, t] == op)
/\ (nominal_cargo_value[op, t] <= 0) /\ (nominal_cargo_value[op, t] <= 0)
/\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] < storage_greedy_lower_limit[section]) /\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] < storage_greedy_lower_limit[section])
...@@ -496,8 +501,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -496,8 +501,8 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
) -> (real_cargo_value[op, t] = 0) ) -> (real_cargo_value[op, t] = 0)
); );
% Неустранимое переполнение за верхнюю границу. % Неустранимое переполнение за верхнюю границу.
constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1), constraint forall (op in 1..n_operations, t in 1..(n_intervals + 1)) ( % Нецелая операция.
section = operations_secondary_stor[op]) ( % Нецелая операция. let {1..n_all_storage_sections : section = operations_secondary_stor[op]} in
( (current_partial_cargo_op[section, t] == op) ( (current_partial_cargo_op[section, t] == op)
/\ (nominal_cargo_value[op, t] >= 0) /\ (nominal_cargo_value[op, t] >= 0)
/\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] > storage_greedy_upper_limit[section]) /\ (nominal_incoming_sum[section, t] + storage_used_volume[section, t - 1] > storage_greedy_upper_limit[section])
...@@ -546,11 +551,11 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац ...@@ -546,11 +551,11 @@ array [0..n_operations] of 0..n_locations : operations_destination; % Локац
array [0..n_operations, 0..n_intervals] of bool : is_fixed; 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; 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]) ( constraint forall (no in 1..n_fixed_op) (
forall (t in fixed_op_start[no]..fixed_op_end[no]) ( forall (t in fixed_op_start[no]..fixed_op_end[no]) (
(op_status[op, t]) (op_status[fixed_op[no], t])
/\ (forall (obj in fixed_op_resources[no]) (participation_as_resource[obj, t] = op)) /\ (forall (obj in fixed_op_resources[no]) (participation_as_resource[obj, t] = fixed_op[no]))
/\ (real_cargo_value[op, t] = -fixed_op_intensity[no]) /\ (real_cargo_value[fixed_op[no], t] = -fixed_op_intensity[no])
) )
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment