|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This is the interface for scalar product expressions for integer variables.
Objects of type IloLinearIntExpr
represent integer
linear expressions of the form
sum_{i=1..n} a_i * x_i + c
x_i
are variables of type IloIntVar
and
c
and a_i
are integer values. Note that the
variable types must be known at compile time for use with
IloLinearIntExpr
. The java type of the variables must be
IloIntVar
and cannot be IloNumVar
with
variable type IloNumVarType.Int
.
IloLinearIntExpr
objects are created with the methods:
IloModeler.linearIntExpr()
IloModeler.scalProd()
a_i * x_i
can be added;IloLinearIntExpr
object can be
queried. The constant term is accessed through the method getConstant()
.
The values and variables of the terms a_i * x_i
are accessed using
iterator objects of type IloLinearIntExpr.Iterator
that
can be created using the method linearIterator()
.
IloModeler.linearIntExpr()
,
IloModeler.scalProd(int[], IloIntVar[])
Method Summary | |
void |
add(ilog.concert.IloLinearIntExpr sc)
Adds all the terms found in the scalar product passed as argument to the invoking object. |
void |
addTerm(ilog.concert.IloIntVar var,
int coef)
Adds the new term coef * var to a scalar product. |
void |
addTerm(int coef,
ilog.concert.IloIntVar var)
Adds the new term coef * var to a scalar product. |
void |
addTerms(ilog.concert.IloIntVar[] var,
int[] coef)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(ilog.concert.IloIntVar[] var,
int[] coef,
int start,
int num)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(int[] coef,
ilog.concert.IloIntVar[] var)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(int[] coef,
ilog.concert.IloIntVar[] var,
int start,
int num)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
clear()
Removes all terms from the invoking linear expression leaving a 0 expression behind. |
int |
getConstant()
Queries the constant term from the invoking IloLinearIntExpr . |
ilog.concert.IloLinearIntExprIterator |
linearIterator()
Returns an iterator for the variables in the invoking IloLinearIntExpr expression. |
void |
remove(ilog.concert.IloIntVar var)
Removes a variable from the invoking IloLinearIntExpr expression. |
void |
remove(ilog.concert.IloIntVar[] var)
Removes a set of variables from the invoking IloLinearIntExpr
expression. |
void |
remove(ilog.concert.IloIntVar[] var,
int start,
int num)
Removes a set of variables from the invoking IloLinearIntExpr
expression. |
void |
setConstant(int val)
Sets the constant term from the invoking IloLinearIntExpr
to val . |
Method Detail |
public void addTerm(int coef, ilog.concert.IloIntVar var) throws IloException
coef * var
to a scalar product.
No checks are performed to verify
that the invoking IloLinearIntExpr
object does not contain
a term with the same variable var
. This method can create
duplicate terms ... + a_i * x + ... + a_k * x + ...
that
could be joined to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
coef
- The coefficient of the added term.var
- The variable of the added term.
IloException
public void addTerm(ilog.concert.IloIntVar var, int coef) throws IloException
coef * var
to a scalar product.
No checks are performed to verify that the invoking
IloLinearIntExpr
object does not contain
a term with the same variable var
. This method can create
duplicate terms ... + a_i * x + ... + a_k * x + ...
that
could be joined to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
var
- The variable of the added term.coef
- The coefficient of the added term.
IloException
public void addTerms(int[] coef, ilog.concert.IloIntVar[] var, int start, int num) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
No checks are performed to verify
that the invoking IloLinearIntExpr
object does not contain
a term with the same variable var
. This method can create
duplicate terms ... + a_i * x + ... + a_k * x + ...
that
could be joined to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
coef
- The coefficients of the added terms.var
- The variables of the added terms.start
- The first element in coef, var
to be added.num
- The number of added terms.
IloException
public void addTerms(ilog.concert.IloIntVar[] var, int[] coef, int start, int num) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
No checks are performed to verify
that the invoking IloLinearIntExpr
object does not contain
terms with the same variable var
. This method can create
duplicate terms ... + a_i * x + ... + a_k * x + ...
that
could be joined to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
var
- The variables of the added terms.coef
- The coefficients of the added terms.start
- The first element in coef, var
to be added.num
- The number of added terms.
IloException
public void addTerms(int[] coef, ilog.concert.IloIntVar[] var) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
No checks are performed to verify
that the invoking IloLinearIntExpr
object does not contain
terms with the same variable var
. This method can create
duplicate terms ... + a_i * x + ... + a_k * x + ...
that
could be joined to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
coef
- The coefficients of added terms.var
- The variables of added terms.
IloException
public void addTerms(ilog.concert.IloIntVar[] var, int[] coef) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
No checks are performed to verify
that the invoking IloLinearIntExpr
object does not contain
terms with the same variable var
. This method can create
duplicate terms ... + a_i * x + ... + a_k * x + ...
that
could be joined to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
var
- The variables of added terms.coef
- The coefficients of added terms.
IloException
public void add(ilog.concert.IloLinearIntExpr sc) throws IloException
No checks are performed to verify that the invoking
IloLinearIntExpr
object does not contain terms with the same
variable var
. This method can create duplicate terms
... + a_i * x + ... + a_k * x + ...
that could be joined
to a single term ... + (a_i + a_k) * x + ...
.
Duplicates do not generate errors but require more memory and more runtime when
iterating through the terms of an IloLinearIntExpr
.
sc
- The scalar product expression, the terms of which are added
to the invoking object.
IloException
public void clear() throws IloException
0
expression behind.
IloException
public int getConstant() throws IloException
IloLinearIntExpr
.
IloException
public void setConstant(int val) throws IloException
IloLinearIntExpr
to val
.
val
- The new constant term.
IloException
public void remove(ilog.concert.IloIntVar var) throws IloException
IloLinearIntExpr
expression.
All terms in the invoking linear expression with the specified variable are
removed from the invoking IloLinearIntExpr
object. If
variable var
occurs more than once in the invoking
IloLinearIntExpr
, all occurrences are removed. The
IloLinearIntExpr.Iterator
can be used to remove individual
terms regardless of duplicates.
var
- The variable to be removed.
IloException
public void remove(ilog.concert.IloIntVar[] var, int start, int num) throws IloException
IloLinearIntExpr
expression. All terms in the invoking linear expression having any
variable in var[start], ..., var[start+num-1]
are removed.
If variable var
occurs more than once in the invoking
IloLinearIntExpr
, all occurrences are removed. The
IloLinearIntExpr.Iterator
can be used to remove individual
terms regardless of duplicates.
var
- The array containing the variables to be removed.start
- The index of the first variable in var
to be removed.num
- The number of variables in var
to be removed.
IloException
public void remove(ilog.concert.IloIntVar[] var) throws IloException
IloLinearIntExpr
expression. All terms in the invoking linear expression having any
variable in var[0], ..., var[num-1]
, where num
is
the length of array var
, are removed from the invoking
IloLinearIntExpr
object. If variable var
occurs
more than once in the invoking IloLinearIntExpr
, all
occurrences are removed. The IloLinearIntExpr.Iterator
can be used to remove individual terms regardless of duplicates.
var
- The array of variables to be removed.
IloException
public ilog.concert.IloLinearIntExprIterator linearIterator()
IloLinearIntExpr
expression. An iterator allows
the caller to enumerate all the terms of an IloLinearIntExpr
and to perform simple operations such as querying or modifying a term.
An iterator also allows the caller to remove elements from the underlying
IloLinearIntExpr
during the iteration with well-defined
semantics.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |