Advanced Modeling with IloMPModeler

So far we have only considered the constraints individually as ranged constraints of type IloRange; this is termed a modeling by row approach. However, mathematically the models that can be solved with IloCplex are frequently represented as:

min/max f(x) s.t. L Ax U L x U

where A is a sparse matrix. A sparse matrix is one in which a significant portion of the coefficients are zero, so algorithms and data structures can be designed to take advantage of it by storing and working with the substantially smaller subset of non-zero coefficients.

Objects of type IloLPMatrix are provided for use with IloCplex to express constraint matrices rather than individual constraints . An IloLPMatrix object allows you to view a set of ranged constraints and the variables used by them as a matrix, that is as:L Ax U

Every row of an IloLPMatrix object corresponds to an IloRange constraint, and every column of an IloLPMatrix object corresponds to a modeling variable (an instance of IloNumVar).

An IloLPMatrix object is created with method LPMatrix() defined in IloMPModeler by calling:

  IloLPMatrix lp = cplex.LPMatrix();

(or cplex.addLPMatrix() to immediately add it to the active model). The rows and columns are then added to it by specifying the non-zero matrix coefficients. Alternatively, you can add complete IloRange and IloNumVar objects to it to create new rows and columns. When adding ranged constraints, columns will be implicitly added for all the variables in the constraint expression that do not already correspond to a column of the IloLPMatrix. The IloLPMatrix object will ensure consistency of the mapping of rows to constraints and columns to variables. For example, if a ranged constraint that uses variables not yet part of the IloLPMatrix is added to the IloLPMatrix, new columns will automatically be added and associated to those variables.

See the online ILOG CPLEX Java Reference Manual for more information about IloLPMatrix methods.


Previous Page: Solution Quality  Return to Top Next Page: Modeling by Column