|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An IloLPMatrix
object allows you to treat a set of
range constraints (instances of IloRange
) and variables
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. It allows
you to directly edit A
as a sparse matrix.
Every row of an 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
to
getNrows()-1
. Similarly, the columns of an LP matrix are
referenced by integer values, called the column indices, ranging from
0
to getNcols()-1
. Non-zero values in the LP
matrix correspond to linear coefficients in the range constraints
corresponding to its rows. For example a non-zero 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;
IloLPMatrix
objects are created by calling method
IloMPModeler.LPMatrix()
or
IloMPModeler.addLPMatrix()
. These methods create an empty
IloLPMatrix
object, that is, an LP matrix with 0
rows and 0
columns. The LP matrix can be populated using
methods addRow()
, addRows()
,
addColumn
, and addCols
.
IloMPModeler.LPMatrix()
,
IloMPModeler.addLPMatrix()
Method Summary | |
int |
addCols(ilog.concert.IloNumVar[] var)
Adds new empty columns to LP matrix. |
int |
addCols(ilog.concert.IloNumVar[] var,
int[][] indices,
double[][] values)
Adds new columns to the LP matrix. |
int |
addCols(ilog.concert.IloNumVar[] var,
int start,
int num)
Adds new empty columns to LP matrix. |
int |
addColumn(ilog.concert.IloNumVar var)
Adds a new empty column to an LP matrix. |
int |
addColumn(ilog.concert.IloNumVar var,
int[] ind,
double[] val)
Adds a new column to an LP matrix. |
int |
addRow(double lb,
double ub,
int[] ind,
double[] val)
Adds a new row to the LP matrix. |
int |
addRow(ilog.concert.IloRange rng)
Adds a range constraint as a new row to an LP matrix. |
int |
addRows(double[] lb,
double[] ub,
int[][] ind,
double[][] val)
Adds a set of new rows to LP matrix. |
int |
addRows(ilog.concert.IloRange[] rng)
Adds range constraints as new rows to an LP matrix. |
int |
addRows(ilog.concert.IloRange[] rng,
int start,
int num)
Adds a set of range constraints as new rows to an LP matrix. |
void |
clear()
Removes all rows and columns from invoking LP matrix. |
void |
getCols(int begin,
int num,
int[][] ind,
double[][] val)
Returns columns in a sparse matrix representation. |
int |
getIndex(ilog.concert.IloNumVar var)
Returns the column index corresponding to a variable in the invoking LP matrix. |
int |
getIndex(ilog.concert.IloRange rng)
Returns the row index corresponding to a ranged constraint in the invoking LP matrix. |
int |
getNcols()
Returns the number of columns in the invoking LP matrix. |
int |
getNNZs()
Returns the number of nonzeros in the invoking LP matrix. |
int |
getNrows()
Returns the number of rows in the invoking LP matrix. |
ilog.concert.IloNumVar |
getNumVar(int i)
Returns the variable corresponding to the i -th column of LP
matrix. |
ilog.concert.IloNumVar[] |
getNumVars()
Returns an array of variables corresponding to the columns of the LP matrix. |
double |
getNZ(int row,
int column)
Returns the value of the matrix element row and
col from the invoking LP matrix. |
ilog.concert.IloRange |
getRange(int i)
Returns the ranged constraint corresponding to the i -th row
of the LP matrix. |
ilog.concert.IloRange[] |
getRanges()
Returns an array of range constraints corresponding to the rows of the LP matrix. |
void |
getRows(int start,
int num,
double[] lb,
double[] ub,
int[][] ind,
double[][] val)
Returns rows in a sparse matrix representation. |
void |
removeCols(int[] ind)
Removes a set columns from the invoking LP matrix. |
void |
removeCols(int[] ind,
int start,
int num)
Removes a set of columns from the invoking LP matrix. |
void |
removeCols(int begin,
int num)
Remove a range of columns from the LP matrix. |
void |
removeColumn(int ind)
Removes one column from the LP matrix. |
void |
removeRow(int ind)
Removes one row from the LP matrix. |
void |
removeRows(int[] ind)
Removes a set of rows from the invoking LP matrix. |
void |
removeRows(int[] ind,
int start,
int num)
Removes as set of rows from the invoking LP matrix. |
void |
removeRows(int start,
int num)
Removes a range of rows rows from the LP matrix. |
void |
setNZ(int rowind,
int colind,
double val)
Sets one non-zero of the coefficient matrix of the invoking LP matrix. |
void |
setNZs(int[] rowind,
int[] colind,
double[] val)
Sets non-zero elements of the coefficient matrix of the invoking LP matrix. |
Methods inherited from interface ilog.concert.IloAddable |
getName, setName |
Method Detail |
public int getNcols() throws IloException
IloException
public int getNrows() throws IloException
IloException
public int getNNZs() throws IloException
IloException
public void getCols(int begin, int num, int[][] ind, double[][] val) throws IloException
begin
- The index of the first column being queried.num
- The number of columns being queried.ind
- An array of arrays of integers to where the row
indices of the queried columns will be copied. The
non-zero indices of column begin+i
will be
copied into an array returned as ind[i]
.
This array must be initialized at least to size
num
.val
- An array of arrays of doubles to where the non-zero
coefficients of the queried columns will be copied.
The non-zero values of column begin+i
will be copied
into an array returned as val[i]
. This
array must be initialized to at least size
num
.
IloException
public void getRows(int start, int num, double[] lb, double[] ub, int[][] ind, double[][] val) throws IloException
start
- The index of the first row being queried.num
- The number of rows being queried.lb
- An array where to copy the lower bound values for the
range constraints
corresponding to the queried rows. The lower bound of
the range corresponding to row begin+i
will be returned as lb[i]
. This array
must be allocated at least length num
.ub
- An array where to copy the upper bound values for the
range constraints
corresponding to the queried rows. The upper bound of
the range corresponding to row begin+i
will be returned as ub[i]
. This array
must be allocated at least length num
.ind
- An array of arrays of integers to which the column
indices of the queried rows will be copied. The
non-zero indices of row begin+i
will be
copied into an array returned as ind[i]
.
This array must be initialized to at least size
num
.val
- An array of arrays of doubles to which the non-zero
coefficients of the queried rows will be copied.
The non-zero values of row begin+i
will be
copied into an array returned as val[i]
.
This array must be initialized to at least size
num
.
IloException
public double getNZ(int row, int column) throws IloException
row
and
col
from the invoking LP matrix.
row
- The row index of the matrix element to query.
IloException
public int getIndex(ilog.concert.IloRange rng) throws IloException
-1
is returned.
rng
- Ranged constraint for which to query the row index.
IloException
public ilog.concert.IloRange getRange(int i) throws IloException
i
-th row
of the LP matrix.
i
- The row index of the ranged constraint to be queried.
i
.
IloException
public ilog.concert.IloRange[] getRanges() throws IloException
IloException
public int getIndex(ilog.concert.IloNumVar var) throws IloException
-1
is returned.
var
- The variable whose column index is queried.
var
.
IloException
public ilog.concert.IloNumVar getNumVar(int i) throws IloException
i
-th column of LP
matrix.
i
- The column index of the variable to be queried.
i
.
IloException
public ilog.concert.IloNumVar[] getNumVars() throws IloException
IloException
public int addRow(double lb, double ub, int[] ind, double[] val) throws IloException
The row being added is represented in
sparse matrix notation. That is, the non-zero coefficients of the new row
are given as an array ind
of column indices, and an array of
corresponding values val
. These arrays must match in length.
A new range constraint is implicitly constructed for the added row.
Its lower and upper bound values are provided as parameters
lb
and ub
. The expression of the implicitly
added range constraint is the scalar product of the values specified by
parameter val
and the variables corresponding to the columns
specified by parameter ind
.
lb
- The lower bound for the newly created range constraint
added as a new row to the invoking LP matrix.ub
- The upper bound for the newly created range constraint
added as a new row to the invoking LP matrix.ind
- An array of column indices for the non-zeros of the new
row. An index must appear at most one time, and must be
in the range 0
through
getNcols()-1
.val
- An array of the corresponding values of the non-zeros of
the row to be added.
IloException
public int addRows(double[] lb, double[] ub, int[][] ind, double[][] val) throws IloException
The rows being added are represented in sparse matrix notation. That is, the non-zero coefficients of the new rows are given as arrays of column indices and corresponding arrays of values. Each pair of corresponding arrays must match in length.
For each of the added rows, a new range constraint is implicitly
constructed. The lower and upper bound value of the i
-th
newly created range constraint are provided in parameters
lb[i]
and ub[i]
. Its expression is the scalar
product of the values specified in array val[i]
and the
variables corresponding to the columns specified in array
ind[i]
.
lb
- An array of double values containing the
lower bounds for the range constraints to be
created and added as rows to the invoking LP matrix.ub
- An array of double values containing the
upper bounds for the range constraints to be
created and added as rows to the invoking LP matrix.ind
- An array or arrays of column indices for the non-zeros of
the new rows. An index must appear at most one time
for each new row and must be in the range
0
through getNcols()-1
.val
- An array or arrays of the corresponding values of the
non-zeros of the rows to be added.
IloException
public int addRow(ilog.concert.IloRange rng) throws IloException
IloLPMatrix
, new columns are automatically added as
needed.
rng
- The range constraint that is to become the new row.
IloException
public int addRows(ilog.concert.IloRange[] rng) throws IloException
IloLPMatrix
, new columns are automatically added as
needed.
rng
- The array of range constraints to be added as new rows.
IloException
public int addRows(ilog.concert.IloRange[] rng, int start, int num) throws IloException
IloLPMatrix
, new columns are automatically added as
needed.
rng
- An array containing the range constraints to be added
as new rows.start
- The index of the first range in rng
to be
added as a new row.num
- The number of ranges in rng
to be added as
new rows.
IloException
public void removeRow(int ind) throws IloException
ind
- The index of the row to be removed.
IloException
public void removeRows(int start, int num) throws IloException
start
- The index of the first row to be removed.num
- The number of rows to be removed.
IloException
public void removeRows(int[] ind) throws IloException
ind
.
Rows that are not removed remain in their original order, but they
are assigned new row indices from 0 to getNrows()-1
.
ind
- An array containing row indices of the rows to be
removed.
IloException
public void removeRows(int[] ind, int start, int num) throws IloException
ind[start], ..., ind[start+num-1]
.
Rows that are not removed remain in their original order, but they
are assigned new row indices from 0 to getNrows()-1
.
ind
- An array containing row indices of the rows to be
removed.start
- The first index in ind
of the rows to be
removed.num
- The number of indices in ind
of the
rows to be removed.
IloException
public int addColumn(ilog.concert.IloNumVar var, int[] ind, double[] val) throws IloException
The column being added is represented
in sparse matrix notation. The non-zero coefficients of the new
column are given as an array ind
of row indices, and an array
of corresponding values val
. These arrays must match in
length.
The added column is linked to the variable provided as parameter
var
. This variable must not originally be linked to a column
of the invoking LP matrix.
var
- The variable to be linked with the added column.ind
- An array of row indices of the non-zeros of the new
column. An index must appear at most one time and must
be in the range 0
through
getNrows()-1
.val
- An array of the corresponding values of the non-zeros of
the column to be added.
IloException
public int addColumn(ilog.concert.IloNumVar var) throws IloException
var
. This variable must not originally be linked
to a column of the invoking LP matrix.
var
- The variable to be linked with the new column.
IloException
public int addCols(ilog.concert.IloNumVar[] var, int[][] indices, double[][] values) throws IloException
Adds new columns to the LP matrix.
The columns being added are represented
in sparse matrix notation. That is, the non-zero coefficients of the
j
-th new columns to be added are provided by array
ind[j]
containing the row indices, and by array
val[j]
containing corresponding values. Each pair of
arrays ind[j]
and val[j]
must match in length.
The added columns will be linked to the variables provided as parameter
var
. These variables must not currently be linked to a column
of the invoking LP matrix, nor may a variable be listed more than once in
var
.
var
- An array of variables to be linked to the new columns.
IloException
public int addCols(ilog.concert.IloNumVar[] var) throws IloException
var
. These variables must not currently be linked to a column
of the invoking LP matrix, nor may a variable be listed more than once in
var
.
var
- An array of variables to be linked to the new columns.
IloException
public int addCols(ilog.concert.IloNumVar[] var, int start, int num) throws IloException
var
. These variables must not currently be linked to a column
of the invoking LP matrix, nor may a variable be listed more than once in
var[start], ... var[start+num-1]
.
var
- An array containing the variables to be added as columns.start
- The first variable in var
to be added.num
- The number of variables in var
to be added.
IloException
public void removeColumn(int ind) throws IloException
ind
- The index of the column to be removed.
IloException
public void removeCols(int begin, int num) throws IloException
begin
- The index of the first column to be removed.num
- Number of column to be removed.
IloException
public void removeCols(int[] ind) throws IloException
ind
.
Columns that are not removed remain in their original order but are
assigned new column indices from 0 to getNcols()-1
.
ind
- An array containing the indices of the columns to
be removed.
IloException
public void removeCols(int[] ind, int start, int num) throws IloException
ind[start], ..., ind[start+num-1]
.
Columns that are not removed remain in their original order but are
assigned new column indices from 0 to getNcols()-1
.
ind
- An array containing the indices of the columns to be
removed.start
- The first index in ind
of the columns to
be removed.num
- The number of indices in ind
of the
columns to be removed.
IloException
public void clear() throws IloException
IloException
public void setNZ(int rowind, int colind, double val) throws IloException
rowind
- The row index of the matrix coefficient to be set.colind
- The column index of the matrix coefficient to be set.val
- The value of the matrix coefficient to be set.
IloException
public void setNZs(int[] rowind, int[] colind, double[] val) throws IloException
rowind
- An array containing the row indices of the matrix
coefficients to be set.colind
- An array containing the column indices of the matrix
coefficients to be set.val
- An array containing the values of the new matrix
coefficients to be set.
IloException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |