[gecode-users] Question about gecode2

Christian Schulte cschulte at kth.se
Thu Jan 10 17:48:38 CET 2008


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