From 854b595e4f1b58ec7072e34c0cce069f62f4bd90 Mon Sep 17 00:00:00 2001 From: Vlad_kv Date: Thu, 11 Jul 2019 15:33:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 8 ++-- src/inport/ConversionUtils/Task.java | 5 +- src/inport/InPort.java | 70 ++++++++++++++-------------- src/inport/Storage.java | 8 +++- src/inport/TransportShip.java | 9 +++- 5 files changed, 57 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index c15e99f..7a6f809 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ +.PHONY: Conversion.jar + out_dir = temp -Conversion.jar: src/inport/**/*.java src/constraints/*.mzn +Conversion.jar: mkdir -p $(out_dir) - javac -d $(out_dir) -encoding UTF-8 -classpath annotations-java8.jar src/inport/*.java src/inport/ConversionUtils/*.java - jar cfe Conversion.jar inport.Main -C $(out_dir) inport -C src constraints + javac -d $(out_dir) -encoding UTF-8 -cp annotations-java8.jar -cp org.sat4j.core.jar -cp org.sat4j.pb.jar src/inport/*.java src/inport/ConversionUtils/*.java + jar cfe Conversion.jar inport.Main org.sat4j.core.jar org.sat4j.pb.jar -C $(out_dir) inport -C src constraints rm -r -f $(out_dir) diff --git a/src/inport/ConversionUtils/Task.java b/src/inport/ConversionUtils/Task.java index 803f1fe..72aacf2 100644 --- a/src/inport/ConversionUtils/Task.java +++ b/src/inport/ConversionUtils/Task.java @@ -1,7 +1,6 @@ package inport.ConversionUtils; import inport.*; -import org.jetbrains.annotations.NotNull; import java.io.FileWriter; import java.io.IOException; @@ -56,7 +55,7 @@ public class Task { } @Override - public int compareTo(@NotNull StorageSectionId id) { + public int compareTo(StorageSectionId id) { if (isRealStorage != id.isRealStorage) { return (isRealStorage ? 1 : -1); } @@ -1046,7 +1045,7 @@ public class Task { } @Override - public int compareTo(@NotNull OperationData o) { + public int compareTo(OperationData o) { if (opId != o.opId) { return Integer.compare(opId, o.opId); } diff --git a/src/inport/InPort.java b/src/inport/InPort.java index 6e2f852..70d06c9 100644 --- a/src/inport/InPort.java +++ b/src/inport/InPort.java @@ -12,7 +12,9 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.math.BigInteger; +import java.util.ArrayList; import java.util.Date; +import java.util.Optional; import org.sat4j.core.Vec; import org.sat4j.core.VecInt; @@ -242,21 +244,21 @@ public class InPort { task.getStorages().add(storage1); // Суда - TransportShip ship1 = new TransportShip(4, "Ship 1", 200); + TransportShip ship1 = new TransportShip(4, "Ship 1", 200, cargo0); task.getShips().add(ship1); // Шаблоны операций // Перемещения - MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,1.0,5+task.getTemplates().size()); + MovingTemplate move101 = new MovingTemplate(ship1, berth0, berth1, new ArrayList<>(), 1.0, 5+task.getTemplates().size()); task.getTemplates().add(move101); - MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,1.0,5+task.getTemplates().size()); + MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,new ArrayList<>(),1.0,5+task.getTemplates().size()); task.getTemplates().add(move110); // Погрузки - LoadingTemplate load11 = new LoadingTemplate(ship1,berth1,storage1,100.0,5+task.getTemplates().size()); + LoadingTemplate load11 = new LoadingTemplate(ship1,berth1,storage1, cargo0, Optional.empty(), new ArrayList<>(), false,100.0,5+task.getTemplates().size()); task.getTemplates().add(load11); @@ -300,21 +302,21 @@ public class InPort { task.getStorages().add(storage1); // Суда - TransportShip ship1 = new TransportShip(5, "Ship 1", 200); + TransportShip ship1 = new TransportShip(5, "Ship 1", 200, cargo0); task.getShips().add(ship1); // Шаблоны операций // Перемещения - MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,1.0,6+task.getTemplates().size()); + MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,new ArrayList<>(),1.0,6+task.getTemplates().size()); task.getTemplates().add(move101); - MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,1.0,6+task.getTemplates().size()); + MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,new ArrayList<>(),1.0,6+task.getTemplates().size()); task.getTemplates().add(move110); // Погрузки - LoadingTemplate load11 = new LoadingTemplate(ship1,berth1,storage1,100.0,6+task.getTemplates().size()); + LoadingTemplate load11 = new LoadingTemplate(ship1,berth1,storage1,cargo0, Optional.empty(), new ArrayList<>(), false,100.0,6+task.getTemplates().size()); task.getTemplates().add(load11); @@ -449,9 +451,9 @@ public class InPort { task.getStorages().add(storage1); // Суда - TransportShip ship1 = new TransportShip(5, "Ship 1", 2000); + TransportShip ship1 = new TransportShip(5, "Ship 1", 2000, cargo0); task.getShips().add(ship1); - TransportShip ship2 = new TransportShip(6, "Ship 2", 2000); + TransportShip ship2 = new TransportShip(6, "Ship 2", 2000, cargo0); task.getShips().add(ship2); @@ -459,56 +461,56 @@ public class InPort { // Перемещения //1 - MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,1.0,7+task.getTemplates().size()); + MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move101); //2 - MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,1.0,7+task.getTemplates().size()); + MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move110); //3 - MovingTemplate move102 = new MovingTemplate(ship1,berth0,berth2,1.0,7+task.getTemplates().size()); + MovingTemplate move102 = new MovingTemplate(ship1,berth0,berth2,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move102); //4 - MovingTemplate move120 = new MovingTemplate(ship1,berth2,berth0,1.0,7+task.getTemplates().size()); + MovingTemplate move120 = new MovingTemplate(ship1,berth2,berth0,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move120); //5 - MovingTemplate move112 = new MovingTemplate(ship1,berth1,berth2,1.0,7+task.getTemplates().size()); + MovingTemplate move112 = new MovingTemplate(ship1,berth1,berth2,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move112); //6 - MovingTemplate move121 = new MovingTemplate(ship1,berth2,berth1,1.0,7+task.getTemplates().size()); + MovingTemplate move121 = new MovingTemplate(ship1,berth2,berth1,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move121); //7 - MovingTemplate move201 = new MovingTemplate(ship2,berth0,berth1,1.0,7+task.getTemplates().size()); + MovingTemplate move201 = new MovingTemplate(ship2,berth0,berth1,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move201); //8 - MovingTemplate move210 = new MovingTemplate(ship2,berth1,berth0,1.0,7+task.getTemplates().size()); + MovingTemplate move210 = new MovingTemplate(ship2,berth1,berth0,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move210); //9 - MovingTemplate move202 = new MovingTemplate(ship2,berth0,berth2,1.0,7+task.getTemplates().size()); + MovingTemplate move202 = new MovingTemplate(ship2,berth0,berth2,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move202); //10 - MovingTemplate move220 = new MovingTemplate(ship2,berth2,berth0,1.0,7+task.getTemplates().size()); + MovingTemplate move220 = new MovingTemplate(ship2,berth2,berth0,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move220); //11 - MovingTemplate move212 = new MovingTemplate(ship2,berth1,berth2,1.0,7+task.getTemplates().size()); + MovingTemplate move212 = new MovingTemplate(ship2,berth1,berth2,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move212); //12 - MovingTemplate move221 = new MovingTemplate(ship2,berth2,berth1,1.0,7+task.getTemplates().size()); + MovingTemplate move221 = new MovingTemplate(ship2,berth2,berth1,new ArrayList<>(),1.0,7+task.getTemplates().size()); task.getTemplates().add(move221); // Погрузки //13 - LoadingTemplate load11 = new LoadingTemplate(ship1,berth1,storage1,100.0,7+task.getTemplates().size()); + LoadingTemplate load11 = new LoadingTemplate(ship1,berth1,storage1, cargo0, Optional.empty(), new ArrayList<>(), false,100.0,7+task.getTemplates().size()); task.getTemplates().add(load11); //14 - LoadingTemplate load12 = new LoadingTemplate(ship1,berth2,storage1,50.0,7+task.getTemplates().size()); + LoadingTemplate load12 = new LoadingTemplate(ship1,berth2,storage1, cargo0, Optional.empty(), new ArrayList<>(), false,50.0,7+task.getTemplates().size()); task.getTemplates().add(load12); //15 - LoadingTemplate load21 = new LoadingTemplate(ship2,berth1,storage1,100.0,7+task.getTemplates().size()); + LoadingTemplate load21 = new LoadingTemplate(ship2,berth1,storage1, cargo0, Optional.empty(), new ArrayList<>(), false,100.0,7+task.getTemplates().size()); task.getTemplates().add(load21); //16 - LoadingTemplate load22 = new LoadingTemplate(ship2,berth2,storage1,50.0,7+task.getTemplates().size()); + LoadingTemplate load22 = new LoadingTemplate(ship2,berth2,storage1, cargo0, Optional.empty(), new ArrayList<>(), false,50.0,7+task.getTemplates().size()); task.getTemplates().add(load22); // Начальное состояние @@ -1449,30 +1451,30 @@ public class InPort { task.getTows().add(tow1); // Суда - TransportShip ship1 = new TransportShip(7, "Ship 1", 2000); + TransportShip ship1 = new TransportShip(7, "Ship 1", 2000, cargo0); task.getShips().add(ship1); // Перемещения // 1 - MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,2.0,8+task.getTemplates().size()); move101.getResources().add(tow1); + MovingTemplate move101 = new MovingTemplate(ship1,berth0,berth1,new ArrayList<>(),2.0,8+task.getTemplates().size()); move101.getResources().add(tow1); task.getTemplates().add(move101); // 2 - MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,2.0,8+task.getTemplates().size()); move110.getResources().add(tow1); + MovingTemplate move110 = new MovingTemplate(ship1,berth1,berth0,new ArrayList<>(),2.0,8+task.getTemplates().size()); move110.getResources().add(tow1); task.getTemplates().add(move110); // 3 - MovingTemplate movet20 = new MovingTemplate(tow1,berth2,berth0,2.0,8+task.getTemplates().size()); + MovingTemplate movet20 = new MovingTemplate(tow1,berth2,berth0,new ArrayList<>(),2.0,8+task.getTemplates().size()); task.getTemplates().add(movet20); // 4 - MovingTemplate movet10 = new MovingTemplate(tow1,berth1,berth0,2.0,8+task.getTemplates().size()); + MovingTemplate movet10 = new MovingTemplate(tow1,berth1,berth0,new ArrayList<>(),2.0,8+task.getTemplates().size()); task.getTemplates().add(movet10); // 5 - MovingTemplate movet12 = new MovingTemplate(tow1,berth1,berth2,1.0,8+task.getTemplates().size()); + MovingTemplate movet12 = new MovingTemplate(tow1,berth1,berth2,new ArrayList<>(),1.0,8+task.getTemplates().size()); task.getTemplates().add(movet12); // 6 - MovingTemplate movek21 = new MovingTemplate(floatingCrane,berth2,berth1,2.0,8+task.getTemplates().size()); movek21.getResources().add(tow1); + MovingTemplate movek21 = new MovingTemplate(floatingCrane,berth2,berth1,new ArrayList<>(),2.0,8+task.getTemplates().size()); movek21.getResources().add(tow1); task.getTemplates().add(movek21); // 7 - LoadingTemplate lt = new LoadingTemplate(ship1,berth1,storage1,-20.0,8+task.getTemplates().size()); lt.getResources().add(floatingCrane); + LoadingTemplate lt = new LoadingTemplate(ship1,berth1,storage1, cargo0, Optional.empty(), new ArrayList<>(), false,-20.0,8+task.getTemplates().size()); lt.getResources().add(floatingCrane); task.getTemplates().add(lt); StorageState tini1 = new StorageState(storage1, cargo0, 0.0); diff --git a/src/inport/Storage.java b/src/inport/Storage.java index 6fa97df..fb47f2e 100644 --- a/src/inport/Storage.java +++ b/src/inport/Storage.java @@ -61,7 +61,13 @@ public class Storage { this.id = id; } - public Storage(int id, String name, double volume, ArrayList> storageSections) { + public Storage(int id, String name, double volume, Cargo cargo) { + this.id = id; + this.name = name; + storageSections.add(new Pair<>(cargo, volume)); + } + + public Storage(int id, String name, ArrayList> storageSections) { this.id = id; this.name = name; this.storageSections = storageSections; diff --git a/src/inport/TransportShip.java b/src/inport/TransportShip.java index 2996d4b..010568e 100644 --- a/src/inport/TransportShip.java +++ b/src/inport/TransportShip.java @@ -24,8 +24,13 @@ public class TransportShip extends MovingObject { public void setStorageSections(ArrayList> storageSections) { this.storageSections = storageSections; - } - + } + + public TransportShip(int id, String name, double volume, Cargo cargo) { + super(id, name); + storageSections.add(new Pair<>(cargo, volume)); + } + public TransportShip(int id, String name, ArrayList> storageSections) { super(id, name); this.storageSections = storageSections; -- GitLab