Skip to main content
FRAMES NO FRAMES

Macro ILCCTDEMON0

Definition file: ilcp/cpext.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)
Macro for creating a new demon class.

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.

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(IlcCPEngine solver,
                        MyConstraintI* ct,
                        IlcIntVar avar):
      IlcDemonI(cp, ct), var(avar) {}
      ~CallReduceRomainI(){}
      void propagate();
 };
 IlcDemon CallReduceDomain(IlcCPEngine solver,
                        MyConstraintI* ct,
                        IlcIntVar var){
      return new (solver.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(cp,ct,var);

For more information, see the concepts Propagation in CP Optimizer and Propagation events in CP Optimizer.

See Also: