As a modeling object, an instance of ILPMatrix
allows you to treat a set of variables and range constraints (instances of IRange
) as a matrix.
For a list of all members of this type, see ILPMatrix Members.
Objects of this class represent a set of linear constraints of the form L <= A x <= U
, where L
and U
are vectors and A
is a matrix. This modeling object allows you to edit A
directly as a sparse matrix.
Every row of an instance of ILPMatrix
corresponds to an instance of IRange
representing a linear constraint. Every column of this matrix is linked to an INumVar
object. An INumVar
object cannot be linked to more than one column of A
. An IRange
object cannot be linked to more than one row of an ILPMatrix
. The rows of an LP matrix are referenced by integer values, called the row indices, ranging from 0
(zero) to getNrows-1
. Similarly, the columns of an LP matrix are referenced by integer values, called the column indices, ranging from 0
(zero) to getNcols-1
. Nonzero values in the LP matrix correspond to linear coefficients in the range constraints corresponding to its rows. For example, a nonzero coefficient A[i][j]
in row i
and column j
is equivalent to the linear coefficient for the variable corresponding to column j
of the LP matrix in the expression of the range constraint corresponding to row i
of the LP matrix.
Column indices 0 1 2 .... n-1 +--+--+--+--+--+--+ r i 0 | | | | | | | -----> IRange ra; o n +--+--+--+--+--+--+ w d 1 | | | | | | | -----> IRange rb; i +--+--+--+--+--+--+ c . | | | | | | | . e . +--+--+--+--+--+--+ . s . | | | | | | | . +--+--+--+--+--+--+ m-1 | | | | | | | -----> IRange rc; +--+--+--+--+--+--+ | | | | | ... | | | | V V V INumVar x, y, ... z;
Create an instance of ILPMatrix
by calling the method IMPModeler.AddLPMatrix. These methods create an empty instance of ILPMatrix
, that is, an LP matrix with 0 (zero) rows and 0 (zero) columns. Populate the LP matrix by using the methods addRow
, addRows
, addColumn
, and addCols
.
Although you can add multiple ranges (that is, instances of IRange
) and multiple variables (that is, instances of INumVar
) to an instance of ILPMatrix
, it still remains a single modeling object. Any objects of IRange
or INumVar
added to an instance of ILPMatrix
that is subsequently added to an instance of Cplex
are not directly accessible through the methods of Cplex
. For example, consider r1
, an instance of IRange
added to an instance of ILPMatrix
subsequently added to an instance of Cplex
, and r2
, an instance of IRange
added directly to the instance of Cplex
. The range r1
differs from the range r2
; r1
cannot be modified directly by the methods of Cplex
; in contrast, you can use methods of Cplex
to modify r2
.
Namespace: ILOG.Concert
Assembly: ILOG.CPLEX (in ILOG.CPLEX.dll)