> Tutorials > Concert Technology Tutorial for Java Users > Building and Solving a Small LP Model in Java > Modeling by Columns |
Modeling by Columns |
INDEX
![]() |
While for many examples population by rows may seem most straightforward and natural, there are some models where population by columns is a more natural or more efficient approach to implement. For example, problems with network structure typically lend themselves well to modeling by column. Readers familiar with matrix algebra may view the method populateByColumn
as the transpose of populateByRow
.
Range objects are created for modeling by column with only their lower and upper bound. No expressions are given; building them at this point would be impossible since the variables have not been created yet. Similarly, the objective function is created only with its intended optimization sense, and without any expression.
Next the variables are created and installed in the existing ranges and objective. These newly created variables are introduced into the ranges and the objective by means of column objects, which are implemented in the class IloColumn
. Objects of this class are created with the methods IloCplex.column
, and can be linked together with the method IloColumn.and
to form aggregate IloColumn
objects.
An IloColumn
object created with the method IloCplex.column
contains information about how to use this column to introduce a new variable into an existing modeling object. For example if obj
is an IloObjective
object, cplex.column(obj, 2.0)
creates an IloColumn
object containing the information to install a new variable in the expression of the IloObjective
object obj
with a linear coefficient of 2.0
. Similarly, for an IloRange
constraint rng
, the method call cplex.column(rng, -1.0)
creates an IloColumn
object containing the information to install a new variable into the expression of rng
, as a linear term with coefficient -1.0
.
When using a modeling by column approach, new columns are created and installed as variables in all existing modeling objects where they are needed. To do this with ILOG Concert Technology you create an IloColumn
object for every modeling object in which you want to install a new variable, and link them together with the method IloColumn.and
. For example, the first variable in populateByColumn
is created like this:
|
The three methods model.column
create IloColumn
objects for installing a new variable in the objective obj
and in the constraints r0
and r1
, with linear coefficients 1.0
, -1.0
, and 1.0
, respectively. They are all linked to an aggregate column object using the method and
. This aggregate column object is passed as the first argument to the method numVar
, along with the bounds 0.0
and 40.0
as the other two arguments. The method numVar
now creates a new variable and immediately installs it in the modeling objects obj
, r0
, and r1
as defined by the aggregate column object. Once installed, the new variable is returned and stored in var[0][0]
.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |