[gecode-users] A constrain with 3 IntVar

Tias Guns tias.guns at cs.kuleuven.be
Tue Sep 1 10:47:53 CEST 2009


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: constr_myprop.hpp
Type: application/octet-stream
Size: 4375 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20090901/462fe55d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.cpp
Type: application/octet-stream
Size: 2364 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20090901/462fe55d/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 514 bytes
Desc: not available
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20090901/462fe55d/attachment-0002.obj>


More information about the gecode-users mailing list