In this manual we describe only one optimization model and use only one instance of IloCplex
at a time to solve the model. Consequently, we talk about these as the model and the cplex
object. It should be noted, however, that in Concert Technology an arbitrary number of models and algorithm objects can be created, provided you have enough licenses. The cplex
object can be created using the constructor:
To use it to solve the model, the model must first be extracted to cplex
by calling:
This method copies the data from the model into the appropriate optimized data structures, which CPLEX uses for solving the problem. It does so by extracting each of the modeling objects added to the model and each of the objects referenced by them. For every extracted modeling object, corresponding data structures are created internally in the cplex
object. For readers familiar with the sparse matrix representation used internally by CPLEX, a variable becomes a column and a constraint becomes a row. As we will discuss later, these data structures are kept synchronized with the modeling objects even if the modeling objects are modified.
If you consider a variable to be part of your model, even though it is not (initially) used in any constraint, you should add this variable explicitly to the model. This ensures that the variable will be extracted. This may also be important if you query solution information for the variable, since solution information is available only for modeling objects that are known to CPLEX because they have been extracted from a model.
If you feel uncertain about whether or not an object will be extracted, you can add it to the model to be sure. Even if an object is added multiple times, it will only be extracted once and thus will not slow the solution process down.
Since the sequence of creating the cplex
object and extracting the model to it is such a common one, IloCplex
provides the shortcut:
This is completely equivalent to separate calls and ensures that the environment used for the cplex
object will be the same as that used for the model when it is extracted, as required by Concert Technology. The shortcut uses the environment from the model to construct the cplex
object before extraction.