-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bin packing assertion failures when using empty array arguments
Resolves #865
- Loading branch information
Showing
8 changed files
with
75 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
predicate fzn_bin_packing(int: c, | ||
array[int] of var int: bin, | ||
array[int] of int: w) = | ||
let { | ||
int: all_weight = sum(w) | ||
} in forall( b in lb_array(bin)..ub_array(bin) ) ( | ||
sum(i in index_set(bin)) ( | ||
w[i] * (bin[i] != b) | ||
) >= (all_weight - c) | ||
); | ||
predicate fzn_bin_packing( | ||
int: c, | ||
array[int] of var int: bin, | ||
array[int] of int: w | ||
) = if length(bin) > 0 then | ||
let { | ||
int: all_weight = sum(w) | ||
} in forall( b in lb_array(bin)..ub_array(bin) ) ( | ||
sum(i in index_set(bin)) ( | ||
w[i] * (bin[i] != b) | ||
) >= (all_weight - c) | ||
) | ||
endif; | ||
|
||
%-----------------------------------------------------------------------------% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
predicate fzn_bin_packing_reif(int: c, | ||
array[int] of var int: bin, | ||
array[int] of int: w, | ||
var bool: b) = | ||
b <-> forall( assigned_bin in lb_array(bin)..ub_array(bin) ) ( | ||
c >= sum ( i in index_set(bin) ) ( | ||
w[i] * ( bin[i] == assigned_bin ) | ||
) | ||
); | ||
predicate fzn_bin_packing_reif( | ||
int: c, | ||
array[int] of var int: bin, | ||
array[int] of int: w, | ||
var bool: b | ||
) = | ||
b <-> if length(bin) > 0 then | ||
forall(assigned_bin in lb_array(bin)..ub_array(bin)) ( | ||
sum (i in index_set(bin))( | ||
w[i] * (bin[i] == assigned_bin) | ||
) <= c | ||
) | ||
endif; | ||
|
||
%-----------------------------------------------------------------------------% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*** | ||
!Test | ||
solvers: [gecode] | ||
options: | ||
-G: std | ||
expected: !Result | ||
solution: !Solution | ||
***/ | ||
|
||
include "bin_packing.mzn"; | ||
include "bin_packing_capa.mzn"; | ||
include "bin_packing_load.mzn"; | ||
include "bin_packing_load_fn.mzn"; | ||
|
||
constraint bin_packing(0, [], []); | ||
constraint bin_packing_capa([], [], []); | ||
constraint bin_packing_load([], [], []); | ||
constraint bin_packing_load([0], [], []); | ||
constraint bin_packing_load([], []) == []; |