ILOG CPLEX 11.0 Getting Started > Tutorials > Concert Technology Tutorial for C++ Users > The Anatomy of an ILOG Concert Technology C++ Application > Solving the Model: IloCplex

After the optimization problem has been created in an IloModel object, it is time to create the IloCplex object for solving the problem. This is done by creating an instance of the class IloCplex. For example, to create an object named cplex, do the following:

IloCplex cplex(env);

again using the environment env as an argument. The ILOG CPLEX object can then be used to extract the model to be solved. One way to extract the model is to call cplex.extract(model). However, experienced Concert users recommend a shortcut that performs the construction of the cplex object and the extraction of the model in one line:

IloCplex cplex(model);

This shortcut works because the modeling object model contains within it the reference to the environment named env.

After this line, object cplex is ready to solve the optimization problem defined by model. To solve the model, call:

cplex.solve();

This method returns an IloBool value, where IloTrue indicates that cplex successfully found a feasible (yet not necessarily optimal) solution, and IloFalse indicates that no solution was found. More precise information about the outcome of the last call to the method solve can be obtained by calling:

cplex.getStatus();

The returned value tells you what ILOG 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 proved at this point. Even more detailed information about the termination of the solve call is available through method IloCplex::getCplexStatus.