Commit 7f3d6101 authored by Vladislav Kiselev's avatar Vladislav Kiselev

Переделаны окна погоды и конфликтующте операции. Добавлена оптимизация.

parent 2e554245
This diff is collapsed.
......@@ -510,6 +510,28 @@ public class ConversionUtil {
writer.write("\n");
}
/* Окна погоды. Новый формат. */
private void weatherWindowsNewFormat() throws IOException {
ArrayList<ArrayList<Boolean>> badWeather = new ArrayList<>();
for (int i = 0; i < operationTemplates.size(); i++) {
ArrayList<Boolean> curLine = new ArrayList<>();
for (int j = 0; j < n_intervals; j++) {
curLine.add(false);
}
operationTemplates.get(i).getTimeWindows().forEach(
(Double start, Double duration) -> {
for (int j = (int)Math.floor(start); j < (int)Math.ceil(start + duration); j++) {
curLine.set(j, true);
}
}
);
badWeather.add(curLine);
}
locWrite2DArray(writer, "bad_weather", badWeather, Objects::toString);
}
/* Непрерывность перемещения и швартовки. */
private void operationsContinuity() throws IOException {
ArrayList<Integer> operationsDuration = integerArray(operationTemplates.size(), 0);
......@@ -994,18 +1016,21 @@ public class ConversionUtil {
}
private void conflictingOperationsOnStorageAndOnTypeOnMainObject() throws IOException {
ArrayList<Pair<Integer, Integer>> conflictingPairs = new ArrayList<>();
ArrayList<Set<Integer>> conflictingOperationsG = new ArrayList<>();
for (int i = 0; i < operationTemplates.size(); i++) {
for (int j = i + 1; j < operationTemplates.size(); j++) {
conflictingOperationsG.add(new TreeSet<>());
for (int j = 0; j < operationTemplates.size(); j++) {
if (i == j) {
continue;
}
if ((operationTemplates.get(i) instanceof LoadingTemplate) &&
(operationTemplates.get(j) instanceof LoadingTemplate)) {
LoadingTemplate op1 = (LoadingTemplate) operationTemplates.get(i);
LoadingTemplate op2 = (LoadingTemplate) operationTemplates.get(j);
if ((op1.getLoader() == op2.getLoader()) &&
(op1.getStorage() == op2.getStorage()) &&
if ((op1.getStorage() == op2.getStorage()) &&
(op1.getStartLocation() == op2.getStartLocation())) {
conflictingPairs.add(new Pair<>(i + 1, j + 1));
conflictingOperationsG.get(i).add(j + 1);
}
}
{ // Взаимоисключение операций перемещения и грузообработки с общим деятелем.
......@@ -1020,7 +1045,7 @@ public class ConversionUtil {
if (((t1 instanceof MovingTemplate) || (t1 instanceof MooringTemplate))
&& (t2 instanceof LoadingTemplate)) {
if (getExecutor(t1) == getExecutor(t2)) {
conflictingPairs.add(new Pair<>(i + 1, j + 1));
conflictingOperationsG.get(i).add(j + 1);
}
}
}
......@@ -1032,16 +1057,13 @@ public class ConversionUtil {
MooringTemplate op2 = (MooringTemplate) operationTemplates.get(j);
if (op1.getStartLocation() == op2.getStartLocation()) {
conflictingPairs.add(new Pair<>(i + 1, j + 1));
conflictingOperationsG.get(i).add(j + 1);
}
}
}
}
}
writer.write("n_conflicting_op = " + conflictingPairs.size() + ";\n");
writeArray(writer, "confl_op_1", conflictingPairs, Pair::getKey);
writeArray(writer, "confl_op_2", conflictingPairs, Pair::getValue);
writer.write("\n");
writeArray(writer, "conflicting_operations", conflictingOperationsG, ConversionUtil::setToString);
}
private void typifiedResourcesDefinition() throws IOException {
......@@ -1131,7 +1153,7 @@ public class ConversionUtil {
movingObjectLocationDefinition();
initialLocations();
finalLocations();
weatherWindows();
weatherWindowsNewFormat();
conflictingOperationsOnStorageAndOnTypeOnMainObject();
operationsContinuity();
......
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