Overview | Group | Tree | Graph | Index | Concepts |
This macro defines a transition time object, a subclass of
IloTransitionTimeObjectI
named
nameI
. The argument solver
is the name of the
IloSolver
that performs the extraction. Within the macro, this
name denotes the solver currently performing the extraction.
When n is greater than 0 (zero), 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 ai
. The call
to the macro must be followed immediately by the body of the extract member
function of the transition time object class being defined. It must return a
pointer to an instance of IlcTransitionTimeObjectI
that corresponds to the extracted
object. 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
IloTransitionTimeObject
that points to
it.
The use of this macro is the only way to define a new subclass of
IloTransitionTimeObjectI
.
Since the argument name
is used to name the transition time
object class, it is not possible to use the same name for some other
classes.
Example
This example shows how to define a transition time object with two data members. The first one is a constant that corresponds to the transition time between any pair of resource constraints when the transition time is considered. The second one is a Concert Technology boolean variable that states whether or not the transition time is to be considered.
ILOTRANSITIONTIMEOBJECT2(MyIloTTObject, mySolver, IloInt, delay, IloNumVar, iloVar) { use(mySolver, iloVar); IlcIntVar ilcVar = mySolver.getIntVar(iloVar); return new (mySolver.getHeap()) MyIlcTTObjectI(mySolver, delay, ilcVar); }
Here is how the corresponding IlcTransitionTimeObject
could be defined:
class MyIlcTTObjectI :public IlcTransitionTimeObjectI { private: IlcInt _delay; IlcIntVar _ilcVar; public: MyIlcTTObjectI(IloSolver solver, IlcInt delay, IlcIntVar ilcVar); ~MyIlcTTObjectI(){}; IlcInt getTransitionTime(const IlcResourceConstraint, const IlcResourceConstraint) const { if (_ilcVar.getMin() == 1) return _delay; return 0; } }; MyIlcTTObjectI::MyIlcTTObjectI(IloSolver solver, IlcInt delay, IlcIntVar ilcVar) :IlcTransitionTimeObjectI(), _delay (delay), _ilcVar (ilcVar) {};
The following statement creates an instance of the class
MyIloTTObjectI
and returns a handle that points to it.
IloTransitionTimeObject myTTObj = MyIloTTObject(env, delay, iloVar);
This transition time could, for instance, be associated with a resource
res
by creating a transition time as follows:
IloTransitionTime(res, myTTObj);
For more information, see Transition Times.
See Also:
IloTransitionTimeObject, IloTransitionTimeObjectI, IloTransitionTime, IlcTransitionTimeObjectI