From 0e9f10549be6d4b62cd661d94c4c33581bb381b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=81=D0=B5=D0=BB=D1=91=D0=B2=20=D0=92=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2?= Date: Mon, 1 Apr 2019 06:23:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/inport/Main.java | 6 ++ src/inport/Testing.java | 33 ++++++-- tests/with_typing/Case1.tipp | 72 ++++++++++++++++ tests/with_typing/Case2.tipp | 111 +++++++++++++++++++++++++ tests/with_typing/TaskBK.tipp | 71 ++++++++++++++++ tests/with_typing/TaskT.tipp | 75 +++++++++++++++++ tests/with_typing/TwoTransports.tipp | 64 ++++++++++++++ tests/with_typing/multiTow.TIPP | 93 +++++++++++++++++++++ tests/with_typing/v2.tipp | 89 ++++++++++++++++++++ tests/without_typing/Case2.ipp | 11 ++- tests/without_typing/TwoTransports.ipp | 4 +- 11 files changed, 618 insertions(+), 11 deletions(-) create mode 100644 tests/with_typing/Case1.tipp create mode 100644 tests/with_typing/Case2.tipp create mode 100644 tests/with_typing/TaskBK.tipp create mode 100644 tests/with_typing/TaskT.tipp create mode 100644 tests/with_typing/TwoTransports.tipp create mode 100644 tests/with_typing/multiTow.TIPP create mode 100644 tests/with_typing/v2.tipp diff --git a/src/inport/Main.java b/src/inport/Main.java index 3261788..f66a02f 100644 --- a/src/inport/Main.java +++ b/src/inport/Main.java @@ -117,6 +117,12 @@ public class Main { case "testing" : test_2(); break; + case "testing_2": + test_2_0(); + break; + case "testing_exp": + test_2_exp(); + break; default: System.out.println("Unknown type \"" + type + "\""); } diff --git a/src/inport/Testing.java b/src/inport/Testing.java index 9f545bc..2a0740c 100644 --- a/src/inport/Testing.java +++ b/src/inport/Testing.java @@ -35,17 +35,34 @@ public class Testing { ConversionUtil::resolveMiniZincResults); } + public static String solveTask_2_0(TaskCase task) { + return solveTask( + task, + "conversion_2.0.mzn", + ConversionUtil::portToMiniZinc_2, + ConversionUtil::resolveMiniZincResults, + "temp_data_2"); + } + + public static String solveTask(TaskCase task, + String constraintName, + BiConsumer converterToMinizincFormat, + BiConsumer interpreter) { + return solveTask(task, constraintName, converterToMinizincFormat, interpreter, "temp_data"); + } + /* Возвращает описание ошибки, если ошибки не было, то пустую строку. */ public static String solveTask(TaskCase task, - String constraintName, - BiConsumer converterToMinizincFormat, - BiConsumer interpreter) { - File directory = new File("temp_data"); + String constraintName, + BiConsumer converterToMinizincFormat, + BiConsumer interpreter, + String tempDir) { + File directory = new File(tempDir); if (!directory.exists()) { directory.mkdir(); } - String tempDir = "temp_data/"; + tempDir = tempDir + "/"; String minizincData = tempDir + "minizinc_data.dzn"; String solverResults = tempDir + "solver_results.txt"; String constraints = tempDir + "constraints.mzn"; @@ -141,4 +158,10 @@ public class Testing { public static void test_2() { testGroup("with_typing", Testing::solveTask_2); } + public static void test_2_0() { + testGroup("with_typing", Testing::solveTask_2_0); + } + public static void test_2_exp() { + testGroup("experiments", Testing::solveTask_2); + } } diff --git a/tests/with_typing/Case1.tipp b/tests/with_typing/Case1.tipp new file mode 100644 index 0000000..05c2d4c --- /dev/null +++ b/tests/with_typing/Case1.tipp @@ -0,0 +1,72 @@ +Typified +1 + +Cargoes +313; Груз1; 0.0 + +Berths +314; Рейд +315; Терминал1 +316; Терминал2 + +Storages +317; Хранилище1; 313; 270.0 + +Vessel Types +1001; Тип судна1 +1002; Тип буксира1 + +Bunkers + +Tows +320; Буксир1; 1000000; 1002 + +Loading Equipment Types +1003; Кран + +Loading Equipments +323; Плавучий кран; 1003 + +Transport Ships +321; Судно1; 1000000.0; 1001 + +Templates +8; mov; []; 1002; 314; 316; []; 1.0 +9; mov; []; 1002; 315; 316; []; 3.0 +5; mov; []; 1002; 315; 314; []; 1.0 +7; mov; []; 1002; 316; 314; []; 1.0 +11; mov; []; 1001; 314; 315; [1002]; 2.0 +6; mov; []; 1001; 314; 316; [1002]; 2.0 +10; mov; []; 1003; 316; 315; [1002]; 3.0 +2; loa; []; 1001; 313; 317; 315; [1003]; 20.0; U +4; loa; []; 1001; 313; 317; 316; [1003]; 15.0; U + +Cargo Flows + +Initial Vessel State +321; 314 +323; 316 +320; 315 + +Initial Storage State +313; 317; 0.0 +313; 321; 100.0 + +Final Vessel State + +Final Storage State +313; 321; 0.0 + + +Task Properties +18.0; 0 + + +Solution +13.0 +5; R; 0.0; 1.0 (320 []) +8; R; 1.0; 1.0 (320 []) +10; R; 2.0; 3.0 (323 [320]) +5; R; 5.0; 1.0 (320 []) +11; R; 6.0; 2.0 (321 [320]) +2; R; 8.0; 5.0 (321 [323]) diff --git a/tests/with_typing/Case2.tipp b/tests/with_typing/Case2.tipp new file mode 100644 index 0000000..6f1cc9b --- /dev/null +++ b/tests/with_typing/Case2.tipp @@ -0,0 +1,111 @@ +Typified +1 + +Cargoes +83; Груз1; 0.0 +84; Груз2; 0.0 +85; Груз3; 0.0 + +Berths +86; Рейд +87; Терминал1 +88; Терминал2 + +Storages +89; Хранилище1; 83; 1000.0 +90; Хранилище2; 84; 1000.0 +91; Хранилище3; 85; 1000.0 + +Vessel Types +1001; Тип судна1 +1002; Тип буксира1 + +Bunkers + +Tows +94; Буксир1; 1000000; 1002 +95; Буксир2; 1000000; 1002 + +Loading Equipment Types +1003; Тип крана 1 +1004; Тип крана 1 +1005; Тип крана 1 + +Loading Equipments +99; Плавучий кран 1; 1003 +100; Плавучий кран 2; 1004 +101; Плавучий кран 3; 1005 + +Transport Ships +96; Судно1; 1000000.0; 1001 + +Templates +10; mrn; []; 1001; 88; [1002,1002]; 1.0 +13; mov; []; 1002; 86; 88; []; 1.0 +16; mov; []; 1002; 87; 88; []; 3.0 +15; mov; []; 1002; 87; 86; []; 1.0 +11; mov; []; 1002; 88; 86; []; 1.0 +8; mov; []; 1001; 86; 88; [1002]; 2.0 +2; loa; []; 1001; 83; 89; 88; [1003, 1004]; 20.0; M +4; loa; []; 1001; 84; 90; 88; [1003, 1005]; 10.0; M +5; loa; []; 1001; 84; 90; 88; [1004, 1005]; 10.0; M +7; loa; []; 1001; 85; 91; 88; [1005]; 10.0; M + +Cargo Flows + +Initial Vessel State +96; 86 +99; 88 +100; 88 +101; 88 +94; 87 +95; 88 + +Initial Storage State +83; 89; 0.0 +84; 90; 0.0 +85; 91; 0.0 +83; 96; 60.0 +84; 96; 60.0 +85; 96; 60.0 + +Final Vessel State + +Final Storage State +83; 96; 0.0 +84; 96; 0.0 +85; 96; 0.0 + + +Task Properties +25.0; 0 + + +Solution +16.0 +15; R; 0.0; 1.0 (94 []) +8; R; 1.0; 2.0 (96 [94]) +10; R; 3.0; 1.0 (96 [94, 95]) +11; R; 3.0; 1.0 (95 []) +2; R; 4.0; 2.0 (96 [99, 100]) +7; R; 4.0; 2.0 (96 [101]) +5; R; 6.0; 1.0 (96 [100, 101]) +13; R; 7.0; 1.0 (95 []) +7; R; 7.0; 2.0 (96 [101]) +11; R; 8.0; 1.0 (94 []) +11; R; 8.0; 1.0 (95 []) +13; R; 9.0; 1.0 (95 []) +4; R; 9.0; 2.0 (96 [99, 101]) +11; R; 11.0; 1.0 (95 []) +5; R; 11.0; 1.0 (96 [100, 101]) +13; R; 12.0; 1.0 (94 []) +13; R; 12.0; 1.0 (95 []) +7; R; 12.0; 1.0 (96 [101]) +11; R; 13.0; 1.0 (95 []) +5; R; 13.0; 1.0 (96 [100, 101]) +13; R; 14.0; 1.0 (95 []) +4; R; 14.0; 1.0 (96 [99, 101]) +11; R; 15.0; 1.0 (94 []) +11; R; 15.0; 1.0 (95 []) +2; R; 15.0; 1.0 (96 [99, 100]) +7; R; 15.0; 1.0 (96 [101]) diff --git a/tests/with_typing/TaskBK.tipp b/tests/with_typing/TaskBK.tipp new file mode 100644 index 0000000..4d8ea88 --- /dev/null +++ b/tests/with_typing/TaskBK.tipp @@ -0,0 +1,71 @@ +Typified +1 + +Cargoes +0; LNG; 0.0 + +Berths +1; Raid +2; Pier 1 +3; Pier 2 + +Storages +4; Storage 1; 0; 270.0 + +Vessel Types +1001; Тип судна1 +1002; Тип бункеровщика1 + +Bunkers + +Tows +6; Tow 1; 1000000; 1002 + +Loading Equipment Types +1003; Кран + +Loading Equipments +5; Плавучий кран; 1003 + +Transport Ships +7; Ship 1; 2000.0; 1001 + +Templates +8; mov; []; 1001; 1; 2; [1002]; 2.0 +9; mov; []; 1001; 2; 1; [1002]; 2.0 +10; mov; []; 1002; 3; 1; []; 2.0 +11; mov; []; 1002; 2; 1; []; 2.0 +12; mov; []; 1002; 2; 3; []; 1.0 +13; mov; []; 1003; 3; 2; [1002]; 2.0 +14; loa; []; 1001; 0; 4; 2; [1003]; 20.0; U + +Cargo Flows + +Initial Vessel State +7; 1 +6; 2 +5; 3 + +Initial Storage State +0; 4; 0.0 +0; 7; 100.0 + +Final Vessel State +7; 1 + +Final Storage State +0; 7; 0.0 + + +Task Properties +25.0; 0 + + +Solution +14.0 +11; R; 0.0; 2.0 (6 []) +8; R; 2.0; 2.0 (7 [6]) +12; R; 4.0; 1.0 (6 []) +13; R; 5.0; 2.0 (5 [6]) +14; R; 7.0; 5.0 (7 [5]) +9; R; 12.0; 2.0 (7 [6]) diff --git a/tests/with_typing/TaskT.tipp b/tests/with_typing/TaskT.tipp new file mode 100644 index 0000000..deda93e --- /dev/null +++ b/tests/with_typing/TaskT.tipp @@ -0,0 +1,75 @@ +Typified +1 + +Cargoes +0; LNG; 0.0 + +Berths +1; Raid +2; Pier 1 +3; Pier 2 + +Storages +4; Storage 1; 0; 10000.0 + +Vessel Types +1001; Тип судна1 + +Bunkers + +Tows + +Loading Equipment Types + +Loading Equipments + +Transport Ships +5; Ship 1; 2000.0; 1001 +6; Ship 2; 2000.0; 1001 + +Templates +7; mov; []; 1001; 1; 2; []; 1.0 +8; mov; []; 1001; 2; 1; []; 1.0 +9; mov; []; 1001; 1; 3; []; 1.0 +10; mov; []; 1001; 3; 1; []; 1.0 +11; mov; []; 1001; 2; 3; []; 1.0 +12; mov; []; 1001; 3; 2; []; 1.0 +19; loa; []; 4; 0; 1001; 2; []; 100.0; U +20; loa; []; 4; 0; 1001; 3; []; 50.0; U + +Cargo Flows + +Initial Vessel State +5; 1 +6; 1 + +Initial Storage State +0; 5; 0.0 +0; 6; 0.0 +0; 4; 10000.0 + +Final Vessel State +5; 1 +6; 1 + +Final Storage State +0; 5; 1000.0 +0; 6; 1000.0 + + +Task Properties +24.0; 0 + + +Solution +16.0 +7; R; 0.0; 1.0 (6 []) +9; R; 0.0; 1.0 (5 []) +19; R; 1.0; 7.0 (6 []) +20; R; 1.0; 6.0 (5 []) +12; R; 7.0; 1.0 (5 []) +11; R; 8.0; 1.0 (6 []) +19; R; 8.0; 7.0 (5 []) +20; R; 9.0; 6.0 (6 []) +8; R; 15.0; 1.0 (5 []) +10; R; 15.0; 1.0 (6 []) diff --git a/tests/with_typing/TwoTransports.tipp b/tests/with_typing/TwoTransports.tipp new file mode 100644 index 0000000..d7cdff4 --- /dev/null +++ b/tests/with_typing/TwoTransports.tipp @@ -0,0 +1,64 @@ +Typified +1 + +Cargoes +83; Груз1; 0.0 + +Berths +86; Рейд + +Storages +89; Хранилище1; 83; 1000.0 + +Vessel Types +1001; Тип судна1 + +Bunkers + +Tows + +Loading Equipment Types + +Loading Equipments + +Transport Ships +101; Судно1; 1000000.0; 1001 +102; Судно2; 1000000.0; 1001 + +Templates +1; mrn; []; 1001; 86; []; 1.0 +2; unm; []; 1001; 86; []; 1.0 +3; loa; []; 1001; 83; 89; 86; []; 10.0; M + +Cargo Flows + +Initial Vessel State +101; 86 +102; 86 + +Initial Storage State +83; 89; 100.0 +83; 101; 10.0 +83; 102; 10.0 + +Final Vessel State +101; 86 +102; 86 + +Final Storage State +83; 101; 0.0 +83; 102; 0.0 + + +Task Properties +10.0; 0 + + +Solution +6.0 +1; R; 0.0; 1.0 (101 []) +3; R; 1.0; 1.0 (101 []) +2; R; 2.0; 1.0 (101 []) +1; R; 3.0; 1.0 (102 []) +3; R; 4.0; 1.0 (102 []) +2; R; 5.0; 1.0 (102 []) diff --git a/tests/with_typing/multiTow.TIPP b/tests/with_typing/multiTow.TIPP new file mode 100644 index 0000000..fc9d9f3 --- /dev/null +++ b/tests/with_typing/multiTow.TIPP @@ -0,0 +1,93 @@ +Typified +1 + +Cargoes +13; Груз1; 0.0 + +Berths +10; Рейд +16; Терминал1 + +Storages +18; Хранилище1; 13; 600.0 + +Vessel Types +11; Тип судна1 +12; Тип буксира1 + +Bunkers + +Tows +121; Буксир1; 1000000; 12 +122; Буксир2; 1000000; 12 +123; Буксир3; 1000000; 12 +124; Буксир4; 1000000; 12 + +Loading Equipment Types + +Loading Equipments + +Transport Ships +111; Судно1; 1000000.0; 11 +112; Судно2; 1000000.0; 11 + +Templates +61; mov; []; 11; 10; 16; [12,12]; 1.0 +62; mov; []; 11; 16; 10; [12,12]; 1.0 +63; mov; []; 12; 10; 16; []; 1.0 +64; mov; []; 12; 16; 10; []; 1.0 +65; mrn; []; 11; 16; [12,12,12]; 1.0 +66; unm; []; 11; 16; [12,12,12]; 1.0 +67; loa; []; 11; 13; 18; 16; []; 600.0; M +68; loa; []; 18; 13; 11; 16; []; 600.0; M + +Cargo Flows + +Initial Vessel State +111; 10 +112; 10 +121; 16 +122; 16 +123; 10 +124; 10 + +Initial Storage State +13; 111; 1200.0 +13; 112; 0.0 +13; 18; 0.0 + +Final Vessel State +111; 10 +112; 10 + +Final Storage State +13; 111; 0.0 +13; 112; 1200.0 + + +Task Properties +20.0; 0 + + +Solution +15.0 +61; R; 0.0; 1.0 (111 [123, 124]) +64; R; 0.0; 1.0 (121 []) +64; R; 0.0; 1.0 (122 []) +61; R; 1.0; 1.0 (112 [121, 122]) +65; R; 2.0; 1.0 (111 [121, 122, 124]) +67; R; 3.0; 1.0 (111 []) +66; R; 4.0; 1.0 (111 [121, 123, 124]) +65; R; 5.0; 1.0 (112 [121, 123, 124]) +64; R; 6.0; 1.0 (123 []) +68; R; 6.0; 1.0 (112 []) +66; R; 7.0; 1.0 (112 [121, 122, 124]) +65; R; 8.0; 1.0 (111 [121, 122, 124]) +63; R; 9.0; 1.0 (123 []) +67; R; 9.0; 1.0 (111 []) +66; R; 10.0; 1.0 (111 [121, 122, 123]) +65; R; 11.0; 1.0 (112 [121, 122, 124]) +68; R; 12.0; 1.0 (112 []) +66; R; 13.0; 1.0 (112 [121, 122, 124]) +62; R; 14.0; 1.0 (111 [121, 123]) +62; R; 14.0; 1.0 (112 [122, 124]) diff --git a/tests/with_typing/v2.tipp b/tests/with_typing/v2.tipp new file mode 100644 index 0000000..1b6ff24 --- /dev/null +++ b/tests/with_typing/v2.tipp @@ -0,0 +1,89 @@ +Typified +1 + +Cargoes +22; Груз1; 0.0 + +Berths +17; Рейд +18; Терминал1 +19; Терминал2 + +Storages +20; Хранилище1; 22; 1000.0 +21; Хранилище2; 22; 1000.0 + +Vessel Types +1001; Тип судна1 +1002; Тип буксира1 + +Bunkers + +Tows +27; Буксир1; 1000000; 1002 + +Loading Equipment Types + +Loading Equipments + +Transport Ships +24; Судно1; 1000000.0; 1001 +25; Судно2; 1000000.0; 1001 + +Templates +4010; mov; []; 1001; 19; 18; [1002]; 1.0 +4; mov; []; 1001; 17; 19; []; 5.0 +4006; mov; []; 1001; 17; 19; [1002]; 2.0 +3; mov; []; 1001; 17; 18; []; 5.0 +4005; mov; []; 1001; 17; 18; [1002]; 2.0 +4009; mov; []; 1001; 18; 19; [1002]; 1.0 +15; mov; []; 1002; 18; 17; []; 1.0 +16; mov; []; 1002; 19; 17; []; 1.0 +18; mov; []; 1002; 19; 18; []; 0.1 +14; mov; []; 1002; 17; 19; []; 1.0 +17; mov; []; 1002; 18; 19; []; 0.1 +13; mov; []; 1002; 17; 18; []; 1.0 +3998; loa; []; 20; 22; 1001; 18; []; 200.0; U +3996; loa; []; 1001; 22; 20; 18; []; 200.0; U +3994; loa; []; 21; 22; 1001; 19; []; 10.0; U +3992; loa; []; 1001; 22; 21; 19; []; 10.0; U + +Cargo Flows + +Initial Vessel State +24; 17 +25; 17 +27; 17 + +Initial Storage State +22; 24; 1000.0 +22; 25; 0.0 +22; 20; 200.0 +22; 21; 800.0 + +Final Vessel State + +Final Storage State +22; 24; 0.0 +22; 25; 1000.0 + + +Task Properties +30.0; 0 + + +Solution +12.0 +3; R; 0.0; 5.0 (25 []) +4005; R; 0.0; 2.0 (24 [27]) +3996; R; 2.0; 3.0 (24 []) +4009; R; 5.0; 1.0 (24 [27]) +3998; R; 5.0; 4.0 (25 []) +3992; R; 6.0; 1.0 (24 []) +3994; R; 7.0; 1.0 (24 []) +4010; R; 8.0; 1.0 (24 [27]) +4009; R; 9.0; 1.0 (25 [27]) +3996; R; 9.0; 2.0 (24 []) +4010; R; 10.0; 1.0 (25 [27]) +4009; R; 11.0; 1.0 (24 [27]) +3998; R; 11.0; 1.0 (25 []) diff --git a/tests/without_typing/Case2.ipp b/tests/without_typing/Case2.ipp index c04b382..0de804c 100644 --- a/tests/without_typing/Case2.ipp +++ b/tests/without_typing/Case2.ipp @@ -23,19 +23,22 @@ Transport Ships Templates 10;mrn;[];96;88;[94,95];1.0 + 13;mov;[];94;86;88;[];1.0 16;mov;[];94;87;88;[];3.0 15;mov;[];94;87;86;[];1.0 11;mov;[];94;88;86;[];1.0 + 12;mov;[];95;88;86;[];1.0 17;mov;[];95;87;88;[];3.0 14;mov;[];95;86;88;[];1.0 + 8;mov;[];96;86;88;[94];2.0 9;mov;[];96;86;88;[95];2.0 -2;loa;[];96;83;89;88;[99,100];20.0;U -4;loa;[];96;84;90;88;[99,101];10.0;U -5;loa;[];96;84;90;88;[100,101];10.0;U -7;loa;[];96;85;91;88;[101];10.0;U +2;loa;[];96;83;89;88;[99,100];20.0;M +4;loa;[];96;84;90;88;[99,101];10.0;M +5;loa;[];96;84;90;88;[100,101];10.0;M +7;loa;[];96;85;91;88;[101];10.0;M Cargo Flows Initial Vessel State diff --git a/tests/without_typing/TwoTransports.ipp b/tests/without_typing/TwoTransports.ipp index f486548..a12eb64 100644 --- a/tests/without_typing/TwoTransports.ipp +++ b/tests/without_typing/TwoTransports.ipp @@ -17,11 +17,11 @@ Transport Ships Templates 1;mrn;[]; 101; 86; []; 1.0 2;unm;[]; 101; 86; []; 1.0 -3;loa;[]; 101; 83; 89; 88; []; 10.0; M +3;loa;[]; 101; 83; 89; 86; []; 10.0; M 4;mrn;[]; 102; 86; []; 1.0 5;unm;[]; 102; 86; []; 1.0 -6;loa;[]; 102; 83; 89; 88; []; 10.0; M +6;loa;[]; 102; 83; 89; 86; []; 10.0; M Cargo Flows Initial Vessel State -- GitLab