Solving the model

Describes the class IloCplex in the Java API.

After you have created an optimization problem in your active model, you solve it by means of the IloCplex object. For an object named cplex, for example, you solve by calling the method like this:


cplex.solve();

The solve method returns a Boolean value specifying whether or not a feasible solution was found and can be queried. However, when true is returned, the solution that was found may not be the optimal one; for example, the optimization may have terminated prematurely because it reached an iteration limit.

Additional information about a possible solution available in the IloCplex object can be queried with the method getStatus returning an IloCplex.Status object. Possible statuses are summarized in Table 1.
Table 1. Solution status 
Return Status Active Model
Error It has not been possible to process the active model, or an error occurred during the optimization.
Unknown It has not been possible to process the active model far enough to prove anything about it. A common reason may be that a time limit was reached.
Feasible A feasible solution for the model has been proven to exist.
Bounded It has been proven that the active model has a finite bound in the direction of optimization. However, this does not imply the existence of a feasible solution.
Optimal The active model has been solved to optimality. The optimal solution can be queried.
Infeasible The active model has been proven to possess no feasible solution.
Unbounded The active model has been proven to be unbounded. The notion of unboundedness adopted by IloCplex is technically that of dual infeasibility; this does not include the notion that the model has been proven to be feasible. Instead, what has been proven is that if there is a feasible solution with objective value z*, there exists a feasible solution with objective value z*-1 for a minimization problem, or z*+1 for a maximization problem.
InfeasibleOrUnbounded The active model has been proven to be infeasible or unbounded.

For example, an Optimal status indicates that an optimal solution has been found and can be queried, whereas an Infeasible status indicates that the active model has been proven to be infeasible. See the online CPLEX Java API Reference Manual for more information about these statuses.

More detailed information about the status of the optimizer can be queried with method getCplexStatus returning an object corresponding to CPLEX status codes. Again the online CPLEX Java API Reference Manual contains further information about this.