| Overview | Group | Tree | Graph | Index | Concepts | 
This macro creates an instance of the class DemonClass
 which is a subclass of IlcAltRCDemon.
 When this demon is triggered, it executes the function method
 of the constraint ConstraintClass given as parameter to the
 macro. The signature of this method must be:
 void ConstraintClass::method(IlcAltResConstraint rc, IlcResource resource).
 The argument resource is a possible resource whose change in
 some ranges for the alternative resource constraint is responsible for
 the triggering of the demon; for example, the start min of the activity if
 the resource was selected in the alternative resource constraint.
 Actually, the demon is trigerred each time a change happens in the
 start, end, duration, processing time, or capacity range.
Once the resource demon class has been defined with the macro
 ILCALTRCDEMON(DemonClass, ConstraintClass, method), an
 instance of this demon can be created by passing an instance of
 ConstraintClass as a parameter of the member function
 IlcAltResConstraint::whenRange as follows:
ConstraintClass* ct = ...; IlcAltRCDemon myDemon = DemonClass(ct);
Example
The following code defines a demon AltRCDemonCaller that
 prints pieces of information about the resources whose ranges change.
  class AltRCDemonCallI : public IlcConstraintI {
    IlcAltResConstraint _ct;
  public:
    AltRCDemonCallI(IlcManager m, IlcAltResConstraint ct)
      :IlcConstraintI(m), _ct(ct)
      {}
    ~AltRCDemonCallI() {}
    virtual void post();
    virtual void propagate();
    void showInfo(IlcAltResConstraint rc, IlcResource resource);
  };
  void AltRCDemonCallI::showInfo(IlcAltResConstraint rc, IlcResource resource) {
    IlcAltResSet set = rc.getAltResSet();
    cout << endl << "--------AltRCDemonCallI---------" << endl;
    cout << "IlcAltResConstraint :" << rc << endl;
    cout << "IlcResource : " << resource << endl;
    cout << "Index : " << set.getIndex(resource) << " in " << rc.getIndexVariable() << endl;
    cout << "--------------------------------" << endl;
  }
  ILCALTRCDEMON(AltRCDemonCaller, AltRCDemonCallI, showInfo);
  void AltRCDemonCallI::post() {
    _ct.whenRange(AltRCDemonCaller(this));
  }
  void AltRCDemonCallI::propagate() {
    cout << endl << "--------AltRCDemonCallI---------" << endl;
    cout << "Demon For " << _ct << endl;
    cout << "--------------------------------" << endl;
  }
  IloSolver ...;
  IlcSchedule schedule(s, 0, 500);
  IlcDiscreteResource r1(schedule, 2);
  IlcDiscreteResource r2(schedule, 2);
  r1.setName("r1");
  r2.setName("r2");
  IlcAltResSet set(schedule, 2, r1, r2);
  IlcActivity a1(schedule, 30);
  IlcAltResConstraint rc1 = a1.requires(set, 2);
  s.add(rc1);
  s.add(new (s.getHeap()) AltRCDemonCallI(s, rc1));
 See Also: