public interface IloLPMatrix extends IloConstraint
As a modeling object, an instance of IloLPMatrix allows you to treat a set of
variables and range constraints (instances of IloRange) as a matrix. 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 directly edit A as a sparse matrix.
Every row of an instance of IloLPMatrix corresponds to an instance of
IloRange representing a linear constraint. Every column of this matrix is linked to
an IloNumVar object. One IloNumVar object cannot be linked to more than
one column of A. An IloRange object cannot be linked to more than one
row of an IloLPMatrix. 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 | | | | | | | -----> IloRange ra;
o n +--+--+--+--+--+--+
w d 1 | | | | | | | -----> IloRange rb;
i +--+--+--+--+--+--+
c . | | | | | | | .
e . +--+--+--+--+--+--+ .
s . | | | | | | | .
+--+--+--+--+--+--+
m-1 | | | | | | | -----> IloRange rc;
+--+--+--+--+--+--+
| | |
| | ... |
| | |
V V V
IloNumVar x, y, ... z;
Create an instance of IloLPMatrix by calling the method
IloMPModeler.LPMatrix() or IloMPModeler.addLPMatrix(). These methods
create an empty IloLPMatrix object, that is, an LP matrix with 0 (zero)
rows and 0 (zero) columns. The LP matrix can be populated using methods
addRow, addRows, addColumn, and addCols.
Although you can add multiple ranges (that is, instances of IloRange) and multiple
variables (that is, instances of IloNumVar) to an instance of
IloLPMatrix, it still remains a single modeling object. Any objects of
IloRange or IloNumVar added to an instance of IloLPMatrix
that is subsequently added to an instance of IloCplex are not directly
accessible through the methods of IloCplex. For example, consider r1,
an instance of IloRange added to an instance of IloLPMatrix
subsequently added to an instance of IloCplex, and r2, an instance of
IloRange added directly to the instance of IloCplex. The range
r1 differs from the range r2; r1 cannot be modified
directly by the methods of IloCplex; in contrast, you can use methods of
IloCplex to modify r2.
| Modifier and Type | Method and Description |
|---|---|
int |
getNcols()
Returns the number of columns in the invoking LP matrix.
|
int |
getNrows()
Returns the number of rows in the invoking LP matrix.
|
IloNumVar |
getNumVar(int i)
Returns the variable corresponding to the
i-th column of LP matrix. |
IloNumVar[] |
getNumVars()
Returns an array of variables corresponding to the columns of the LP matrix.
|
IloRange |
getRange(int i)
Returns the ranged constraint corresponding to the
i-th row of the LP matrix. |
IloRange[] |
getRanges()
Returns an array of range constraints corresponding to the rows of the LP matrix.
|
getName, setNameint getNcols()
throws IloException
IloExceptionint getNrows()
throws IloException
IloExceptionIloRange getRange(int i) throws IloException
i-th row of the LP matrix.IloExceptioni - The row index of the ranged constraint to be queried.i.IloRange[] getRanges() throws IloException
IloExceptionIloNumVar getNumVar(int i) throws IloException
i-th column of LP matrix.IloExceptioni - The column index of the variable to be queried.i.IloNumVar[] getNumVars() throws IloException
IloException