Reputation: 976
I have a small script/code and i want to impose some active
constraints. In the code shown below, i have P[I,J] #= E
and in the next line Result[I,E] #= J
but this is throwing an instantiation error
because E
is not instantiated.
For these constraints i need to know what value is at P[I,J]
, so if i write it as E is P[I,J]
then offcourse i will not get an instantiation error(incase i suspend next two constraints with suspend, e.g suspend:(P[I,J] #= E)
but will it effect the activeness of a constraint because the assignment
will not be delayed but only constraint will be delayed. Is there any alternative way to impose this constraint?
multifor([I,J] ,[1,1],[N,N]),param(P,ResultFirst),foreach(E,_) do
E #:: 1..9,
P[I,J] #= E,
(ResultFirst[I,E] #= J),
Upvotes: 0
Views: 105
Reputation: 5034
It would be nice if one could just write it the way you have done, but unfortunately this is currently not supported (assuming you are using ECLiPSe). If the array index E
is uninstantiated at constraint setup time, you have to use an element/3 constraint. So, instead of
ResultFirst[I,E] #= J
write
element(E, ResultFirst[I], J)
Upvotes: 1