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 <t...@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
us...@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users


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

Attachment: constr_myprop.hpp
Description: Binary data

Attachment: example.cpp
Description: Binary data

Attachment: Makefile
Description: Binary data

_______________________________________________
Gecode users mailing list
us...@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to