> Languages and APIs > ILOG Concert Technology for Java Users > Modeling by Column

The concept of modeling by column modeling comes from the matrix view of mathematical programming problems. Starting from a (degenerate) constraint matrix with all its rows but no columns, you populate it by adding columns to it. The columns of the constraint matrix correspond to variables.

Modeling by column in ILOG CPLEX is not limited to IloLPMatrix, but can be approached through IloObjective and IloRange objects as well. In short, for ILOG CPLEX, modeling by column can be more generally understood as using columns to hold a place for new variables to install in modeling objects, such as an objective or row. The variables are created as explained in the procedure.

Procedure for Modeling by Column

Start by creating a description of how to install a new variable into existing modeling objects. Such a description is represented by IloColumn objects. Individual IloColumn objects define how to install a new variable in one existing modeling object and are created with one of the IloMPModeler.column methods. Several IloColumn objects can be linked together (with the IloCplex.add method) to install a new variable in all modeling objects 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 by obj with a linear coefficient of 1.0 and in the ranged constraint rng with a linear coefficient of 2.0.

Once the proper column object has been constructed, it can be used to create a new variable by passing it as the first parameter to the variable constructor. The newly created variable will be immediately installed in existing modeling objects as defined by the IloColumn object 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 objective obj 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 first IloColumn parameter. Methods for constructing arrays of variables are also provided for modeling by column. These methods take an IloColumnArray object as a parameter that defines how each individual new variable is to be installed in existing modeling objects.