Formulating a problem: IloModel
Describes the C++ class IloModel.
To formulate a full optimization problem, you need to
create the objects that are part of it and add them to an instance
of IloModel, the class that represents optimization
problems. For example, these lines:
IloModel model(env);
model.add(obj);
model.add(r1);
define a model consisting of the objective obj ,
constraint r1 , and all the variables they
use. Notice that variables need not be added to a model explicitly,
as they are implicitly considered if any of the other modeling objects
in the model use them. (However, you may explicitly add variables
to a model, for example, if you consider a variable a part of the
problem even though it does not appear in a constraint or objective
function.)
For convenience, Concert Technology provides the functions IloMinimize and IloMaximize
to define minimization and maximization objective functions. Also,
operators <=, == , and >=
are overloaded to create IloRange constraints.
These features allow you to rewrite that example in a compact and
readable way, like this:
IloModel model(env);
model.add(IloMinimize(env, 1*x[1] + 2*x[2] + 3*x[3]);
model.add(x[1] + x[2] == 3.0);
With this notation, you need not create the C++ variables obj and r1 explicitly
(as originally in the example). Instead, they are expressed through
the variables in this second example.
The class IloModel is itself
a class of modeling objects. Thus, one model can be added to another.
A possible use of this feature is to capture different scenarios in
different models, all of which are extensions of a core model. The
core model could be represented as an IloModel
object itself and added to the IloModel
objects that represent the individual scenarios.