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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

objects define how to install a new variable in one existing modeling object and are createdwith one of the IloMPModeler.column methods. Several IloColumn objects can belinked together (with the IloCplex.and method) to install a new variable in all modelingobjects in which it is to appear. For example:IloColumn col = cplex.column(obj, 1.0).and(cplex.column(rng, 2.0));can be used to create a new variable and install it in the objective function represented byobj with a linear coefficient of 1.0 and in the ranged constraint rng with a linearcoefficient of 2.0.Once the proper column object has been constructed, it can be used to create a new variableby passing it as the first parameter to the variable constructor. The newly created variablewill be immediately installed in existing modeling objects as defined by the IloColumnobject that has been used. So the line,IloNumVar var = cplex.numVar(col, 0.0, 1.0);creates a new variable with bounds 0.0 and 1.0 and immediately installs it in the objectiveobj with linear coefficient 1.0 and in the ranged constraint rng with linear coefficient 2.0.All constructor methods for variables come in pairs, one with and one without a firstIloColumn parameter. Methods for constructing arrays of variables are also provided formodeling by column. These methods take an IloColumnArray object as a parameter thatdefines how each individual new variable is to be installed in existing modeling objects.Example: Optimizing the Diet Problem in JavaThe problem solved in this example is to minimize the cost of a diet that satisfies certainnutritional constraints. You might also want to compare this approach through the Java APIof <strong>ILOG</strong> <strong>CPLEX</strong> with similar applications in other programming languages:◆ Example: Optimizing the Diet Problem in C++ on page 65◆ Example: Optimizing the Diet Problem in C#.NET on page 107◆ Example: Optimizing the Diet Problem in the Callable Library on page 125This example was chosen because it is simple enough to be viewed from a row as well asfrom a column perspective. Both ways are shown in the example. In this example, eitherperspective can be viewed as natural. Only one approach will seem natural for many models,but there is no general way of deciding which is more appropriate (rows or columns) in aparticular case.The example accepts a filename and two options -c and -i as command line arguments.Option -i allows you to create a MIP model where the quantities of foods to purchase mustbe integers. Option -c can be used to build the model by columns.92 <strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL

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

Saved successfully!

Ooh no, something went wrong!