Commit f75c0cc0 authored by Vladislav Kiselev's avatar Vladislav Kiselev

Теперь фиксированные операции задаются отдельно от решения.

parent 1297c475
...@@ -1321,7 +1321,7 @@ public class ConversionUtil { ...@@ -1321,7 +1321,7 @@ public class ConversionUtil {
isFixed.get(i).add(false); isFixed.get(i).add(false);
} }
} }
for (Operation op : task.getSolution()) { for (Operation op : task.getFixedOperations()) {
if (op.getFixation()) { if (op.getFixation()) {
int operation = opNoByOpIdAndExecutorNo.get(new Pair<>(op.getTemplate().getId(), op.getExecutor().getId())); int operation = opNoByOpIdAndExecutorNo.get(new Pair<>(op.getTemplate().getId(), op.getExecutor().getId()));
...@@ -1378,7 +1378,7 @@ public class ConversionUtil { ...@@ -1378,7 +1378,7 @@ public class ConversionUtil {
opNoByOpData.put(new OperationData(op.getId(), getExecutor(op).getId(), bunkerId), i); opNoByOpData.put(new OperationData(op.getId(), getExecutor(op).getId(), bunkerId), i);
} }
for (Operation op : task.getSolution()) { for (Operation op : task.getFixedOperations()) {
if (op.getFixation()) { if (op.getFixation()) {
OptionalInt bunkerId = op.getBunker().map(b -> OptionalInt.of(b.getId())).orElse(OptionalInt.empty()); OptionalInt bunkerId = op.getBunker().map(b -> OptionalInt.of(b.getId())).orElse(OptionalInt.empty());
...@@ -1580,15 +1580,6 @@ public class ConversionUtil { ...@@ -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<Integer> operationsMainStorNoInSecondary = new ArrayList<>(); ArrayList<Integer> operationsMainStorNoInSecondary = new ArrayList<>();
ArrayList<Integer> operationsSecondaryStorNoInMain = new ArrayList<>(); ArrayList<Integer> operationsSecondaryStorNoInMain = new ArrayList<>();
...@@ -1901,7 +1892,7 @@ public class ConversionUtil { ...@@ -1901,7 +1892,7 @@ public class ConversionUtil {
isFixed = task.getIsFixedArray(); isFixed = task.getIsFixedArray();
Set<String> oldSolution = new TreeSet<>(); Set<String> oldSolution = new TreeSet<>();
for (Operation op : taskCase.getSolution()) { for (Operation op : taskCase.getFixedOperations()) {
if (op.getFixation()) { if (op.getFixation()) {
oldSolution.add(op.toString()); oldSolution.add(op.toString());
} }
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
*/ */
package inport; package inport;
import java.util.List; import java.util.*;
import java.util.Optional;
/** /**
* *
...@@ -143,4 +142,50 @@ public class Operation { ...@@ -143,4 +142,50 @@ public class Operation {
sb.append(")"); sb.append(")");
return sb.toString(); return sb.toString();
} }
public Operation(String str,
Map<Integer, MovingObject> m_vessel,
Map<Integer, Bunker> m_bunker,
Map<Integer, LoadingEquipment> m_equipment,
Map<Integer, OperationTemplate> 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<MovingObject> 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)));
}
}
} }
...@@ -60,16 +60,26 @@ public class TaskCase { ...@@ -60,16 +60,26 @@ public class TaskCase {
// Горизонт планирования // Горизонт планирования
private double planningInterval; private double planningInterval;
// Зафиксированные операции.
private List<Operation> fixedOperations;
// Тип критерия оптимизации // Тип критерия оптимизации
private int criterionType; private int criterionType;
// План - критерий // План - критерий
private double solution_result; private double solution_result;
// План - решение // План - решение
private List<Operation> solution; private List<Operation> solution;
public List<Operation> getFixedOperations() {
return fixedOperations;
}
public void setFixedOperations(List<Operation> fixedOperations) {
this.fixedOperations = fixedOperations;
}
public Map<Integer, String> getBunkerTypes() { public Map<Integer, String> getBunkerTypes() {
return bunkerTypes; return bunkerTypes;
} }
...@@ -408,7 +418,9 @@ public class TaskCase { ...@@ -408,7 +418,9 @@ public class TaskCase {
vesselEndState = new ArrayList<>(); vesselEndState = new ArrayList<>();
storageEndState = new ArrayList<>(); storageEndState = new ArrayList<>();
fixedOperations = new ArrayList<>();
solution = new ArrayList<>(); solution = new ArrayList<>();
} }
...@@ -448,6 +460,7 @@ public class TaskCase { ...@@ -448,6 +460,7 @@ public class TaskCase {
Final_Vessel_State ("Final Vessel State"), Final_Vessel_State ("Final Vessel State"),
Final_Storage_State ("Final Storage State"), Final_Storage_State ("Final Storage State"),
Task_Properties ("Task Properties"), Task_Properties ("Task Properties"),
Fixed_Operations ("Fixed Operations"),
Solution ("Solution"); Solution ("Solution");
private final String text; private final String text;
...@@ -469,6 +482,7 @@ public class TaskCase { ...@@ -469,6 +482,7 @@ public class TaskCase {
cargoes.clear(); berths.clear(); storages.clear(); bunkers.clear(); tows.clear(); equipments.clear(); ships.clear(); templates.clear(); 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(); cargoFlows.clear(); vesselInitialState.clear(); storageInitialState.clear(); vesselEndState.clear(); storageEndState.clear();
bunkerTypes.clear(); bunkerTypes.clear();
fixedOperations.clear();
solution.clear(); solution.clear();
// Open the file // Open the file
...@@ -688,51 +702,14 @@ public class TaskCase { ...@@ -688,51 +702,14 @@ public class TaskCase {
criterionType = Integer.parseInt(rs[1].trim()); criterionType = Integer.parseInt(rs[1].trim());
} }
break; break;
case Fixed_Operations:
fixedOperations.add(new Operation(strLine, m_vessel, m_bunker, m_equipment, m_template));
break;
case Solution: // Чтение операций. case Solution: // Чтение операций.
if (numInside == 1) { if (numInside == 1) {
solution_result = Double.parseDouble(strLine.trim()); solution_result = Double.parseDouble(strLine.trim());
} else { } else {
String lStr = strLine.substring(0, strLine.indexOf('(')).trim(); solution.add(new Operation(strLine, m_vessel, m_bunker, m_equipment, m_template));
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<MovingObject> 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);
} }
break; break;
default: default:
...@@ -822,6 +799,11 @@ public class TaskCase { ...@@ -822,6 +799,11 @@ public class TaskCase {
writer.write("\n"); writer.write("\n");
writer.write("\nTask Properties"+"\n"); writer.write("\nTask Properties"+"\n");
writer.write(planningInterval+"; "+criterionType+"\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("\n");
writer.write("\nSolution"+"\n"); writer.write("\nSolution"+"\n");
writer.write(solution_result+"\n"); writer.write(solution_result+"\n");
......
...@@ -76,6 +76,8 @@ Final Storage State ...@@ -76,6 +76,8 @@ Final Storage State
Task Properties Task Properties
20.0; 0 20.0; 0
Fixed Operations
20; F; 1.0; 2.0 (101 202 [] 2)
Solution Solution
8.0 8.0
......
...@@ -62,6 +62,9 @@ Final Storage State ...@@ -62,6 +62,9 @@ Final Storage State
Task Properties Task Properties
30.0; 0 30.0; 0
Fixed Operations
21; F; 0.0; 3.0 (5 [])
19; F; 6.0; 3.0 (5 [] 10)
Solution Solution
18.0 18.0
......
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