ILOG CPLEX 11.0 User's Manual > Languages and APIs > ILOG Concert Technology for C++ Users > Example: Optimizing the Diet Problem in C++ > Solving the Model with IloCplex

After the model has been populated, it is time to create the cplex object and extract the model to it by calling:

IloCplex cplex(mod); 

It is then ready to solve the model, but for demonstration purposes the extracted model will first be written to the file diet.lp. Doing so can help you debug your model, as the file contains exactly what ILOG CPLEX sees. If it does not match what you expected, it will probably help you locate the code that generated the wrong part.

The model is then solved by calling method solve. Finally, the solution status and solution vector are output to the output channel cplex.out. By default this channel is initialized to cout. All logging during optimization is also output to this channel. To turn off logging, you would set the out stream of cplex to a null stream by calling cplex.setOut(env.getNullStream()).