Commit 90dfc6f9 authored by Vladislav Kiselev's avatar Vladislav Kiselev

Добавлено взаимоисключение операций грузообработки с операциями перемещения в...

Добавлено взаимоисключение операций грузообработки с операциями перемещения в виде отдельного constraint-а.
parent 52525b8b
......@@ -131,7 +131,7 @@ array [1..n_operations] of 1..n_locations : operations_destination; % Локац
array [1..n_moving_obj] of set of 1..n_operations : operations_that_used_obj_as_resource;
% Является ли данная операция операцией перемещения.
array [1..n_operations] of bool : is_moving_operation;
array [0..n_operations] of bool : is_moving_operation;
% Операция, в которой участвует данный объект как ресурс.
array [1..n_moving_obj, 0..(n_intervals + 1)] of var 0..n_operations : participation_as_resource;
......@@ -205,6 +205,26 @@ array [1..n_operations] of 1..n_locations : operations_destination; % Локац
)
);
% Участие объекта в операциях грузообработки.
array [1..n_moving_obj, 1..n_intervals] of var bool : is_involved_in_cargo_op;
array [1..n_moving_obj] of set of 1..n_operations : related_cargo_op_using_obj_as_main;
% TODO узнать про where
constraint forall (obj in 1..n_moving_obj, t in 1..n_intervals) (
is_involved_in_cargo_op[obj, t] =
% (exists (op in 1..n_operations where (not is_moving_operation[op]) /\ (main_obj_of_operation[op] = obj)) (
(exists (op in related_cargo_op_using_obj_as_main[obj]) (
op_status[op, t]
))
\/
((participation_as_resource[obj, t] != 0) /\ (not is_moving_operation[participation_as_resource[obj, t]]))
);
constraint forall (obj in 1..n_moving_obj, t in 1..n_intervals) (
is_involved_in_cargo_op[obj, t] -> (current_moving_operation[obj, t] = 0)
);
% Наличие всех объектов на месте во время начала операции перемещения + готовность к началу.
% Требуемое положение конкретных типов объектов в момент начала операций.
array [1..n_resources_counters] of 1..n_locations : operations_resources_start_loc;
......@@ -228,8 +248,7 @@ array [1..n_operations] of 1..n_locations : operations_destination; % Локац
% Наличие и готовность главных объектов (субъектов).
constraint forall (op in 1..n_operations, t in 1..n_intervals, obj = main_obj_of_operation[op]) (
op_start[op, t] -> ((m_obj_loc[obj, t] == main_obj_start_loc[op]) /\
(not is_m_obj_in_movement_before_start[obj, t]) /\
((not is_moving_operation[op]) -> (current_moving_operation[obj, t] = 0))
(not is_m_obj_in_movement_before_start[obj, t])
)
);
......@@ -342,17 +361,6 @@ array [1..n_operations] of 1..n_locations : operations_destination; % Локац
)
);
% Участвует ли данный объект в операции грузообработки в качестве главного.
array [1..n_moving_obj, 1..n_intervals] of var bool : is_obj_involved_in_cargo_op_as_main_obj;
constraint forall (obj in 1..n_moving_obj, t in 1..n_intervals) (
is_obj_involved_in_cargo_op_as_main_obj[obj, t] = (
exists (op in 1..n_operations where (main_obj_of_operation[op] = obj) /\ (not is_moving_operation[op])) (
op_status[op, t]
)
)
);
array [1..n_operations, 1..n_intervals] of var bool : debug_1;
constraint forall (op in 1..n_operations, t in 1..n_intervals) (
debug_1[op, t] =
......@@ -370,7 +378,7 @@ array [1..n_operations] of 1..n_locations : operations_destination; % Локац
(is_enough_free_resources[op, t] = true) /\ % Достаточно свободных ресурсов на нужном месте.
(forall (conf_op in conflicting_operations[op]) (op_status[op, t] = false))
/\ % Не выполняется ни одной конфликтующей операции.
(is_moving_operation[op] -> not is_obj_involved_in_cargo_op_as_main_obj[main_obj_of_operation[op], t])
(is_moving_operation[op] -> not is_involved_in_cargo_op[main_obj_of_operation[op], t])
/\ % Если это операция перемещения, то главный объект
% не участвует в операциях погрузки.
((is_mooring_op[op] /\ (operations_destination[op] mod 2 = 0)) -> (
......
......@@ -964,6 +964,20 @@ public class ConversionUtil {
writeArray(writer, "related_unmoored_cargo_op", relatedUnmooredCargoOp, ConversionUtil::setToString);
}
private void cargoOpUsingObjAsMain() throws IOException {
ArrayList<Set<Integer>> relatedCargoOpUsingObjAsMain = new ArrayList<>();
for (int i = 0; i < movingObjects.size(); i++) {
relatedCargoOpUsingObjAsMain.add(new TreeSet<>());
}
for (int i = 0; i < operationTemplates.size(); i++) {
if (operationTemplates.get(i) instanceof LoadingTemplate) {
LoadingTemplate op = (LoadingTemplate) operationTemplates.get(i);
relatedCargoOpUsingObjAsMain.get(getMObjNumberById().get(op.getLoader().getId())).add(i + 1);
}
}
writeArray(writer, "related_cargo_op_using_obj_as_main", relatedCargoOpUsingObjAsMain, ConversionUtil::setToString);
}
void portToMiniZinc_0() throws IOException {
if (task.isTypified()) {
throw new ParserException("Attempt to convert typified task as untyped.");
......@@ -1169,7 +1183,7 @@ public class ConversionUtil {
isMovingOp.add((op instanceof MovingTemplate) || (op instanceof MooringTemplate));
}
writeArray(writer, "main_obj_start_loc", mainObjStartLoc, (Integer val) -> val + 1);
writeArray(writer, "is_moving_operation", isMovingOp);
writeArray(writer, "is_moving_operation", isMovingOp, Optional.of(false));
writer.write("\n");
}
{ // counters, operations_resources_start_loc
......@@ -1231,6 +1245,8 @@ public class ConversionUtil {
unmooredCargoOp();
cargoOpUsingObjAsMain();
writer.write("n_obj_with_storage = " + nObjWithStorage + ";\n");
writer.write("n_cargo_types = " + cargoes.size() + ";\n");
......
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