From 0b19327be7c71ed46238405b51f96c3be17c52c3 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Wed, 12 May 2021 11:16:48 +1000 Subject: [PATCH] Remove tests giving invalid results --- flatten/instances.csv | 25 -- flatten/median-string/median_string_dp.mzn | 81 ------- flatten/median-string/p1_15_20-1.dzn | 6 - flatten/median-string/p2_10_8-0.dzn | 6 - flatten/median-string/p2_10_8-3.dzn | 6 - flatten/median-string/p2_2_20-2.dzn | 6 - flatten/median-string/p2_4_20-0.dzn | 6 - flatten/train/instance.1.dzn | 12 - flatten/train/instance.10.dzn | 12 - flatten/train/instance.11.dzn | 12 - flatten/train/instance.12.dzn | 12 - flatten/train/instance.13.dzn | 12 - flatten/train/instance.14.dzn | 12 - flatten/train/instance.15.dzn | 12 - flatten/train/instance.2.dzn | 12 - flatten/train/instance.3.dzn | 12 - flatten/train/instance.4.dzn | 12 - flatten/train/instance.5.dzn | 12 - flatten/train/instance.6.dzn | 12 - flatten/train/instance.7.dzn | 12 - flatten/train/instance.8.dzn | 12 - flatten/train/instance.9.dzn | 12 - flatten/train/train.mzn | 176 -------------- flatten/zephyrus/12__6__8__3.dzn | 18 -- flatten/zephyrus/12__8__6__3.dzn | 18 -- flatten/zephyrus/14__10__8__3.dzn | 18 -- flatten/zephyrus/14__6__8__3.dzn | 18 -- flatten/zephyrus/14__8__6__3.dzn | 18 -- flatten/zephyrus/zephyrus.mzn | 266 --------------------- 29 files changed, 848 deletions(-) delete mode 100644 flatten/median-string/median_string_dp.mzn delete mode 100644 flatten/median-string/p1_15_20-1.dzn delete mode 100644 flatten/median-string/p2_10_8-0.dzn delete mode 100644 flatten/median-string/p2_10_8-3.dzn delete mode 100644 flatten/median-string/p2_2_20-2.dzn delete mode 100644 flatten/median-string/p2_4_20-0.dzn delete mode 100644 flatten/train/instance.1.dzn delete mode 100644 flatten/train/instance.10.dzn delete mode 100644 flatten/train/instance.11.dzn delete mode 100644 flatten/train/instance.12.dzn delete mode 100644 flatten/train/instance.13.dzn delete mode 100644 flatten/train/instance.14.dzn delete mode 100644 flatten/train/instance.15.dzn delete mode 100644 flatten/train/instance.2.dzn delete mode 100644 flatten/train/instance.3.dzn delete mode 100644 flatten/train/instance.4.dzn delete mode 100644 flatten/train/instance.5.dzn delete mode 100644 flatten/train/instance.6.dzn delete mode 100644 flatten/train/instance.7.dzn delete mode 100644 flatten/train/instance.8.dzn delete mode 100644 flatten/train/instance.9.dzn delete mode 100644 flatten/train/train.mzn delete mode 100644 flatten/zephyrus/12__6__8__3.dzn delete mode 100644 flatten/zephyrus/12__8__6__3.dzn delete mode 100644 flatten/zephyrus/14__10__8__3.dzn delete mode 100644 flatten/zephyrus/14__6__8__3.dzn delete mode 100644 flatten/zephyrus/14__8__6__3.dzn delete mode 100644 flatten/zephyrus/zephyrus.mzn diff --git a/flatten/instances.csv b/flatten/instances.csv index 80ea06d..0334b55 100644 --- a/flatten/instances.csv +++ b/flatten/instances.csv @@ -9,11 +9,6 @@ "stack-cuttingstock","stack-cuttingstock/stack-cutstock-cumu.mzn","stack-cuttingstock/d8.dzn" "stack-cuttingstock","stack-cuttingstock/stack-cutstock-cumu.mzn","stack-cuttingstock/d5.dzn" "stack-cuttingstock","stack-cuttingstock/stack-cutstock-cumu.mzn","stack-cuttingstock/d7.dzn" -"zephyrus","zephyrus/zephyrus.mzn","zephyrus/12__8__6__3.dzn" -"zephyrus","zephyrus/zephyrus.mzn","zephyrus/14__8__6__3.dzn" -"zephyrus","zephyrus/zephyrus.mzn","zephyrus/14__6__8__3.dzn" -"zephyrus","zephyrus/zephyrus.mzn","zephyrus/12__6__8__3.dzn" -"zephyrus","zephyrus/zephyrus.mzn","zephyrus/14__10__8__3.dzn" "depot-placement","depot-placement/depot_placement.mzn","depot-placement/ts225_5.dzn" "depot-placement","depot-placement/depot_placement.mzn","depot-placement/u159_4.dzn" "depot-placement","depot-placement/depot_placement.mzn","depot-placement/att48_5.dzn" @@ -38,21 +33,6 @@ "depot-placement","depot-placement/depot_placement.mzn","depot-placement/ulysses16_5.dzn" "depot-placement","depot-placement/depot_placement.mzn","depot-placement/ts225_6.dzn" "depot-placement","depot-placement/depot_placement.mzn","depot-placement/ulysses22_6.dzn" -"train","train/train.mzn","train/instance.15.dzn" -"train","train/train.mzn","train/instance.2.dzn" -"train","train/train.mzn","train/instance.3.dzn" -"train","train/train.mzn","train/instance.6.dzn" -"train","train/train.mzn","train/instance.12.dzn" -"train","train/train.mzn","train/instance.5.dzn" -"train","train/train.mzn","train/instance.1.dzn" -"train","train/train.mzn","train/instance.13.dzn" -"train","train/train.mzn","train/instance.4.dzn" -"train","train/train.mzn","train/instance.9.dzn" -"train","train/train.mzn","train/instance.14.dzn" -"train","train/train.mzn","train/instance.8.dzn" -"train","train/train.mzn","train/instance.7.dzn" -"train","train/train.mzn","train/instance.11.dzn" -"train","train/train.mzn","train/instance.10.dzn" "triangular","triangular/triangular.mzn","triangular/n10.dzn" "triangular","triangular/triangular.mzn","triangular/n23.dzn" "triangular","triangular/triangular.mzn","triangular/n37.dzn" @@ -152,11 +132,6 @@ "kidney-exchange","kidney-exchange/ccmcp.mzn","kidney-exchange/3_20_0.30_5.dzn" "kidney-exchange","kidney-exchange/ccmcp.mzn","kidney-exchange/3_20_0.25_2.dzn" "kidney-exchange","kidney-exchange/ccmcp.mzn","kidney-exchange/3_25_0.20_3.dzn" -"median-string","median-string/median_string_dp.mzn","median-string/p2_2_20-2.dzn" -"median-string","median-string/median_string_dp.mzn","median-string/p1_15_20-1.dzn" -"median-string","median-string/median_string_dp.mzn","median-string/p2_10_8-3.dzn" -"median-string","median-string/median_string_dp.mzn","median-string/p2_10_8-0.dzn" -"median-string","median-string/median_string_dp.mzn","median-string/p2_4_20-0.dzn" "road-cons","road-cons/road_naive.mzn","road-cons/road_33.dzn" "road-cons","road-cons/road_naive.mzn","road-cons/road_26.dzn" "road-cons","road-cons/road_naive.mzn","road-cons/road_25.dzn" diff --git a/flatten/median-string/median_string_dp.mzn b/flatten/median-string/median_string_dp.mzn deleted file mode 100644 index 9475f0f..0000000 --- a/flatten/median-string/median_string_dp.mzn +++ /dev/null @@ -1,81 +0,0 @@ -%------------------------------------------------------------------------------ -% Parameters - -int: num_strings; -int: max_length_strings; -int: max_char; - -int: max_length_median; - -array [1..num_strings, 1..max_length_strings] of int: strings; -array [1..num_strings] of int: str_length; - - -%------------------------------------------------------------------------------ -% Variables - -array [1..max_length_strings] of var 0..max_char: median; -array [1..num_strings] of var 0..2*max_length_strings: distances; - -int: obj_ub = num_strings * 2 * max_length_strings; -var 0..obj_ub: objective; - -%------------------------------------------------------------------------------ -% Predicates - -predicate lcs_global(array[int] of var int: S1, array[int] of var int: S2, var int: ED) = - - let { int: l1 = min(index_set(S1)) - 1; - int: l2 = min(index_set(S2)) - 1; - int: u1 = max(index_set(S1)); - int: u2 = max(index_set(S2)); - array[l1..u1,l2..u2] of var 0..u1+u2: T; } in - T[l1,l2] = 0 /\ - T[u1,u2] = ED /\ - forall(i in l1+1..u1, j in l2+1..u2) - (T[i,j] >= 0 /\ T[i,j] <= i+j) /\ - forall(j in l2+1..u2)(T[l1,j] = j-l2) /\ - forall(i in l1+1..u1)(T[i,l2] = i-l1) /\ - forall(i in l1+1..u1, j in l2+1..u2) - (T[i,j] = if S1[i] = S2[j] then - T[i-1,j-1] - else - if S1[i] = 0 then - T[i-1,j] - else - if S2[j] = 0 then - T[i,j-1] - else - min([T[i-1,j]+1,T[i,j-1]+1]) - endif - endif - endif - ); - -%------------------------------------------------------------------------------ -% Constraints - -constraint forall(i in 1..num_strings)( - lcs_global([strings[i,j] | j in 1..max_length_strings], median, distances[i]) -); - -constraint forall(i in max_length_median+1..max_length_strings)( - median[i] = 0 -); - -constraint objective = sum(i in 1..num_strings)(distances[i]); - -%------------------------------------------------------------------------------ -% Solve item - -solve - :: int_search(median, input_order, indomain_min, complete) - minimize objective; - -%------------------------------------------------------------------------------ -% Output - -output [ - "median = \(median);\n", - "objective = \(objective);\n" -]; diff --git a/flatten/median-string/p1_15_20-1.dzn b/flatten/median-string/p1_15_20-1.dzn deleted file mode 100644 index cd71845..0000000 --- a/flatten/median-string/p1_15_20-1.dzn +++ /dev/null @@ -1,6 +0,0 @@ -num_strings=15; -max_length_strings=20; -max_length_median=20; -max_char=4; -strings=[|2,1,2,1,1,1,2,1,2,2,1,1,1,2,1,1,2,2,1,1|2,1,1,1,1,2,1,1,1,2,1,1,2,1,1,2,1,1,2,1|1,1,1,3,1,1,1,1,1,2,1,2,2,2,2,1,1,1,1,1|2,1,2,1,2,1,1,1,2,2,1,2,3,1,1,2,1,1,1,1|1,1,1,1,1,1,1,2,1,1,2,2,1,2,1,1,1,3,2,1|1,1,2,1,1,1,1,1,1,2,1,2,1,2,1,1,1,1,1,1|1,1,1,2,2,1,1,2,1,2,1,1,1,2,1,2,1,1,1,2|2,1,2,1,1,1,2,1,1,1,2,1,1,1,2,1,2,1,1,1|2,1,1,1,1,2,1,1,2,1,1,1,1,1,1,2,2,2,1,1|2,1,2,2,2,1,1,1,1,1,1,1,1,1,1,2,3,1,2,1|1,3,1,2,1,1,3,1,1,1,1,2,1,2,1,1,1,2,1,2|1,1,2,1,3,1,1,1,1,1,1,1,1,1,2,1,2,1,1,1|1,1,1,1,1,1,2,1,1,2,1,1,2,1,1,1,2,2,1,3|1,2,1,2,1,1,2,2,3,1,2,1,1,2,1,1,1,1,2,2|2,1,1,2,2,2,1,2,2,1,1,1,2,2,1,1,1,1,2,1|]; -str_length=[20,20,20,20,20,20,20,20,20,20,20,20,20,20,20]; diff --git a/flatten/median-string/p2_10_8-0.dzn b/flatten/median-string/p2_10_8-0.dzn deleted file mode 100644 index 69977fd..0000000 --- a/flatten/median-string/p2_10_8-0.dzn +++ /dev/null @@ -1,6 +0,0 @@ -num_strings=10; -max_length_strings=8; -max_length_median=8; -max_char=4; -strings=[|4,3,4,2,0,0,0,0|2,1,2,4,1,4,0,0|4,0,0,0,0,0,0,0|1,4,3,2,2,3,2,0|3,3,2,3,1,2,0,0|3,0,0,0,0,0,0,0|1,4,3,2,0,0,0,0|1,3,3,3,4,2,3,0|2,1,2,0,0,0,0,0|1,2,3,4,3,0,0,0|]; -str_length=[4,6,1,7,6,1,4,7,3,5]; diff --git a/flatten/median-string/p2_10_8-3.dzn b/flatten/median-string/p2_10_8-3.dzn deleted file mode 100644 index 4640470..0000000 --- a/flatten/median-string/p2_10_8-3.dzn +++ /dev/null @@ -1,6 +0,0 @@ -num_strings=10; -max_length_strings=8; -max_length_median=8; -max_char=4; -strings=[|3,1,2,3,4,1,1,0|1,4,1,4,1,2,0,0|1,3,1,0,0,0,0,0|3,0,0,0,0,0,0,0|4,3,0,0,0,0,0,0|1,4,4,2,3,0,0,0|4,3,2,2,1,3,1,1|2,0,0,0,0,0,0,0|3,3,2,3,4,3,0,0|2,3,4,1,1,2,2,0|]; -str_length=[7,6,3,1,2,5,8,1,6,7]; diff --git a/flatten/median-string/p2_2_20-2.dzn b/flatten/median-string/p2_2_20-2.dzn deleted file mode 100644 index 78f3a6c..0000000 --- a/flatten/median-string/p2_2_20-2.dzn +++ /dev/null @@ -1,6 +0,0 @@ -num_strings=2; -max_length_strings=20; -max_length_median=20; -max_char=4; -strings=[|4,4,4,1,4,3,1,3,4,1,0,0,0,0,0,0,0,0,0,0|2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|]; -str_length=[10,2]; diff --git a/flatten/median-string/p2_4_20-0.dzn b/flatten/median-string/p2_4_20-0.dzn deleted file mode 100644 index f58aef7..0000000 --- a/flatten/median-string/p2_4_20-0.dzn +++ /dev/null @@ -1,6 +0,0 @@ -num_strings=4; -max_length_strings=20; -max_length_median=20; -max_char=4; -strings=[|4,4,3,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|4,4,4,4,4,3,4,4,2,0,0,0,0,0,0,0,0,0,0,0|2,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|]; -str_length=[5,3,9,3]; diff --git a/flatten/train/instance.1.dzn b/flatten/train/instance.1.dzn deleted file mode 100644 index 55e6510..0000000 --- a/flatten/train/instance.1.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 3; -m = 3; -maxTime = 1140; -delayTime = 5; -delayTrain = 2; -delayDuration = 5; -distance = [5,5]; -passengerStart = [0,0,0]; -passengerFlow = [0,10,0]; -scheduledArrival = [|0,5,13, |0,15,23, |0,25,33|]; -scheduledDeparture = [|0,8,16, |10,18,26, |20,28,36|]; -capacity = 500; diff --git a/flatten/train/instance.10.dzn b/flatten/train/instance.10.dzn deleted file mode 100644 index 57e4bf9..0000000 --- a/flatten/train/instance.10.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 15; -delayTrain = 2; -delayDuration = 20; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.11.dzn b/flatten/train/instance.11.dzn deleted file mode 100644 index 60cae1b..0000000 --- a/flatten/train/instance.11.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 38; -delayTrain = 2; -delayDuration = 5; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.12.dzn b/flatten/train/instance.12.dzn deleted file mode 100644 index 3beecbd..0000000 --- a/flatten/train/instance.12.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 25; -delayTrain = 2; -delayDuration = 5; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.13.dzn b/flatten/train/instance.13.dzn deleted file mode 100644 index bb5ae27..0000000 --- a/flatten/train/instance.13.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 25; -delayTrain = 2; -delayDuration = 10; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.14.dzn b/flatten/train/instance.14.dzn deleted file mode 100644 index 1b991e4..0000000 --- a/flatten/train/instance.14.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 25; -delayTrain = 2; -delayDuration = 15; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.15.dzn b/flatten/train/instance.15.dzn deleted file mode 100644 index da5f462..0000000 --- a/flatten/train/instance.15.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 25; -delayTrain = 2; -delayDuration = 20; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.2.dzn b/flatten/train/instance.2.dzn deleted file mode 100644 index 08a6fa8..0000000 --- a/flatten/train/instance.2.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 5; -delayTrain = 2; -delayDuration = 5; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.3.dzn b/flatten/train/instance.3.dzn deleted file mode 100644 index 5c488cf..0000000 --- a/flatten/train/instance.3.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 5; -delayTrain = 2; -delayDuration = 10; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.4.dzn b/flatten/train/instance.4.dzn deleted file mode 100644 index f57268c..0000000 --- a/flatten/train/instance.4.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 5; -delayTrain = 2; -delayDuration = 15; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.5.dzn b/flatten/train/instance.5.dzn deleted file mode 100644 index efc8d67..0000000 --- a/flatten/train/instance.5.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 5; -delayTrain = 2; -delayDuration = 20; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.6.dzn b/flatten/train/instance.6.dzn deleted file mode 100644 index 8586804..0000000 --- a/flatten/train/instance.6.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 4; -m = 4; -maxTime = 1140; -delayTime = 15; -delayTrain = 2; -delayDuration = 5; -distance = [5,5,5]; -passengerStart = [0,0,6,0]; -passengerFlow = [0,10,10,0]; -scheduledArrival = [|0,5,13,21, |0,15,23,31, |0,25,33,41, |0,35,43,51|]; -scheduledDeparture = [|0,8,16,24, |10,18,26,34, |20,28,36,44, |30,38,46,54|]; -capacity = 500; diff --git a/flatten/train/instance.7.dzn b/flatten/train/instance.7.dzn deleted file mode 100644 index 3280a70..0000000 --- a/flatten/train/instance.7.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 15; -delayTrain = 2; -delayDuration = 5; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.8.dzn b/flatten/train/instance.8.dzn deleted file mode 100644 index 7671466..0000000 --- a/flatten/train/instance.8.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 15; -delayTrain = 2; -delayDuration = 10; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/instance.9.dzn b/flatten/train/instance.9.dzn deleted file mode 100644 index d1379e5..0000000 --- a/flatten/train/instance.9.dzn +++ /dev/null @@ -1,12 +0,0 @@ -n = 5; -m = 5; -maxTime = 1140; -delayTime = 15; -delayTrain = 2; -delayDuration = 15; -distance = [5,5,5,5]; -passengerStart = [0,0,6,14,0]; -passengerFlow = [0,10,10,10,0]; -scheduledArrival = [|0,5,13,21,29, |0,15,23,31,39, |0,25,33,41,49, |0,35,43,51,59, |0,45,53,61,69|]; -scheduledDeparture = [|0,8,16,24,32, |10,18,26,34,42, |20,28,36,44,52, |30,38,46,54,62, |40,48,56,64,72|]; -capacity = 500; diff --git a/flatten/train/train.mzn b/flatten/train/train.mzn deleted file mode 100644 index 3c23893..0000000 --- a/flatten/train/train.mzn +++ /dev/null @@ -1,176 +0,0 @@ -%----------------------------------------------------------------------------% -%----------------------------------------------------------------------------% -% -% We have n trains moving along a single track with m stations. There is a -% non-zero constant flow of passengers arriving at all but the first and last -% station who wish to travel to the final station. Trains are originally -% scheduled so that they collect the passengers and drop them at the final -% station. To this original schedule a disruption is introduced whereby a train -% is delayed. Each of the trains (at the time of the delay) has knowledge of the -% duration of the delay. The objective is to reschedule the trains to minimize -% the average travel time of the passengers. Trains are not able to overtake -% preceding trains, however they do have the option to -% skip a station and wait longer at a station to collect more passengers. - -%----------------------------------------------------------------------------% -%----------------------------------------------------------------------------% - -%include "globals.mzn"; - -int : n; -int : m; - -int : maxTime; - -0..maxTime : delayTime; -1..n : delayTrain; -0..maxTime : delayDuration; - -array [1..m-1] of 0..maxTime : distance; - -array [1..n, 1..m] of 0..maxTime : scheduledArrival; -array [1..n, 1..m] of 0..maxTime : scheduledDeparture; - -array [1..m] of 0..maxTime : passengerStart; -array [1..m] of 0..maxTime : passengerStop = [scheduledDeparture[n,j] | j in 1..m]; -array [1..m] of int : passengerFlow; - -array [1..n, 1..m] of var 0..maxTime : departure; -array [1..n, 1..m] of var 0..maxTime : arrival; - -array [1..n] of var 0..maxTime : finalArrival = [ arrival[i,m] | i in 1..n ]; - -array [1..n, 1..m] of var 0..maxTime : sigmaLower; -array [1..n, 1..m] of var 0..maxTime : sigmaUpper; - -int : capacity; - -array [1..n, 1..m] of var 0..capacity : collect; -array [1..n, 1..m] of var 0..capacity : load; - -% All trains "arrive" at the first station at time 0. -constraint forall (i in 1..n) - (arrival[i,1] = 0); -% ... and "depart" from the last station as soon as they arrive there. -constraint forall (i in 1..n) - (departure[i,m] = arrival[i,m]); - -% Before the delay, everything runs to schedule. -constraint forall (i in 1..n, j in 1..m-1) - (if scheduledDeparture[i,j] <= delayTime - then departure[i,j] = scheduledDeparture[i,j] - else true - endif); - -% If the train is in motion, then the arrival of the -% delayed train is at least the departure time at the previous station -% plus the ordinary travel time plus the duration of the delay. -int : destinationWhenDelayed = min([j | j in 1..m where scheduledDeparture[delayTrain,j] > delayTime]); -constraint if destinationWhenDelayed > 1 - then if delayTime < scheduledDeparture[delayTrain,destinationWhenDelayed-1] + distance[destinationWhenDelayed-1] - then arrival[delayTrain,destinationWhenDelayed] >= - departure[delayTrain,destinationWhenDelayed-1] + delayDuration + distance[destinationWhenDelayed-1] - else true - endif - else true - endif; -% The train's next departure is at least the delay time plus the delay -% duration. -constraint departure[delayTrain, destinationWhenDelayed] >= delayTime + delayDuration; - -% Trains depart after they arrive. -constraint forall (i in 1..n, j in 1..m) - (departure[i,j] >= arrival[i,j]); - -% Trains never leave earlier than scheduled. -constraint forall (i in 1..n, j in 1..m-1) - (departure[i,j] >= scheduledDeparture[i,j]); - -% There is a minimum travel time between stations. -constraint forall (i in 1..n, j in 1..m-1) - (arrival[i,j+1] >= departure[i,j] + distance[j]); - -% At station 1, trains leave in order. -constraint forall (i in 1..n-1) - (departure[i,1] < departure[i+1,1]); -% At most one train dwelling at a station at a given time. -constraint forall (i in 1..n-1, j in 2..m-1) - (departure[i,j] <= arrival[i+1,j]-2); - -% The sigma values partition time at each station. -constraint forall (i in 1..n, j in 1..m) - (sigmaLower[i,j] <= sigmaUpper[i,j]); - -% For the first and last trains, the sigma values are equal to the -% extreme times of passenger arrivals. -constraint forall (j in 2..m-1) - ((sigmaLower[1,j] = passengerStart[j]) - /\ (sigmaUpper[n,j] = scheduledDeparture[n,j])); -% The sigma values join together. -constraint forall (i in 1..n-1, j in 1..m) - (sigmaUpper[i,j] = sigmaLower[i+1,j]); - -% You can't pick up people after you leave. -constraint forall (i in 1..n-1, j in 1..m-1) - (sigmaUpper[i,j] <= departure[i,j]); -constraint forall (j in 1..m-1) - (sigmaUpper[n,j] <= departure[n,j]); - -% Defines collect and load variables. -constraint forall (i in 1..n, j in 1..m) - (collect[i,j] = (sigmaUpper[i,j]-sigmaLower[i,j])*passengerFlow[j]); - -constraint forall (i in 1..n) (load[i,1] = collect[i,1]); -constraint forall (i in 1..n, j in 2..m) - (load[i,j] = load[i,j-1] + collect[i,j]); - -% If a train picks anyone up, then it must pick -% everyone up (until it gets full). -constraint forall (i in 1..n, j in 1..m-1) - (sigmaUpper[i,j] > sigmaLower[i,j] -> - ((sigmaUpper[i,j] = departure[i,j]) \/ - (sigmaUpper[i,j] = scheduledDeparture[n,j]) \/ - (load[i,j] + bool2int(sigmaUpper[i,j] < scheduledDeparture[n,j])*passengerFlow[j] > capacity))); - -% Boarding time. -constraint forall (i in 1..n, j in 2..m) - (((capacity-load[i,j-1] < 100) -> (collect[i,j] <= dwell[i,j]*20)) /\ - ((capacity-load[i,j-1] >= 100) -> (collect[i,j] <= dwell[i,j]*50))); -% (Redundant for j>=2 (but necessary for j=1)) -constraint forall (i in 1..n, j in 1..m) - (collect[i,j] <= (departure[i,j]-arrival[i,j])*50); - -array [1..n, 1..m] of var 0..maxTime : dwell; -constraint forall (i in 1..n, j in 1..m) (dwell[i,j] = departure[i,j] - arrival[i,j]); - -int: objective_min = lb(sum(i in 1..n)(load[i,m]*arrival[i,m])); -int: objective_max = ub(sum(i in 1..n)(load[i,m]*arrival[i,m])); -var objective_min..objective_max: objective = sum(i in 1..n)(load[i,m]*arrival[i,m]); - -solve - :: seq_search([ - int_search( - [arrival[i,m-j+1] | j in 1..m, i in 1..n] ++ - [departure[i,m-j+1] | j in 1..m, i in 1..n] ++ - [sigmaUpper[i,m-j+1] | j in 1..m, i in 1..n] ++ - [sigmaLower[i,m-j+1] | j in 1..m, i in 1..n], - input_order, indomain_min, complete - ), - int_search( - array1d(1..n*m, collect) ++ array1d(1..n*m, load) ++ array1d(1..n*m, dwell), - first_fail, indomain_min, complete - ) - ]) - minimize objective; - -output [ - "arrival = array2d(1..", show(n), ", 1..", show(m), ", ", show(arrival), ");\n", - "departure = array2d(1..", show(n), ", 1..", show(m), ", ", show(departure), ");\n", - "sigmaLower = array2d(1..", show(n), ", 1..", show(m), ", ", show(sigmaLower), ");\n", - "sigmaUpper = array2d(1..", show(n), ", 1..", show(m), ", ", show(sigmaUpper), ");\n", - "collect = array2d(1..", show(n), ", 1..", show(m), ", ", show(collect), ");\n", - "load = array2d(1..", show(n), ", 1..", show(m), ", ", show(load), ");\n", - "dwell = array2d(1..", show(n), ", 1..", show(m), ", ", show(dwell), ");\n", - "constraint objective = ", show(objective), ";\n" -]; - diff --git a/flatten/zephyrus/12__6__8__3.dzn b/flatten/zephyrus/12__6__8__3.dzn deleted file mode 100644 index 0804e49..0000000 --- a/flatten/zephyrus/12__6__8__3.dzn +++ /dev/null @@ -1,18 +0,0 @@ -comps = 1..4; -ports = 1..4; -multi_provide_ports = 1..5; -locations = 1..48; -resources = 1..1; -requirement_port_nums = [| -0,8,0,0|0,17,0,0|6,0,0,0|0,0,0,0|]; -provide_port_nums = [| --1,0,0,0,0|0,-1,-1,0,0|0,0,0,-1,0|0,0,0,0,3|]; -conflicts = [| -false,false,false,false|false,false,true,false|false,false,false,false|false,false,false,false|]; -multi_provides = [| -false,false,false,true|false,false,false,true|false,false,true,false|false,true,false,false|true,false,false,false|]; -costs = [260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520]; -resource_provisions = [| -8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|]; -resource_consumptions = [| -512|64|512|512|]; diff --git a/flatten/zephyrus/12__8__6__3.dzn b/flatten/zephyrus/12__8__6__3.dzn deleted file mode 100644 index 8f1bcde..0000000 --- a/flatten/zephyrus/12__8__6__3.dzn +++ /dev/null @@ -1,18 +0,0 @@ -comps = 1..4; -ports = 1..4; -multi_provide_ports = 1..5; -locations = 1..48; -resources = 1..1; -requirement_port_nums = [| -0,6,0,0|0,13,0,0|8,0,0,0|0,0,0,0|]; -provide_port_nums = [| --1,0,0,0,0|0,-1,-1,0,0|0,0,0,-1,0|0,0,0,0,3|]; -conflicts = [| -false,false,false,false|false,false,true,false|false,false,false,false|false,false,false,false|]; -multi_provides = [| -false,false,false,true|false,false,false,true|false,false,true,false|false,true,false,false|true,false,false,false|]; -costs = [260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520]; -resource_provisions = [| -8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|]; -resource_consumptions = [| -512|64|512|512|]; diff --git a/flatten/zephyrus/14__10__8__3.dzn b/flatten/zephyrus/14__10__8__3.dzn deleted file mode 100644 index 619bb69..0000000 --- a/flatten/zephyrus/14__10__8__3.dzn +++ /dev/null @@ -1,18 +0,0 @@ -comps = 1..4; -ports = 1..4; -multi_provide_ports = 1..5; -locations = 1..56; -resources = 1..1; -requirement_port_nums = [| -0,8,0,0|0,17,0,0|10,0,0,0|0,0,0,0|]; -provide_port_nums = [| --1,0,0,0,0|0,-1,-1,0,0|0,0,0,-1,0|0,0,0,0,3|]; -conflicts = [| -false,false,false,false|false,false,true,false|false,false,false,false|false,false,false,false|]; -multi_provides = [| -false,false,false,true|false,false,false,true|false,false,true,false|false,true,false,false|true,false,false,false|]; -costs = [260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520]; -resource_provisions = [| -8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|]; -resource_consumptions = [| -512|64|512|512|]; diff --git a/flatten/zephyrus/14__6__8__3.dzn b/flatten/zephyrus/14__6__8__3.dzn deleted file mode 100644 index ee6dec4..0000000 --- a/flatten/zephyrus/14__6__8__3.dzn +++ /dev/null @@ -1,18 +0,0 @@ -comps = 1..4; -ports = 1..4; -multi_provide_ports = 1..5; -locations = 1..56; -resources = 1..1; -requirement_port_nums = [| -0,8,0,0|0,17,0,0|6,0,0,0|0,0,0,0|]; -provide_port_nums = [| --1,0,0,0,0|0,-1,-1,0,0|0,0,0,-1,0|0,0,0,0,3|]; -conflicts = [| -false,false,false,false|false,false,true,false|false,false,false,false|false,false,false,false|]; -multi_provides = [| -false,false,false,true|false,false,false,true|false,false,true,false|false,true,false,false|true,false,false,false|]; -costs = [260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520]; -resource_provisions = [| -8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|]; -resource_consumptions = [| -512|64|512|512|]; diff --git a/flatten/zephyrus/14__8__6__3.dzn b/flatten/zephyrus/14__8__6__3.dzn deleted file mode 100644 index 278a4c1..0000000 --- a/flatten/zephyrus/14__8__6__3.dzn +++ /dev/null @@ -1,18 +0,0 @@ -comps = 1..4; -ports = 1..4; -multi_provide_ports = 1..5; -locations = 1..56; -resources = 1..1; -requirement_port_nums = [| -0,6,0,0|0,13,0,0|8,0,0,0|0,0,0,0|]; -provide_port_nums = [| --1,0,0,0,0|0,-1,-1,0,0|0,0,0,-1,0|0,0,0,0,3|]; -conflicts = [| -false,false,false,false|false,false,true,false|false,false,false,false|false,false,false,false|]; -multi_provides = [| -false,false,false,true|false,false,false,true|false,false,true,false|false,true,false,false|true,false,false,false|]; -costs = [260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520]; -resource_provisions = [| -8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|8052|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|4026|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|1825|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|16104|]; -resource_consumptions = [| -512|64|512|512|]; diff --git a/flatten/zephyrus/zephyrus.mzn b/flatten/zephyrus/zephyrus.mzn deleted file mode 100644 index 1b6bd85..0000000 --- a/flatten/zephyrus/zephyrus.mzn +++ /dev/null @@ -1,266 +0,0 @@ -% Copyright (c) 2016, Jacopo Mauro. All rights reserved. -% This file is licensed under the terms of the ISC License. - - -% Please note that you will need to set the MiniZinc standard library -% environment variable $MZN_STDLIB_PATH to share/minizinc to include -% the MiniSearch builtins - -include "lex_greatereq.mzn"; -include "lex_less.mzn"; - -int: MAX_INT = 4096; -%%%%%%%%%%%%%%%% -% Input parameters -%%%%%%%%%%%%%%%% - -% components -set of int: comps; -% ports -set of int: ports; -% multiple provide port -set of int: multi_provide_ports; - -% locations -set of int: locations; -% resources -set of int: resources; - -% map of components with their requirements number -array[ comps, ports] of int: requirement_port_nums; -% map of components with their provided multi-ports -% -1 means infinite multi-port provider -array[ comps, multi_provide_ports] of int: provide_port_nums; -% map of components with their conflicts -array[ comps, ports] of bool: conflicts; -% map of multi-ports with their ports -array[ multi_provide_ports, ports] of bool: multi_provides; - -% map of location with their costs -array[ locations ] of int: costs; -% map of locations with the resouces they provide -array[ locations, resources ] of int: resource_provisions; -% map of components with the resources they consume -array[ comps, resources ] of int: resource_consumptions; - -%%%%%%%%%%%%%%%% -% variables -%%%%%%%%%%%%%%%% -% bindings number -array[ multi_provide_ports, ports, comps, comps] of var 0..MAX_INT: bindings; -% components number -array[ comps ] of var 0..MAX_INT: comps_num; -% location to number of component map -array[ locations, comps] of var 0..MAX_INT: comp_locations; - -% total number of components -var 0..MAX_INT: sum_comp; - -%%%%%%%%%%%%%%%% -% constraints (no location) -%%%%%%%%%%%%%%%% - -% bind the total number of components -constraint sum_comp = sum( i in comps)(comps_num[i]); - -% bindings 0 if the multiprovide does not provide port -constraint forall(mport in multi_provide_ports, port in ports) ( - if multi_provides[mport,port] - then true - else forall(i in comps, j in comps) ( bindings[mport,port,i,j] = 0) - endif -); - -% provides must be greater or equal to bindings & infinite provide port constraints -constraint forall(mport in multi_provide_ports, pcomp in comps) ( - if provide_port_nums[pcomp,mport]=0 - then forall(port in ports, rcomp in comps) ( - bindings[mport,port,pcomp,rcomp] = 0 - ) - else - if (provide_port_nums[pcomp,mport] = -1) - then forall(port in ports, rcomp in comps) ( - (comps_num[pcomp] = 0) -> (bindings[mport,port,pcomp,rcomp]=0)) - else sum( port in ports, rcomp in comps)( - bindings[mport,port,pcomp,rcomp] ) <= comps_num[pcomp] * provide_port_nums[pcomp,mport] - endif - endif -); - -% requires must be equal to bindings -% note: here is possible to require also smaller than or equal -constraint forall(port in ports, rcomp in comps) ( - sum( mport in multi_provide_ports, pcomp in comps)( - bindings[mport,port,pcomp,rcomp] ) = comps_num[rcomp] * requirement_port_nums[rcomp,port] -); - - -% conflict constraints if component provide same port -constraint forall(port in ports, pcomp in comps) ( - if (conflicts[pcomp,port] /\ exists(mport in multi_provide_ports) ( - (multi_provides[mport,port]) /\ provide_port_nums[pcomp,mport] != 0)) - then comps_num[pcomp] <= 1 - else true - endif -); - -% conflict constraints -constraint forall(port in ports, pcomp in comps, rcomp in comps) ( - if (conflicts[rcomp,port] /\ exists(mport in multi_provide_ports) ( - (multi_provides[mport,port]) /\ provide_port_nums[pcomp,mport] != 0)) - then comps_num[pcomp] > 0 -> comps_num[rcomp] = 0 - else true - endif -); - -% unicity constraint -% note that we require that a component does not -% require more than one port provided by a -% multiple provide port -constraint forall(mport in multi_provide_ports, pcomp in comps, rcomp in comps) ( - let - { int: max_req = sum(port in ports) ( - if multi_provides[mport,port] - then requirement_port_nums[rcomp,port] - else 0 - endif - ) - } in - if pcomp = rcomp - then - ( comps_num[pcomp] >= max_req -> - sum(port in ports)(bindings[mport,port,pcomp,rcomp]) - <= max_req * (comps_num[rcomp] - 1)) - /\ - ( comps_num[pcomp] < max_req -> - forall (i in 1..max_req)( comps_num[pcomp] = i -> - sum(port in ports)(bindings[mport,port,pcomp,rcomp]) <= i * (i-1) )) - else - ( comps_num[pcomp] >= max_req -> - sum(port in ports)(bindings[mport,port,pcomp,rcomp]) - <= max_req * comps_num[rcomp] ) - /\ - ( comps_num[pcomp] < max_req -> - forall (i in 0..max_req)( comps_num[pcomp] = i -> - sum(port in ports)(bindings[mport,port,pcomp,rcomp]) <= i * comps_num[rcomp] ) ) - endif -); - -%%%%%%%%%%%%%%%% -% constraints for deciding locations -%%%%%%%%%%%%%%%% - -% map location used or not used -array[ locations ] of var 0..1: used_locations; -constraint forall( l in locations)( - sum(c in comps)(comp_locations[l,c]) = 0 <-> used_locations[l] = 0 -); - -constraint forall( c in comps) ( - sum( l in locations) ( comp_locations[l,c]) = comps_num[c] -); - - -constraint forall( res in resources, loc in locations) ( - sum( comp in comps)( comp_locations[loc,comp] * resource_consumptions[comp,res] ) - <= resource_provisions[loc,res] -); - -% the number of locations can not be greater than the number of components -% i.e, one component per location in the worst case -constraint sum(i in locations) (used_locations[i]) <= sum_comp; - -%------------------------------------------------------------------------------% -% symmetry constraints (wrap in a unique predicate following minizinc specs - - -constraint symmetry_breaking_constraint( - %if location are equal then first location has more comps than the second - %in lexicographically order (based on the cost) - forall( l1 in locations, l2 in locations)( - if l1 < l2 /\ forall ( r in resources)(resource_provisions[l1,r] = resource_provisions[l2,r] ) - then - if costs[l1] > costs[l2] - then lex_greatereq( - [comp_locations[l2,c] | c in comps], - [comp_locations[l1,c] | c in comps]) - /\ - (used_locations[l1] = 1 -> used_locations[l2] = 1) - else - lex_greatereq( - [comp_locations[l1,c] | c in comps], - [comp_locations[l2,c] | c in comps]) - /\ - (used_locations[l2] = 1 -> used_locations[l1] = 1) - endif - else - true - endif - )); - - -%------------------------------------------------------------------------------% -% Redundant constraints - -%constraint redundant_constraint( -% % Ralf constraints -% forall (rcomp in comps, port in ports)( -% if requirement_port_nums[rcomp,port]!=0 -% then -% comps_num[rcomp] > 0 -> sum( mport in multi_provide_ports, pcomp in comps)( -% if provide_port_nums[pcomp,mport] != 0 /\ multi_provides[mport,port] -% then comps_num[pcomp] -% else 0 -% endif ) >= requirement_port_nums[rcomp,port] -% else -% true -% endif -% )); - -%------------------------------------------------------------------------------% -% Constraints -constraint - ( sum(l in locations)(comp_locations[l,1]) > 0 - \/ sum(l in locations)(comp_locations[l,2]) > 0 - ) -/\ forall(x in locations)(comp_locations[x,3] < 2) -/\ forall(x in locations)(comp_locations[x,4] < 2) -; - -int: obj_min = sum(l in locations)(if costs[l] < 0 then costs[l] else 0 endif); -int: obj_max = sum(l in locations)(if costs[l] > 0 then costs[l] else 0 endif); -var obj_min..obj_max: objective; - -constraint objective = sum(l in locations)(used_locations[l] * costs[l]); - -%------------------------------------------------------------------------------% -% Solve item - -array [locations] of locations: costs_asc = arg_sort(costs); -array [locations] of locations: costs_desc = reverse(costs_asc); - -solve - :: seq_search([ - int_search([used_locations[costs_desc[i]] | i in locations], - input_order, indomain_min, complete), - int_search([comp_locations[l, i] | l in locations, i in comps], - first_fail, indomain_max, complete), - int_search(comps_num, first_fail, indomain_max, complete), - int_search([bindings[m,p,i,j] | m in multi_provide_ports, p in ports, i,j in comps], - first_fail, indomain_max, complete) - ]) - minimize objective; - -%------------------------------------------------------------------------------% -% Output item - -output [ - "bindings = array4d(\(multi_provide_ports), \(ports), \(comps), \(comps), \(bindings));\n", - "comps_num = \(comps_num);\n", - "comp_locations = array2d(\(locations), \(comps), \(comp_locations));\n", - "used_locations = \(used_locations);\n", - "objective = \(objective);\n", - "% [\(objective), \(sum(x in locations)(sum(y in comps)(comp_locations[x,y])))]\n" -]; - -