FRAMES NO FRAMES

Macro ILCCTDEMON0

Definition file: ilsolver/basic.h
ILCCTDEMON0(name, IlcCtClass, IlcFnName)
ILCCTDEMON1(name, IlcCtClass, IlcFnName, t1, nA1)
ILCCTDEMON2(name, IlcCtClass, IlcFnName, t1, nA1, t2, nA2)
ILCCTDEMON3(name, IlcCtClass, IlcFnName, t1, nA1, t2, nA2, t3, nA3)
ILCCTDEMON4(name, IlcCtClass, IlcFnName, t1, nA1, t2, nA2, t3, nA3, t4, nA4)
ILCCTDEMON5(name, IlcCtClass, IlcFnName, t1, nA1, t2, nA2, t3, nA3, t4, nA4, t5, nA5)
ILCCTDEMON6(name, IlcCtClass, IlcFnName, t1, nA1, t2, nA2, t3, nA3, t4, nA4, t5, nA5, t6, nA6)

This macro defines a demon class named nameI with n data members. When n is greater than 0, the types and names of the data members must be supplied as arguments to the macro. Each data member is defined by its type Ti and a name datai. Besides the definition of the class nameI, this macro also defines a function named name that creates an instance of the class nameI and that returns an instance of the class IlcDemon that points to it.

An instance of a class of demons created in this way can serve as a parent of constraints. The member function IlcConstraint::getParentDemon accesses the demon-parent of a constraint.

You are not obliged to use this macro to define demons. When the macro seems too restrictive for your purposes, we recommend that you define a demon class directly.

Since the argument name is used to name the demon class, it is not possible to use the same name for several demon definitions.

Example

Here's how to define a demon that calls the function MyConstraintI::reduceDomain(IlcIntVar var); of the constraint ct:

 ILCCTDEMON1 (CallReduceDomain, MyConstraintI,
           reduceDomain, IlcIntVar, var);

This macro then generates code similar to the following lines:

 class CallReduceDomainI: public IlcDemonI {
      IlcIntVar var;
 public:
      CallReduceDomainI(IloSolver s,
                        MyConstraintI* ct,
                        IlcIntVar avar):
      IlcDemonI(s,ct), var(avar) {}
      ~CallReduceRomainI(){}
      void propagate();
 };
 IlcDemon CallReduceDomain(IloSolver s,
                        MyConstraintI* ct,
                        IlcIntVar var){
      return new (s.getHeap())
                  CallReduceDomainI(s,ct,var);
 }
 void CallReduceDomainI::propagate(){
      ((MyConstraintI*)getConstraint())->reduceDomain(var);
 }

The following statement creates an instance of the class CallReduceDomainI and returns a handle that points to it.

 CallReduceDomain(s,ct,var);

For more information, see the concepts Propagation and Propagation Events.

See Also: