[gecode-users] Question about gecode2

Christian Schulte cschulte at kth.se
Fri Jan 11 09:08:40 CET 2008


Unfortunately, your version is very, very inefficient. It creates a
propagator for each Boolean variable, if I understand correctly.

BTW: channeling between a Boolean variable and an integer is of course
available (so you should not use linear for that). It is called channel:
	
http://www.gecode.org/gecode-doc-latest/group__TaskModelIntChannel.html

Even more convenient is the function channel in the MiniModel module:
	
http://www.gecode.org/gecode-doc-latest/group__TaskModelMiniModelChannel.htm
l

Cheers
Christian 

--
Christian Schulte, www.ict.kth.se/~cschulte/


-----Original Message-----
From: Mohamad Rabbath [mailto:mthefirst at gmail.com] 
Sent: Thursday, January 10, 2008 6:46 PM
To: cschulte at kth.se
Cc: Mohamad Rabbath; users at gecode.org
Subject: Re: [gecode-users] Question about gecode2

Yes that's almost the same trick i used but i used one linear instead
of linear and rel.
Thanx.
Mohamad

On Jan 10, 2008 5:48 PM, Christian Schulte <cschulte at kth.se> wrote:
> Hi,
>
> That's actually a bug (or an omission) in Gecode 2.0.0. Apparently we
missed
> these variants. We will add them for Gecode 2.0.1 which will be available
> very soon (together with Gecode/J 2.0.1).
>
> In the mean time you can fix it very easily as follows: assume that a are
> the IntArgs, x are the BoolVars. Then you can introduce a new variable z
> that will be the sum of a*x. Then you reify just wrt z with rel. So the
> following definition should do the trick:
>
> using namespace Gecode;
> void linear(Space* home, const IntArgs& a, const BoolVarArgs& x,
IntRelType
> r, int y) {
>   IntVar z(home,Limits::Int::int_min,Limits::Int::int_max);
>   linear(home,a,x,IRT_EQ,z);
>   rel(home,z,r,y);
> }
>
> Cheers
> Christian
>
>
> --
> Christian Schulte, www.ict.kth.se/~cschulte/
>
>
>
> -----Original Message-----
> From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
> Of Mohamad Rabbath
> Sent: Thursday, January 10, 2008 3:38 PM
> To: users at gecode.org
> Subject: [gecode-users] Question about gecode2
>
> Hey,
> i have recently imigrated to gecode 2.0 and i foud the following problem:
> There is no refied version for the function :
> void Gecode::linear     (       Space *          home,
>                 const IntArgs &         a,
>                 const BoolVarArgs &     x,
>                 IntRelType      r,
>                 int     y,
>                 IntConLevel     icl = ICL_DEF,
>                 PropKind        pk = PK_DEF
>         )
> or:
> void Gecode::linear     (       Space *          home,
>                 const IntArgs &         a,
>                 const BoolVarArgs &     x,
>                 IntRelType      r,
>                 IntVar          y,
>                 IntConLevel     icl = ICL_DEF,
>                 PropKind        pk = PK_DEF
>         )
> While thie problem is not exited for the version of this function that
> deals with IntVar because the function :
> void Gecode::linear     (       Space *          home,
>                 const IntArgs &         a,
>                 const IntVarArgs &      x,
>                 IntRelType      r,
>                 int     y,
>                 BoolVar         b,
>                 IntConLevel     icl = ICL_DEF,
>                 PropKind        pk = PK_DEF
>         )
> is already exited.
> So if my variables are BoolVarArgs the only way to deal with this is to
> convert to IntVar (and the assignment"=" is not available) so the only way
> to do it is to use the following trick:
> //
> BoolVarArgs convertToIntVar(1);
> convertToIntVar[0]=BoolVarToConvert;
> linear(this, convertToIntVar, IRT_EQ,IntVarToBeConverted);
> //
> So is it possible to add refied version of the
> void Gecode::linear(Space *,const IntArgs & ,const BoolVarArgs &
> ,IntRelType,int ,IntConLevel icl = ICL_DEF,PropKind pk = PK_DEF)
>
> Best regards.
>
> Mohamad Rabbath
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>
>





More information about the gecode-users mailing list