diff --git a/src/inport/ConversionUtil.java b/src/inport/ConversionUtil.java index 4af060a6842010a51f5fb02d620b4e5b26e89b3f..865ed27168999d696acd650c1fa0745637f59fa1 100644 --- a/src/inport/ConversionUtil.java +++ b/src/inport/ConversionUtil.java @@ -1321,7 +1321,7 @@ public class ConversionUtil { isFixed.get(i).add(false); } } - for (Operation op : task.getSolution()) { + for (Operation op : task.getFixedOperations()) { if (op.getFixation()) { int operation = opNoByOpIdAndExecutorNo.get(new Pair<>(op.getTemplate().getId(), op.getExecutor().getId())); @@ -1378,7 +1378,7 @@ public class ConversionUtil { opNoByOpData.put(new OperationData(op.getId(), getExecutor(op).getId(), bunkerId), i); } - for (Operation op : task.getSolution()) { + for (Operation op : task.getFixedOperations()) { if (op.getFixation()) { OptionalInt bunkerId = op.getBunker().map(b -> OptionalInt.of(b.getId())).orElse(OptionalInt.empty()); @@ -1580,15 +1580,6 @@ public class ConversionUtil { } } -// System.out.print("#######\n"); -// for (int i = 0; i < sectionNById.size(); i++) { -// for (Integer val : positionsOfConnectedSections.get(i)) { -// System.out.print(val + " "); -// } -// System.out.print("\n"); -// } -// System.out.print("---\n"); - ArrayList operationsMainStorNoInSecondary = new ArrayList<>(); ArrayList operationsSecondaryStorNoInMain = new ArrayList<>(); @@ -1901,7 +1892,7 @@ public class ConversionUtil { isFixed = task.getIsFixedArray(); Set oldSolution = new TreeSet<>(); - for (Operation op : taskCase.getSolution()) { + for (Operation op : taskCase.getFixedOperations()) { if (op.getFixation()) { oldSolution.add(op.toString()); } diff --git a/src/inport/Operation.java b/src/inport/Operation.java index 536d7f4fef1422bdd5fc9f5bf88f43ea3a278c76..a98c22ad49a734819dd42d36a8722612cd53a482 100644 --- a/src/inport/Operation.java +++ b/src/inport/Operation.java @@ -4,8 +4,7 @@ */ package inport; -import java.util.List; -import java.util.Optional; +import java.util.*; /** * @@ -143,4 +142,50 @@ public class Operation { sb.append(")"); return sb.toString(); } + + public Operation(String str, + Map m_vessel, + Map m_bunker, + Map m_equipment, + Map m_template) { + + String lStr = str.substring(0, str.indexOf('(')).trim(); + String rStr = str.substring(str.indexOf('(') + 1, str.indexOf(')')).trim(); + + { + String[] items = lStr.split(";"); + setStart(Double.parseDouble(items[2].trim())); + setDuration(Double.parseDouble(items[3].trim())); + setTemplate(m_template.get(Integer.parseInt(items[0].trim()))); + + setFixation(items[1].trim().equals("F")); + } + { + String[] items = rStr.substring(rStr.indexOf('[') + 1, rStr.indexOf(']')).split(","); + ArrayList resources = new ArrayList<>(); + for (String item : items) { + if (item.trim().isEmpty()) { + continue; + } + resources.add(m_equipment.get(Integer.valueOf(item.trim()))); + } + setResources(resources); + } + { + String[] items = rStr.substring(0, rStr.indexOf('[')).split(" "); + + MovingObject ex = m_vessel.get(Integer.valueOf(items[0].trim())); + if (ex == null) { + ex = m_bunker.get(Integer.valueOf(items[0].trim())); + } + setExecutor(ex); + if (items.length > 1) { + setBunker(Optional.of(m_bunker.get(Integer.valueOf(items[1].trim())))); + } + } + String intensity = rStr.substring(rStr.indexOf(']') + 1).trim(); + if (! intensity.isEmpty()) { + setIntensity(Optional.of(Integer.valueOf(intensity))); + } + } } diff --git a/src/inport/TaskCase.java b/src/inport/TaskCase.java index fb6cb99a07c61b5b5af42b2982c30241efc54676..2a9524d7fcf1f6ac5b9550fc20b27cad4792fc4d 100644 --- a/src/inport/TaskCase.java +++ b/src/inport/TaskCase.java @@ -60,16 +60,26 @@ public class TaskCase { // Горизонт планирования private double planningInterval; - + + // Зафиксированные операции. + private List fixedOperations; + // Тип критерия оптимизации private int criterionType; - + // План - критерий private double solution_result; - + // План - решение private List solution; + public List getFixedOperations() { + return fixedOperations; + } + public void setFixedOperations(List fixedOperations) { + this.fixedOperations = fixedOperations; + } + public Map getBunkerTypes() { return bunkerTypes; } @@ -408,7 +418,9 @@ public class TaskCase { vesselEndState = new ArrayList<>(); storageEndState = new ArrayList<>(); - + + fixedOperations = new ArrayList<>(); + solution = new ArrayList<>(); } @@ -448,6 +460,7 @@ public class TaskCase { Final_Vessel_State ("Final Vessel State"), Final_Storage_State ("Final Storage State"), Task_Properties ("Task Properties"), + Fixed_Operations ("Fixed Operations"), Solution ("Solution"); private final String text; @@ -469,6 +482,7 @@ public class TaskCase { cargoes.clear(); berths.clear(); storages.clear(); bunkers.clear(); tows.clear(); equipments.clear(); ships.clear(); templates.clear(); cargoFlows.clear(); vesselInitialState.clear(); storageInitialState.clear(); vesselEndState.clear(); storageEndState.clear(); bunkerTypes.clear(); + fixedOperations.clear(); solution.clear(); // Open the file @@ -688,51 +702,14 @@ public class TaskCase { criterionType = Integer.parseInt(rs[1].trim()); } break; + case Fixed_Operations: + fixedOperations.add(new Operation(strLine, m_vessel, m_bunker, m_equipment, m_template)); + break; case Solution: // Чтение операций. if (numInside == 1) { solution_result = Double.parseDouble(strLine.trim()); } else { - String lStr = strLine.substring(0, strLine.indexOf('(')).trim(); - String rStr = strLine.substring(strLine.indexOf('(') + 1, strLine.indexOf(')')).trim(); - - Operation op = new Operation(); - { - String[] items = lStr.split(";"); - op.setStart(Double.parseDouble(items[2].trim())); - op.setDuration(Double.parseDouble(items[3].trim())); - op.setTemplate(m_template.get(Integer.parseInt(items[0].trim()))); - - op.setFixation(items[1].trim().equals("F")); - } - { - String[] items = rStr.substring(rStr.indexOf('[') + 1, rStr.indexOf(']')).split(","); - ArrayList resources = new ArrayList<>(); - for (String item : items) { - if (item.trim().isEmpty()) { - continue; - } - resources.add(m_equipment.get(Integer.valueOf(item.trim()))); - } - op.setResources(resources); - } - { - String[] items = rStr.substring(0, rStr.indexOf('[')).split(" "); - - MovingObject ex = m_vessel.get(Integer.valueOf(items[0].trim())); - if (ex == null) { - ex = m_bunker.get(Integer.valueOf(items[0].trim())); - } - op.setExecutor(ex); - if (items.length > 1) { - op.setBunker(Optional.of(m_bunker.get(Integer.valueOf(items[1].trim())))); - } - } - String intensity = rStr.substring(rStr.indexOf(']') + 1).trim(); - if (! intensity.isEmpty()) { - op.setIntensity(Optional.of(Integer.valueOf(intensity))); - } - - solution.add(op); + solution.add(new Operation(strLine, m_vessel, m_bunker, m_equipment, m_template)); } break; default: @@ -822,6 +799,11 @@ public class TaskCase { writer.write("\n"); writer.write("\nTask Properties"+"\n"); writer.write(planningInterval+"; "+criterionType+"\n"); + + writer.write("\n" + Tag.Fixed_Operations.text + "\n"); + for (Operation op : fixedOperations) { + writer.write(op.toString() + "\n"); + } writer.write("\n"); writer.write("\nSolution"+"\n"); writer.write(solution_result+"\n"); diff --git a/tests/with_typing/Bunkers.tipp b/tests/with_typing/Bunkers.tipp index 5e6714156a314fa40978417dbeeae635d199a706..2d7694a5f7b729a37cdf4cfbba6f5ff82ab9739f 100644 --- a/tests/with_typing/Bunkers.tipp +++ b/tests/with_typing/Bunkers.tipp @@ -76,6 +76,8 @@ Final Storage State Task Properties 20.0; 0 +Fixed Operations +20; F; 1.0; 2.0 (101 202 [] 2) Solution 8.0 diff --git a/tests/with_typing/FixedOperations.tipp b/tests/with_typing/FixedOperations.tipp index d4e56ac5760f64c6cb98c620be7f032dc2bd1843..ca8ac7ed72be18a9d0b2b05b25b3bc0816f187d3 100644 --- a/tests/with_typing/FixedOperations.tipp +++ b/tests/with_typing/FixedOperations.tipp @@ -62,6 +62,9 @@ Final Storage State Task Properties 30.0; 0 +Fixed Operations +21; F; 0.0; 3.0 (5 []) +19; F; 6.0; 3.0 (5 [] 10) Solution 18.0