Postprocessing solutions
Shows how to initiate the call to postprocessing in your model.
As modeling and solving are two separate phases, the OPL model does not know when a solution is available. Therefore, it does not know when to postprocess that solution, and you have to initiate the call to postprocessing.
Note:
To avoid unexpected behavior, you are recommended to call the postprocess method even if your model does not contain a postprocessing block.
C++
C++: Calling the postprocessing phase
if ( cplex.solve() ) {
cout << endl
<< "OBJECTIVE: " << fixed << setprecision(2) << opl.getCplex().getObjValue()
<< endl;
opl.postProcess();
opl.printSolution(cout);
status = 0;
} else {
cout << "No solution!" << endl;
status = 1;
}
} catch (IloOplException & e) {
cout << "### OPL exception: " << e.getMessage() << endl;
} catch( IloException & e ) {
cout << "### CONCERT exception: ";
e.print(cout);
status = 2;
} catch (...) {
cout << "### UNEXPECTED ERROR ..." << endl;
status = 3;
}
env.end();
cout << endl << "--Press <Enter> to exit--" << endl;
getchar();
return status;
}
Java
Java: Calling the postprocessing phase
if ( cplex.solve() )
{
System.out.println("OBJECTIVE: " + opl.getCplex().getObjValue());
opl.postProcess();
opl.printSolution(System.out);
status = 0;
} else {
System.out.println("No solution!");
status = 1;
}
oplF.end();
.NET (C#)
Visualizing intermediate data
if (cplex.Solve())
{
Console.Out.WriteLine("OBJECTIVE: " + opl.Cplex.ObjValue);
opl.PostProcess();
opl.PrintSolution(Console.Out);
status = 0;
}
else
{
Console.Out.WriteLine("No solution!");
status = 1;
}
oplF.End();