[gecode-users] A constrain with 3 IntVar

Christian Schulte cschulte at kth.se
Tue Sep 1 11:03:12 CEST 2009


There are also examples to be found here (from a course I teach):
	http://www.ict.kth.se/courses/ID2204/assignments.html

Christian

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf Of Tias Guns
Sent: Tuesday, September 01, 2009 10:48 AM
To: users at gecode.org
Subject: Re: [gecode-users] A constrain with 3 IntVar

I've created a very simple propagator once, to show a student how to do it. It's attached, in case it would be helpfull for others too.  
constr_myprop.hpp contains the propagator, example.cpp is an example of how to use it and the Makefile compiles it on *nix systems.

Note that the propagator is really silly: it assigns every unassigned variable to 1. However, it should be enough to start from...


Greetings,
Tias

On Mon, 31 Aug 2009 11:02:26 +0200, Guido Tack <tack at ps.uni-sb.de> wrote:

> amina kemmar wrote:
>
>> Hi,
>>
>> I am writing a new constraint "NewConstraint", which takes 3 IntVar 
>> as arguments :
>>
>> #include <algorithm>
>> #include <gecode/int.hh>
>>
>> namespace Gecode {
>>
>>   using namespace Int;
>>
>>   void NewConstraint(Space& home, IntVar x0, IntVar x1, IntVar x3) {
>>
>>     if (home.failed()) return;
>>
>>     //  Creation of an array x, which contains the 3 variables 
>> x0,x1,x2;
>>     //  .....
>>
>>     // ViewArray<IntView> xv(home,x);
>>     // GECODE_ES_FAIL(home,
>> NewConstraint::Diff<IntView>::post(home,xv));
>>   }
>> }
>>
>> To post the constraint  i need to create a ViewArray, but i don't 
>> understand how to create an IntVarArg  containing these variables ?
>
> Just fill the array manually, no need for IntVarArgs:
>
> xv[0] = x0; xv[1] = x1; xv[2] = x2;
>
> Or change the definition of the NewConstraint class to take three 
> views instead of one ViewArray.
>
> Cheers,
> 	Guido
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm





More information about the gecode-users mailing list