# Re: Help Needed

From: Warwick Harvey <wh_at_icparc.ic.ac.uk>
Date: Mon 12 May 2003 02:20:34 PM GMT
Message-ID: <20030512152033.Z26011@tempest.icparc.ic.ac.uk>
```On Fri, May 09, 2003 at 04:07:22PM +0100, albinali@email.arizona.edu wrote:
> %%%%%%%%%%%%%%%%%%%%%%
> %		what I need over here is the following:
> %		If Acj + Lj is greater than Tj then
> %			I would like to assign Acj +Lj to Tj
> %		otherwise
> %			do nothing
> %
> %		I have been trying to do that for some time with no success
> %		Shedding some light on this issue will be highly appreciated. Thanks.
> %
> %%%%%%%%%%%%%%%%%%%%%%

The usual way to do this kind of thing is via reified constraints.  If
you're using the FD solver, look in the Constraints Library Manual for that
solver, in particular the sections Logical Constraint Predicates and
Evaluation Constraint Predicates.  These predicates provide facilities for
reasoning about the truth or falsehood of other constraints.  In your case,
it is as simple as:

Acj + Lj #> Tj #=> Acj + Lj #= Tj

For this constraint, if it becomes known that Acj + Lj #> Tj, then the
constraint Acj + Lj #= Tj is enforced; conversely, if it becomes known that
Acj + Lj #\= Tj, then Acj + Lj #=< Tj is enforced.

Actually, that doesn't make sense, because if Acj + Lj #> Tj, then
Acj + Lj #= Tj is necessarily false, so the above constraint is logically
equivalent to just Acj + Lj #=< Tj...

Unless by "assign" you mean "change the value of"?  You cannot change the
value of a variable.  Perhaps you mean something like:

If Acj + Lj is greater than Tj0 then
constrain Tj to be Acj + Lj
otherwise
constrain Tj to be Tj0

?

In which case you could do something like this:

#>(Acj + Lj, Tj0, B),	% B reflects the truth of Acj + Lj #> Tj
#=(Acj + Lj, Tj, B),
#\=(Tj, Tj0, B)

Though if that's the kind of thing you want, then rather than messing about
with the above, it seems like you might find the minlist and maxlist
constraints useful?  See the Additional Finite Domain Constraints section of
the Constraint Library Manual, in particular the section Various Constraints
on Lists.

Cheers,
Warwick
```
Received on Mon May 12 15:21:33 2003

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:24 PM GMT GMT