NO FRAMES

Macro ILOCPLEXGOAL0

Definition file: ilogoals.h

ILOCPLEXGOAL0(name)

ILOCPLEXGOAL1(name, type0, var0)

ILOCPLEXGOAL2(name, type0, var0, type1, var1)

ILOCPLEXGOAL3(name, type0, var0, type1, var1, type2, var2)

ILOCPLEXGOAL4(name, t0, v0, t1, v1, t2, v2, t3, v3)

ILOCPLEXGOAL5(name, t0, v0, t1, v1, t2, v2, t3, v3, t4, v4)

ILOCPLEXGOAL6(name, t0, v0, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5)

This macro defines a user goal class named nameI and a constructor named name with n data members, where n is the number following ILOCPLEXGOAL. The first parameter of this macro is always the name of the constructor to be created. What follows are n pairs of parameters, each parameter specifying a data member of the goal. The first parameter of such a pair specifies the type of the data member and is denoted as Ti in the macro definition above. The second parameter of such a pair, denoted by datai, specifies the data member's name.

The constructor name created by this function will have IloEnvenv as its first argument, followed by n additional arguments. The constructor creates a new instance of the user-written goal class nameI and populates its data members with the arguments following IloEnvenv in the function argument list. The constructor name is what you should use to create new goal objects.

The call to the macro must be followed immediately by the execute method of the goal class. This method must be enclosed in curly brackets, as shown in the examples that follow. The macro will also generate an implementation of the method duplicateGoal that simply calls the default constructor for the new class nameI.

You are not obliged to use this macro to define goals. In particular, if your data members do not permit the use of the default constructor as an implementation of the method duplicateGoal or the default destructor, you must subclass IloCplex::GoalI directly and implement those methods appropriately.

Since the argument name is used to construct the name of the goal's implementation class, it is not possible to use the same name for several goal definitions.

Example

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

     ILOCPLEXGOAL1(PrintX, IloInt, x) {	  
       IloEnv env = getEnv();	
       env.out() << "PrintX: a goal with one data member" <<
 endl;
       env.out() << x << endl;    
       return 0;  
     }
 

This macro generates code similar to the following lines:

     class PrintXI : public IloCplex::GoalI {	
     public:	 
       IloInt x;       
       PrintXI(IloEnv env, IloInt arg1)
       IloCplex::Goal execute();  
       IloCplex::Goal duplicateGoal();  
     };	
 
     PrintXI::PrintXI(IloEnv env, IloInt arg1) :
 				    IloCplex::GoalI(env), 
 				    x(arg1) {
     }
 
     IloCplex::Goal PrintX(IloEnv env, IloInt x) {    
       return new PrintXI(env, x); 
     }  
 
     IloCplex::Goal PrintXI::execute() {    
       IloEnv env = getEnv();	
       env.out() << "PrintX: a goal with one data member" <<
 endl;
       env.out() << x << endl;    
       return 0;  
     }
 
     IloCplex::Goal PrintXI::duplicateGoal() {
       return new PrintXI(getEnv(), x);
     }