Solving the model with IloCplex

Shows how to solve the example.

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

IloCplex(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 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()).