Commit 62bd0d72 authored by Vladislav Kiselev's avatar Vladislav Kiselev

few bugs fixed

parent 57cda042
......@@ -41,7 +41,7 @@ array [1..n_moving_obj, 0..(n_intervals + 1)] of var bool : is_m_obj_in_movement
if (current_moving_operation[obj, t - 1] = 0) then
is_m_obj_in_movement_before_start[obj, t] = false
else
is_m_obj_in_movement_before_start[obj, t] = (current_moving_operation[obj, t - 1] != current_moving_operation[obj, t])
is_m_obj_in_movement_before_start[obj, t] = (current_moving_operation[obj, t - 1] == current_moving_operation[obj, t])
endif
);
......@@ -285,6 +285,8 @@ output [show(sum(is_not_terminated)), "\n",
"op_start = ", show(op_start), "\n\n",
"is_not_terminated = ", show(is_not_terminated), "\n\n",
"storage_used_volume = ", show(storage_used_volume), "\n\n",
"is_m_obj_in_movement_before_start = ", show(is_m_obj_in_movement_before_start), "\n\n",
"current_moving_operation = ", show(current_moving_operation), "\n\n"
% "prev_m_obj_loc = ", show(prev_m_obj_loc), "\n\n",
% "next_m_obj_loc = ", show(next_m_obj_loc), "\n\n",
% "is_interval_useful = ", show(is_interval_useful), "\n\n"
......
......@@ -201,8 +201,8 @@ public class ConversionUtil {
return null;
}
static private List<Object> getResources(OperationTemplate t) {
List<Object> res = new ArrayList<>();
static private List<MovingObject> getResources(OperationTemplate t) {
List<MovingObject> res = new ArrayList<>();
if (t instanceof LoadingTemplate) {
res.addAll(((LoadingTemplate) t).getResources());
}
......@@ -218,11 +218,11 @@ public class ConversionUtil {
static private boolean isCompatible(OperationTemplate t1, OperationTemplate t2) {
MovingObject exec1 = getExecutor(t1);
Berth place1 = t1.getStartLocation();
List<Object> resources1 = getResources(t1);
List<MovingObject> resources1 = getResources(t1);
MovingObject exec2 = getExecutor(t2);
Berth place2 = t2.getStartLocation();
List<Object> resources2 = getResources(t2);
List<MovingObject> resources2 = getResources(t2);
// Пересекаемость ресурсов
for (Object res2 : resources2)
if (resources1.contains(res2))
......@@ -643,6 +643,8 @@ public class ConversionUtil {
BiConsumer<MovingObject, Integer> addUsOp = (MovingObject obj, Integer op) ->
objUsefulOperations.get(mObjToN.apply(obj)).add(op + 1);
BiConsumer<MovingObject, Integer> addMovingOp = (MovingObject obj, Integer op) ->
movingOpOfObj.get(mObjToN.apply(obj)).add(op + 1);
for (int i = 0; i < movingObjects.size(); i++) {
movingOpOfObj.add(new TreeSet<>());
......@@ -654,20 +656,20 @@ public class ConversionUtil {
if (t instanceof MovingTemplate) {
MovingTemplate op = (MovingTemplate)t;
int id = mObjToN.apply(op.getMover());
movingOpOfObj.get(id).add(i + 1);
addMovingOp.accept(op.getMover(), i);
for (MovingObject obj : op.getResources()) {
addUsOp.accept(obj, i);
addMovingOp.accept(obj, i);
}
} else if (t instanceof MooringTemplate) {
MooringTemplate op = (MooringTemplate)t;
int id = mObjToN.apply(op.getMoorer());
movingOpOfObj.get(id).add(i + 1);
addMovingOp.accept(op.getMoorer(), i);
for (MovingObject obj : op.getResources()) {
addUsOp.accept(obj, i);
addMovingOp.accept(obj, i);
}
if (!op.isDirect()) { // Отшвартовка.
......@@ -730,12 +732,17 @@ public class ConversionUtil {
movingOpOfObj.add(new TreeSet<>());
}
BiConsumer<MovingObject, Integer> addMovingOp = (MovingObject obj, Integer op) ->
movingOpOfObj.get(mObjToN.apply(obj)).add(op + 1);
for (int i = 0; i < operationTemplates.size(); i++) {
OperationTemplate t = operationTemplates.get(i);
if ((t instanceof MovingTemplate) || (t instanceof MooringTemplate)) {
int id = mObjToN.apply(getExecutor(t));
movingOpOfObj.get(id).add(i + 1);
addMovingOp.accept(getExecutor(t), i);
for (MovingObject obj : getResources(t)) {
addMovingOp.accept(obj, i);
}
}
if (t instanceof MovingTemplate) {
MovingTemplate op = (MovingTemplate)t;
......@@ -835,8 +842,14 @@ public class ConversionUtil {
taskData.portToMiniZinc_1();
}
private static class OperationsComparator implements Comparator<Operation> {
public int compare(Operation op1, Operation op2) {
return Double.compare(op1.getStart(), op2.getStart());
}
}
static public void resolveMiniZincResults(TaskCase task, String fileName) throws IOException, ParserException {
List<Operation> operations = null;
ArrayList<Operation> operations = null;
Integer result = null;
try (FileInputStream fstream = new FileInputStream(fileName)) {
......@@ -906,6 +919,7 @@ public class ConversionUtil {
if (result == null) {
throw new ParserException("No result in input");
}
operations.sort(new OperationsComparator());
task.setSolution(operations);
task.setSolution_result(result);
}
......
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