Using Eclipse prolog and assuming I have a variable X and X must be less than a known number N. For this i can write:
X #< N
So, whenever X gets instantiated to a number larger than N the suspended predicate above fails.
But that if i have a counter C that starts from 0, increases during search and fails if it surpasses N?
For example what if I want to track the number of times a value is selected from a domain and the constraint is to never exceed N times. I can't do the above because Counter C gets instantiated to 0 and uses other variables for the incrementation (C1 is C+1).
do I have to do it with pure prolog? Something like this:
pred(X, N):- X1 is X+1, X1<N, pred(X1, N)
OP here. I found what I was looking for. It's a cardinality constraint and is implemented in the ic global library of eclipse prolog.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments