FRAMES NO FRAMES

Macro ILCGOAL0

Definition file: ilsolver/basic.h
ILCGOAL0(name)
ILCGOAL1(name, t1, nA1)
ILCGOAL2(name, t1, nA1, t2, nA2)
ILCGOAL3(name, t1, nA1, t2, nA2, t3, nA3)
ILCGOAL4(name, t1, nA1, t2, nA2, t3, nA3, t4, nA4)
ILCGOAL5(name, t1, nA1, t2, nA2, t3, nA3, t4, nA4, t5, nA5)
ILCGOAL6(name, t1, nA1, t2, nA2, t3, nA3, t4, nA4, t5, nA5, t6, nA6)

This macro defines a goal class named nameI with n data members. 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 datai. The call to the macro must be followed immediately by the body of the execute member function of the goal class being defined. Besides the definition of the class nameI, this macro also defines a function named name whose first argument is IloSolver s, and the n following ones correspond to the n data members. This function creates an instance of the class nameI, fills the data members with its n last arguments, and returns an instance of the class IlcGoal that points to it.

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

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

Examples:

Here's how to define a goal with one data member:

 ILCGOAL1(PrintX, IlcInt, x){
   IloSolver s = getSolver();
   s.out() << "PrintX: a goal with one data member" << endl;
   s.out() << x << endl;
   return 0;
 }

This macro generates code similar to the following lines:

 class PrintXI : public IlcGoalI {
   public:
     IlcInt x;
     PrintXI(IloSolver solver, IlcInt);
     IlcGoal execute();
 };
 PrintXI::PrintXI(IloSolver solver, IlcInt arg1)
   :IlcGoalI(solver), x(arg1){}
 IlcGoal PrintX(IloSolver s, IlcInt x){
   return new (s.getHeap()) PrintXI(s.getImpl(), x);
 }
 IlcGoal PrintXI :: execute() {
   IloSolver s = getSolver();
   s.out() << "PrintX: a goal with one data member" << endl;
   s.out() << x << endl;
   return 0;
 }

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


 PrintX(s, 2);
 

See Also: