ILOG CPLEX 11.0 User's Manual > Discrete Optimization > Using Column Generation: a Cutting Stock Example > Developing the Model: Building and Modifying > Adding Extractable Objects: Both Ways

In a Concert Technology application, there are two ways of adding extractable objects to a model: by means of a template function (IloAdd) or by means of a method of the model (IloModel::add). In this example, you see both ways.

Using a Template to Add Objects

When an objective is added to the model, the application needs to keep a handle to the objective RollsUsed because it is needed when the application generates columns. For that purpose, the application relies on the template function IloAdd, like this:

IloObjective   RollsUsed = IloAdd(cutOpt, IloMinimize(env));

Apart from the fact that it preserves type information, that single line is equivalent to these lines:

IloObjective RollsUsed = IloMinimize(env);
cutOpt.add(RollsUsed);

Likewise, the application adds an array of constraints to the model. These constraints are needed later in column generation as well, so the application again uses IloAdd again to add the array Fill to the model.

IloRangeArray  Fill = IloAdd(cutOpt,
                             IloRangeArray(env, amount, IloInfinity));

That statement creates amount.getSize range constraints. Constraint Fill[i] has a lower bound of amount[i] and an upper bound of IloInfinity.

Using a Method to Add Objects

It is also possible to add objects to your model by means of the method IloModel::add. This example uses that approach for the submodel in this line:

patGen.add(IloScalProd(size, Use) <= rollWidth);