assert
requires a bool
in the test part, and don't support var bool
.
A suggestion is to rewrite the increasing
constraint to a loop with single asserts with bool
expressions. For example:
include "globals.mzn";
int: n = 5;
array[1..n] of 1..n: x = [5,4,3,1,2];
constraint forall(i in 1..n-1) (
assert(x[i] <= x[i+1], "x is not increasing")
);
solve satisfy;
output[ "\(x)\n"];
This yield the following error:
MiniZinc: evaluation error:
/home/hakank/g12/me/assert_test.mzn:31:
in call 'forall'
in call 'forall'
in array comprehension expression
with i = 1
/home/hakank/g12/me/assert_test.mzn:32:
in call 'assert'
in call 'assert'
Assertion failed: x is not increasing
Update: Another way is to put the forall
inside assert
, i.e.
% ...
constraint
assert(
forall(i in 1..n-1) (
assert(x[i] <= x[i+1], "x is not increasing")
)
, "x is not increasing"
);
assert
. Check Predicate $\endgroup$MiniZinc: type error: no function or predicate with this signature found:
assert(var bool)'` $\endgroup$