|
||||||||||
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
numerical variables of any type.
Objects of type IloLinearNumExpr
represent
linear expressions of the form
sum_{i=1..n} a_i * x_i + c
x_i
are variables of type IloNumVar
and
c
and a_i
are double values.
IloLinearNumExpr
objects are created with methods:
IloModeler.linearNumExpr()
IloModeler.scalProd()
a_i * x_i
can be added;IloLinearNumExpr
object can be
queried as well. The constant term is accessed via method
getConstant()
. The values and variables of the terms
a_i * x_i
are accessed using iterator objects of type
IloLinearNumExpr.Iterator
that can be created using method
linearIterator()
.
IloModeler.linearNumExpr()
,
IloModeler.scalProd(double[], IloNumVar[])
Method Summary | |
void |
add(ilog.concert.IloLinearNumExpr sc)
Adds all the terms found in the scalar product passed as argument to the invoking object. |
void |
addTerm(double coef,
ilog.concert.IloNumVar var)
Adds the new term coef * var to a scalar product. |
void |
addTerm(ilog.concert.IloNumVar var,
double coef)
Adds the new term coef * var to a scalar product. |
void |
addTerms(double[] coef,
ilog.concert.IloNumVar[] var)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(double[] coef,
ilog.concert.IloNumVar[] var,
int start,
int num)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(ilog.concert.IloNumVar[] var,
double[] coef)
Adds the new terms sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(ilog.concert.IloNumVar[] var,
double[] coef,
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. |
double |
getConstant()
Queries the constant term from the invoking IloLinearIntExpr . |
ilog.concert.IloLinearNumExprIterator |
linearIterator()
Returns an iterator for the variables in the invoking IloLinearNumExpr
expression. |
void |
remove(ilog.concert.IloNumVar var)
Removes a variable from the invoking IloLinearNumExpr expression. |
void |
remove(ilog.concert.IloNumVar[] var)
Removes variables from the invoking IloLinearNumExpr
expression. |
void |
remove(ilog.concert.IloNumVar[] var,
int start,
int num)
Removes variables from the invoking IloLinearNumExpr
expression. |
void |
setConstant(double val)
Sets the constant term from the invoking IloLinearIntExpr
to val . |
Method Detail |
public void addTerm(double coef, ilog.concert.IloNumVar var) throws IloException
coef * var
to a scalar product.
The caller must ensure that the variable being added is not yet
part of the invoking IloScalProd
.
If this cannot be asserted, use the method setCoef
instead.
No checks are performed to ensure that the invoking
IloLinearNumExpr
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 IloLinearNumExpr
.
coef
- The coefficient of the added term.var
- The variable of the added term.
IloException
public void addTerm(ilog.concert.IloNumVar var, double coef) throws IloException
coef * var
to a scalar product.
The caller must ensure that the variable being added is not yet part
of the invoking IloScalProd
.
If this cannot be asserted, use the method setCoef
instead.
No checks are performed to ensure that the invoking
IloLinearNumExpr
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 IloLinearNumExpr
.
var
- The variable of the added term.coef
- The coefficient of the added term.
IloException
public void addTerms(double[] coef, ilog.concert.IloNumVar[] var, int start, int num) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
The caller must ensure that the variables being added are not yet part of
the invoking IloScalProd
.
If this cannot be asserted, use the method setCoef
instead.
No checks are performed to ensure that the invoking
IloLinearNumExpr
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 IloLinearNumExpr
.
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.IloNumVar[] var, double[] coef, int start, int num) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
The caller must ensure that the variables being added are not yet part of
the invoking IloScalProd
.
If this cannot be asserted, use the method setCoef
instead.
No checks are performed to ensure that the invoking
IloLinearNumExpr
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 IloLinearNumExpr
.
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(double[] coef, ilog.concert.IloNumVar[] var) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
The caller must ensure that the variables being added are not yet part of
the invoking IloScalProd
.
If this cannot be asserted, use the method setCoef
instead.
No checks are performed to ensure that the invoking
IloLinearNumExpr
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 IloLinearNumExpr
.
coef
- The coefficients of the added terms.var
- The variables of the added terms.
IloException
public void addTerms(ilog.concert.IloNumVar[] var, double[] coef) throws IloException
sum_i(coef[i] * var[i])
to a scalar product.
The caller must ensure that the variables being added are not yet part of
the invoking IloScalProd
.
If this cannot be asserted, use the method setCoef
instead.
No checks are performed to ensure that the invoking
IloLinearNumExpr
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 IloLinearNumExpr
.
var
- The variables of the added terms.coef
- The coefficients of the added terms.
IloException
public void add(ilog.concert.IloLinearNumExpr sc) throws IloException
IloScalProd
.
No checks are performed to ensure that the invoking
IloLinearNumExpr
object does not contain terms with
variables that also appear in the scalar product expression being added.
This method can potentially 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
IloLinearNumExpr
.
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 double getConstant() throws IloException
IloLinearIntExpr
.
IloException
public void setConstant(double val) throws IloException
IloLinearIntExpr
to val
.
val
- The new constant term.
IloException
public void remove(ilog.concert.IloNumVar var) throws IloException
IloLinearNumExpr
expression.
All terms in the invoking linear expression with the specified variable
are removed from the invoking IloLinearNumExpr
object. If
variable var
occurs more than once in the invoking
IloLinearNumExpr
, all occurrences are removed. The
IloLinearNumExpr.Iterator
can be used to remove individual
terms regardless of duplicates.
var
- The variable to be removed.
IloException
public void remove(ilog.concert.IloNumVar[] var, int start, int num) throws IloException
IloLinearNumExpr
expression. All terms in the invoking linear expression having any
variable in var[start], ..., var[start+num-1]
are removed
from the invoking IloLinearNumExpr
object. If variable
var
occurs more than once in the invoking
IloLinearNumExpr
, all occurrences are removed. The
IloLinearNumExpr.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.IloNumVar[] var) throws IloException
IloLinearNumExpr
expression. All terms in the invoking linear expression having any
variable in var[0], ..., var[num-1]
are removed from the
invoking IloLinearNumExpr
object, where num
is
the length of array var
. If variable var
occurs
more than once in the invoking IloLinearNumExpr
, all
occurrences are removed. The IloLinearNumExpr.Iterator
can be used to remove individual terms regardless of duplicates.
var
- The array of variables to be removed.
IloException
public ilog.concert.IloLinearNumExprIterator linearIterator()
IloLinearNumExpr
expression.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |