Dear Kilian,
I scratched my head quite a bit yesterday, and I just found a nice
solution to your problem. The idea is to avoid reification, because
propagation is too poor in that case.
Kilian Sprotte wrote:
I am looking for a way to constrain a sequence to be "ascending towards
a goal". The goal is determined before posting, let's say its 5, so a
solution could be:
[1 2 4 5 5]
Let us call this sequence S. It can be defined as:
declare
Goal=5
N=5
S={FD.list N 1#Goal}
The issue is that S is strictly increasing, except when values reach the
goal. My idea is to combine the propagators <: and FD.min. Consider
another sequence, say T, that is strictly increasing, and where values
may be greater than the goal:
declare
T={FD.list N 1#(Goal+N-1)}
for A in T B in T.2 do A <: B end % strictly increasing
The link with S is done by taking the minimum between the Goal and each
element of T:
for X in S Y in T do X={FD.min Goal Y} end
Both propagators <: and FD.min will propagate of the variables' domains,
and propagates exactly as you wanted:
[1#5 2#5 3#5 4#5 5]
Try to constrain the 3rd element of S to value 4 in the example, and you
will see that the 4th element is constrained to 5.
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users