double objval = cplex.getObjValue(); |
double x1 = cplex.getValue(var1); |
double[] x = cplex.getValues(vars); |
This can now be applied to solving the diet problem we discussed earlier, and printing its solution.
IloCplex cplex = new IloCplex();
IloNumVar[] Buy = new IloNumVar[nFoods];
if ( byColumn ) buildModelByColumn(cplex, data, Buy, varType);
else buildModelByRow (cplex, data, Buy, varType);
System.out.println("Solution status = " + cplex.getStatus());
System.out.println(" cost = " + cplex.getObjValue());
for (int i = 0; i < nFoods; i++) {