The following statement solves the problem to optimality:
These lines (the action of the if-statement) display the solution:
cout << " Maximum profit = " << cplex.getObjValue() << endl;
for (IloInt i = 0; i < nbMonths; i++) {
IloInt p;
cout << " Month " << i << " " << endl;
cout << " . buy ";
for (p = 0; p < nbProducts; p++) {
cout << cplex.getValue(buy[i][p]) << "\t ";
}
cout << endl;
cout << " . use ";
for (p = 0; p < nbProducts; p++) {
cout << cplex.getValue(use[i][p]) << "\t ";
}
cout << endl;
cout << " . store ";
for (p = 0; p < nbProducts; p++) {
cout << cplex.getValue(store[i][p]) << "\t ";
}
cout << endl;
}
}
else {
cout << " No solution found" << endl;
|
Like other C++ applications using ILOG CPLEX with Concert Technology, this one ends with a call to free the memory used by the environment.