[gecode-users] customize IntVar

Changbin Liu changbin.liu at gmail.com
Fri Apr 15 01:18:25 CEST 2011


Hi folks,

    I am trying to customize existing class IntVar by adding some more data
member into it. My current way is to subclass from IntVar (say the new class
name is MyIntVar) and write constructors and new member functions to
manipulate the new data. This works well.

However, if I want to use IntVarArray and IntVarArgs to hold MyIntVar, all
MyIntVar elements seems are converted to IntVar.

For example, in the code

MyIntVar myIntVar(*this, 0, 10);
IntVarArgs intVarArgs;
intVarArgs << myIntVar;

I observe that intVarArgs[0] is IntVar type. I can not even use dynamic_cast
to cast it to MyIntVar.

If I do it another way by implementing MyIntVarArray and MyIntVarArgs for
MyIntVar following the document "Modeling and Programming with Gecode" (this
corresponds to IntVarArray and IntVarArgs for IntVar), this works well. But
the problem is that constraints posting (e.g. sum, "+") do not work on new
MyIntVarArray and MyIntVarArgs.

Basically, my question is what is the easiest to way to slightly modify
IntVar to adapt to user needs.

Many thanks
-- 
--------------------------------------------
Changbin Liu
Computer & Information Science Department
University of Pennsylvania
Philadelphia, PA
U.S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20110414/e1f014a4/attachment.htm>


More information about the users mailing list