|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An IloLPMatrix
object allows you to
treat a set or range constraints (instances of IloRange
) and
variables as a matrix. Objects of this class represent a set of linear
constraints of the form lhs <= A x <= rhs
, where
lhs
and rhs
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
. 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
c_ij
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.
IloMPModeler.addLPMatrix()
Method Summary | |
int |
addCols(IloNumVar[] var)
Adds new empty columns to LP matrix. |
int |
addCols(IloNumVar[] var,
int[][] indices,
double[][] values)
Adds new columns to the LP matrix. |
int |
addCols(IloNumVar[] var,
int start,
int num)
Adds new empty columns to LP matrix. |
int |
addColumn(IloNumVar var)
Adds a new empty column to LP matrix. |
int |
addColumn(IloNumVar var,
int[] ind,
double[] val)
Adds a new column to LP matrix. |
int |
addRow(double lb,
double ub,
int[] ind,
double[] val)
Adds a new row to LP matrix. |
int |
addRow(IloRange rng)
Adds range constraint as a new row to LP matrix. |
int |
addRows(double[] lb,
double[] ub,
int[][] indices,
double[][] values)
Adds a set of new rows to LP matrix. |
int |
addRows(IloRange[] rng)
Adds range constraints as new rows to LP matrix. |
int |
addRows(IloRange[] rng,
int start,
int num)
Adds range constraints as new rows to LP matrix. |
void |
clear()
Deletes all rows and columns from invoking LP matrix. |
void |
getCols(int begin,
int end,
int[][] ind,
double[][] val)
Returns the queried columns in a sparse matrix representation. |
int |
getIndex(IloNumVar var)
Returns the column index corresponding to a variable in the invoking LP matrix. |
int |
getIndex(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. |
IloNumVar |
getNumVar(int i)
Returns the variable corresponding to the i -th column of LP
matrix. |
IloNumVar[] |
getNumVars()
Returns the 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. |
IloRange |
getRange(int i)
Returns the ranged constraint corresponding to the i -th row
of the LP matrix. |
IloRange[] |
getRanges()
Returns the 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 the queried rows in a sparse matrix representation. |
void |
removeCols(int[] ind)
Removes all columns with column index listed in parameter ind
from the invoking LP matrix. |
void |
removeCols(int[] ind,
int start,
int num)
Removes all columns with column index listed in parameter ind[start], ... ind[start+num-1] from the
invoking LP matrix. |
void |
removeCols(int begin,
int num)
Remove 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 all rows from the invoking LP matrix, with row index listed in parameter ind . |
void |
removeRows(int[] ind,
int start,
int num)
Removes all rows from the invoking LP matrix, with row index listed in parameter ind[start], ... ind[start+num-1] . |
void |
removeRows(int start,
int num)
Removes 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()
public int getNrows()
public int getNNZs() throws IloException
public void getCols(int begin, int end, int[][] ind, double[][] val) throws IloException
begin
- The number of first column being queried.end
- The number of last column being queried.ind
- An array or 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
ind[end-begin+1][]
.val
- An array or arrays of doubles to where the non-zero
coefficients 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
val[end-begin+1][]
.public void getRows(int start, int num, double[] lb, double[] ub, int[][] ind, double[][] val) throws IloException
start
- The index of first row being queried.num
- The number rows being queried.lb
- 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 to
at least
length end-begin+1
.ub
- 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 to at least length
end-begin+1
.ind
- An array or 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 at least to size
ind[end-begin+1][]
.val
- an array or arrays of doubles to which the non-zero
coefficients 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 at least to size
val[end-begin+1][]
.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.col
- The column index of the matrix element to query.public int getIndex(IloRange rng) throws IloException
-1
is returned.public IloRange getRange(int i) throws IloException
i
-th row
of the LP matrix.public IloRange[] getRanges() throws IloException
public int getIndex(IloNumVar var) throws IloException
-1
is returned.var
- The variable whose column index is required.var
.public IloNumVar getNumVar(int i)
i
-th column of LP
matrix.i
.public IloNumVar[] getNumVars()
public int addRow(double lb, double ub, int[] ind, double[] val) throws IloException
var
of column indices, and an array of
corresponding
values val
. Both arrays must match in length.
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 row to the invoking LP matrix.ub
- The upper bound for the newly created range constraint
added as row to the invoking LP matrix.ind
- An array of column indices of 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.public int addRows(double[] lb, double[] ub, int[][] indices, double[][] values) throws IloException
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 by parameter val[i]
and the
variables corresponding to the columns specified by parameter
ind[i]
.lb
- The lower bounds for the newly created range
constraints added as rows to the invoking LP matrix.ub
- The upper bounds for the newly created range
constraints 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.public int addRow(IloRange rng) throws IloException
IloLPMatrix
, new columns will automatically be added as
needed.rng
- The range constraint that is to become the new row.public int addRows(IloRange[] rng) throws IloException
IloLPMatrix
, new columns will automatically be added as
needed.rng
- The array of range constraints to be added as new rows.public int addRows(IloRange[] rng, int start, int num) throws IloException
IloLPMatrix
, new columns will automatically be added as
needed.rng
- The 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.public void removeRow(int ind) throws IloException
ind
- The index of the row to be removed.public void removeRows(int start, int num) throws IloException
start
- The index of the first row to be removed.num
- number of rows to be removed.public void removeRows(int[] ind) throws IloException
ind
. The remaining rows will be kept in the same
order.ind
- an array of row indices of the rows to be removedpublic void removeRows(int[] ind, int start, int num) throws IloException
ind[start], ... ind[start+num-1]
. The
remaining rows will be kept in the same order.ind
- An array of row indices of the rows to be removed.start
- The index of first row index in ind
of the
rows to be removed.start
- The number of row indices in ind
of the
rows to be removed.public int addColumn(IloNumVar var, int[] ind, double[] val) throws IloException
ind
of row indices, and an array of
corresponding values val
. Both arrays must match in length.
The added column will be linked to the variable provided as parameter
var
. This variable must not currently be linked to a column
of the invoking LP matrix.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.public int addColumn(IloNumVar var) throws IloException
var
. This variable must not currently be linked to
a column of the invoking LP matrix.public int addCols(IloNumVar[] var, int[][] indices, double[][] values) throws IloException
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.ind
- An array or arrays of row indices of the non-zeros of
the new columns. An index must appear at most one time
in each column and must be in the range
0
through getNrows()-1
.val
- An array or arrays containing the corresponding values
of the non-zeros of the columns to be added.public int addCols(IloNumVar[] var) throws IloException
var
. This variable 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.public int addCols(IloNumVar[] var, int start, int num) throws IloException
var
. This variable 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.public void removeColumn(int ind) throws IloException
ind
- The index of the column to be removed.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.public void removeCols(int[] ind) throws IloException
ind
from the invoking LP matrix. The remaining columns will be kept in the
same order.ind
- An array of column indices of the columns to be removed.public void removeCols(int[] ind, int start, int num) throws IloException
ind[start], ... ind[start+num-1]
from the
invoking LP matrix. The
remaining columns will be kept in the same order.ind
- An array of column indices of the columns to be removed.start
- The index of first column index in ind
of
the columns to be
removed.num
- The number of column indices in ind
of the
columns to be
removed.public void clear() throws 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.public void setNZs(int[] rowind, int[] colind, double[] val) throws IloException
rowind
- The row indices of the matrix coefficients to be set.colind
- The column indices of the matrix coefficients to be set.val
- The values of the matrix coefficients to be set.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |