public interface IloLinearNumExpr extends IloNumExpr
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().| Modifier and Type | Method and Description |
|---|---|
void |
add(IloLinearNumExpr sc)
Adds all the terms found in the scalar product passed as argument to the
invoking object.
|
void |
addTerm(double coef,
IloNumVar var)
Adds the new term
coef * var to a scalar product. |
void |
addTerm(IloNumVar var,
double coef)
Adds the new term
coef * var to a scalar product. |
void |
addTerms(double[] coef,
IloNumVar[] var)
Adds the new terms
sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(double[] coef,
IloNumVar[] var,
int start,
int num)
Adds the new terms
sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(IloNumVar[] var,
double[] coef)
Adds the new terms
sum_i(coef[i] * var[i]) to a scalar product. |
void |
addTerms(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. |
IloLinearNumExprIterator |
linearIterator()
Returns an iterator for the variables in the invoking
IloLinearNumExpr
expression. |
void |
remove(IloNumVar var)
Removes a variable from the invoking
IloLinearNumExpr expression. |
void |
remove(IloNumVar[] var)
Removes variables from the invoking
IloLinearNumExpr
expression. |
void |
remove(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. |
void addTerm(double coef,
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
running time when iterating through the terms of an IloLinearNumExpr.
IloExceptioncoef - The coefficient of the added term.var - The variable of the added term.void addTerm(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
running time when iterating through the terms of an IloLinearNumExpr.
IloExceptionvar - The variable of the added term.coef - The coefficient of the added term.void addTerms(double[] coef,
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
running time when iterating through the terms of an IloLinearNumExpr.
IloExceptioncoef - 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.void addTerms(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
running time when iterating through the terms of an IloLinearNumExpr.
IloExceptionvar - 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.void addTerms(double[] coef,
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
running time when iterating through the terms of an IloLinearNumExpr.
IloExceptioncoef - The coefficients of the added terms.var - The variables of the added terms.void addTerms(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
running time when iterating through the terms of an IloLinearNumExpr.
IloExceptionvar - The variables of the added terms.coef - The coefficients of the added terms.void add(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
running time when iterating through the terms of an
IloLinearNumExpr.
IloExceptionsc - The scalar product expression, the terms of which are added
to the invoking object.void clear()
throws IloException
0
expression behind.IloExceptiondouble getConstant()
throws IloException
IloLinearIntExpr.IloExceptionvoid setConstant(double val)
throws IloException
IloLinearIntExpr
to val.IloExceptionval - The new constant term.void remove(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.IloExceptionvar - The variable to be removed.void remove(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.IloExceptionvar - 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.void remove(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.IloExceptionvar - The array of variables to be removed.IloLinearNumExprIterator linearIterator()
IloLinearNumExpr
expression.