[gecode-users] Conditional constraints ?

Guido Tack tack at gecode.org
Mon Feb 20 23:04:29 CET 2012


On 21 Feb 2012, at 08:33, Wajid Hassan wrote:

> Hi Christian,
> 
> The problem in a nut shell is: 
> 
> I have two arrays of integer variables, Array1[x] and Array2[x]. I want to use the value assigned to the variables in Array1[] as an index of Array2[], something like this:
> 
> rel(*this, Array2[Array1[x].val()] + (something) <= Array2[x+1]);
> 
> Is there anything wrong with the above constraint or should this work?

That is what the element constraint is used for (you'll find it in the documentation).  It works directly on variables, so you don't have to solve the sub-problem on x first.

Cheers,
Guido

-- 
Guido Tack,
http://www.csse.monash.edu/~guidot/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20120221/c96e2a60/attachment-0001.htm>


More information about the users mailing list