[gecode-users] How can I make this constraint

Guido Tack tack at ps.uni-sb.de
Thu Feb 14 22:42:48 CET 2008


Mauricio Toro wrote:

> Sorry... I meant this
>
> 2008/2/14, Guido Tack <tack at ps.uni-sb.de>:
> Am 14.02.2008 um 21:23 schrieb Mauricio Toro:
>> How can I make this constraint?
>>
>>
>> int const x[] = {0,2,5,8,9,10};
>> answer = IntVarArray(this,n,1,11);
>>
>> for (int i = 0; i < n-1; i++){
>> 		// x[i] - x[i+1] = answer[i] - answer[i+1]

for (int i=0; i<n-1; i++)
   post(this, x[i] - x[i+1] == answer[i] - answer[i+1]);

should do the trick (you have to include gecode/minimodel.hh for this  
to work).

Cheers,
	Guido

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20080214/ac6796d1/attachment.htm>


More information about the gecode-users mailing list