12.07.2015 Views

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

IloCplex cplex = new IloCplex();IloNumVar[] Buy = new IloNumVar[nFoods];if ( byColumn ) buildModelByColumn(cplex, data, Buy, varType);else buildModelByRow (cplex, data, Buy, varType);// Solve modelif ( cplex.solve() ) {System.out.println();System.out.println(“Solution status = “ + cplex.getStatus());System.out.println();System.out.println(“ cost = “ + cplex.getObjValue());for (int i = 0; i < nFoods; i++) {System.out.println(“ Buy” + i + “ = “ +cplex.getValue(Buy[i]));}System.out.println();}These lines of code start by creating a new IloCplex object and passing it, along with theraw data in another object, either to the method buildModelByColumn or to the methodbuildModelByRow. The array of variables returned by it is saved as the array Buy. Then themethod solve is called to optimize the active model and, upon success, solutioninformation is printed.Choosing an OptimizerThe algorithm used in the solve methods can be controlled and if necessary tailored to theparticular needs of the model. The most important control is that of selecting the optimizer.For solving the active model, <strong>ILOG</strong> <strong>CPLEX</strong> solves one continuous relaxation or a series ofcontinuous relaxations.◆A single LP is solved if IloCplex.isMIP, IloCplex.isQO, and IloCplex.isQCreturn false. This is the case if the active model does not include:●●●●integer variables, Boolean variables, or semi-continuous variables;special ordered sets (SOS);piecewise linear functions among the constraints; orquadratic terms in the objective function or among the constraints.IloCplex provides several optimizing algorithms to solve LPs. For more about thoseoptimizers, see Solving LPs: Simplex Optimizers on page 171, Solving LPs: BarrierOptimizer on page 197, and Solving Network-Flow Problems on page 217 in this manual.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!