[gecode-users] Custom constraint to external progam

Pedro Salgueiro pds at di.uevora.pt
Thu Nov 13 13:30:14 CET 2008


Hi!

That example seems very help-full and I think now I can do what I want. 

Any way, I am not beeing able to build your example:

teste1.cc: In static member function ‘static Gecode::ExecStatus Extra::DisEq<View>::post(Gecode::Space*, View, View, View) [with View = Gecode::Int::IntView]’:
teste1.cc:115:   instantiated from here
teste1.cc:70: error: cannot allocate an object of abstract type ‘Extra::DisEq<Gecode::Int::IntView>’
teste1.cc:41: note:   because the following virtual functions are pure within ‘Extra::DisEq<Gecode::Int::IntView>’:
/usr/local/include/gecode/kernel/core.icc:719: note: 	virtual Gecode::ExecStatus Gecode::Propagator::propagate(Gecode::Space*, Gecode::ModEventDelta)
make: *** [teste1] Error 1


If I comment the following line in post method, it builds ok, but
obviously it would not work ok:

    //(void) new (home) DisEq<View>(home,x0,x1,x2);

What am I doing wrong?

Thank you.
Pedro Salgueiro



On Thu, 2008-11-13 at 12:05 +0100, Mikael Zayenz Lagerkvist wrote:
> Hi,
> 
> There are no examples currently in Gecode that implement custom propagators.
> 
> There is an old post in the mailinglist with a custom
> propagator-example [1]. Note that there is a bug in the logic, the
> line
>     GECODE_ME_CHECK(x1.inter_r(home, u12, false));
> should be
>     GECODE_ME_CHECK(x0.inter_r(home, u12, false));
> I missed that on a variable-renaming before posting it.
> 
> Hope that helps,
> Mikael
> 
> [1] http://article.gmane.org/gmane.comp.lib.gecode.user/1276/
> 
> 
> On Thu, Nov 13, 2008 at 11:51 AM, Pedro Salgueiro <pds at di.uevora.pt> wrote:
> > Ok, I think thats what I want to do.
> >
> > Is there any examples in Gecode that implement a custom propagator?
> >
> > Pedro Salgueiro
> >
> > On Thu, 2008-11-13 at 11:10 +0100, Mauricio Toro wrote:
> >> Hello,
> >>
> >>
> >> I made something similar once.
> >> My approach was writting a propagator
> >> that waits until cvars[0] and cvars[1]
> >> are assigned. Once they are assigned
> >> it calls run_something.
> >>
> >>
> >> I hope that helps,
> >>
> >>
> >> Mauricio
> >>
> >> 2008/11/13 Pedro Salgueiro <pds at di.uevora.pt>
> >>         Hi!
> >>
> >>         I have been experimenting Gecode for a while, and now I want
> >>         to make
> >>         something wich I don't know if its possible:
> >>
> >>         I want to create a new "custom" constraint that allows to
> >>         relate/constraint a variable with a function that receives two
> >>         other
> >>         gecode variables as parameters. This function will be
> >>         something
> >>         completely external to gecode, and evan c++, so, by the the
> >>         this
> >>         function is called the gecode variables that are used on it
> >>         should
> >>         already have some values assigned to it.
> >>
> >>         Here's how it would look:
> >>
> >>         post(this, cvars[0] < 5)
> >>         post(this, cvars[1] < cvars[0] + 2)
> >>         post(this, new_constraint(cvars[2], run_something(cvars[0],
> >>         cvars[1])
> >>
> >>         In this example, we could just assume that the
> >>         "new_constraint" is used
> >>         to make sure that cvars[2] "<"
> >>         run_something(cvars[0],cvars[1]).
> >>
> >>         Is this possible to do? If so, where should I start?
> >>
> >>         Thank you all
> >>         Pedro Salgueiro
> >>
> >>
> >>         _______________________________________________
> >>         Gecode users mailing list
> >>         users at gecode.org
> >>         https://www.gecode.org/mailman/listinfo/gecode-users
> >>
> >>
> >>
> >> --
> >> Mauricio Toro Bermudez
> >> Estudiante de Ingeniería de Sistemas
> >> Pontificia Universidad Javeriana, Colombia
> >>
> >> Stagiare à l'Ircam
> >> 1, place Igor-Stravinsky 75004 Paris,
> >> France de 2008 à 2009
> >>
> >
> >
> > _______________________________________________
> > Gecode users mailing list
> > users at gecode.org
> > https://www.gecode.org/mailman/listinfo/gecode-users
> >
> 
> 
> 





More information about the gecode-users mailing list