So far we have discussed some methods of IloCplex
for creating models. All such methods are defined in the interfaces IloModeler
and its extension IloMPModeler
. However, IloCplex
not only implements these interfaces but also provides additional methods for solving a model and querying its results.
After a model has been created as described in the previous section, the IloCplex
object cplex
is ready to solve the model, which consists of all the modeling objects that have been added to it. Invoking the optimizer is as simple as calling method solve
.
Method solve
returns a Boolean indicating whether the optimization succeeded in finding a solution. If no solution was found, false
is returned. If true
is returned, then CPLEX found a feasible solution, though it is not necessarily an optimal solution. More precise information about the outcome of the last call to method solve
can be obtained by calling:
The returned value tells you what CPLEX found out about the model: whether it found the optimal solution or only a feasible solution, whether it proved the model to be unbounded or infeasible, or whether nothing at all has been determined at this point. Even more detailed information about the termination of the solver call is available through the method:
IloCplex.getCplexStatus();