| 1 |
/*** |
| 2 |
!Test |
| 3 |
solvers: [gecode, chuffed] |
| 4 |
expected: !Result |
| 5 |
solution: !SolutionSet |
| 6 |
- !Solution |
| 7 |
b: false |
| 8 |
i: 0 |
| 9 |
- !Solution |
| 10 |
b: true |
| 11 |
i: 1 |
| 12 |
- !Solution |
| 13 |
b: false |
| 14 |
i: 2 |
| 15 |
- !Solution |
| 16 |
b: false |
| 17 |
i: 3 |
| 18 |
options: |
| 19 |
all_solutions: true |
| 20 |
***/ |
| 21 |
|
| 22 |
% Regression test for bug #244: when asked for all solutions (with G12/FD) |
| 23 |
% this model did not produce the solution (i = 0, b = false). The problem |
| 24 |
% was that the flattening of the reified array lookup in the constraint was |
| 25 |
% incorrect. We were emitting (in pseudcode): |
| 26 |
% |
| 27 |
% (i = i' <-> i <= size(arr)) /\ i >= 1 |
| 28 |
% |
| 29 |
% rather than |
| 30 |
% |
| 31 |
% (i = i' <-> i (i >= 1 /\ i <= size(arr))) |
| 32 |
% |
| 33 |
% i' is the fesh index variable. |
| 34 |
|
| 35 |
var 0..3: i; |
| 36 |
var bool: b; |
| 37 |
array[1..2] of bool: arr = [true, false]; |
| 38 |
constraint b = arr[i]; |
| 39 |
solve satisfy; |
| 40 |
output [ |
| 41 |
"b = ", show(b), ";\n", |
| 42 |
"i = ", show(i), ";\n" |
| 43 |
]; |