ilog.concert
Interface IloLinearNumExpr


public interface IloLinearNumExpr
extends IloNumExpr

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

where x_i are variables of type IloNumVar and c and a_i are double values. IloLinearNumExpr objects are created with methods:

Once created, integer linear expressions can be fully edited: All the information stored in a 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().

See Also:
IloModeler.linearNumExpr(), IloModeler.scalProd(double[], IloNumVar[])

Inner Class Summary
static interface IloLinearNumExpr.Iterator
          This is the iterator for the linear terms of an IloLinearNumExpr expression object.
 
Method Summary
 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.
 IloLinearNumExpr.Iterator 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.
 

Method Detail

addTerm

public void addTerm(double coef,
                    IloNumVar var)
             throws IloException
Adds the new term 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.

Parameters:
coef - The coefficient of the added term.
var - The variable of the added term.

addTerm

public void addTerm(IloNumVar var,
                    double coef)
             throws IloException
Adds the new term 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.

Parameters:
var - The variable of the added term.
coef - The coefficient of the added term.

addTerms

public void addTerms(double[] coef,
                     IloNumVar[] var,
                     int start,
                     int num)
              throws IloException
Adds the new terms 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.

Parameters:
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.

addTerms

public void addTerms(IloNumVar[] var,
                     double[] coef,
                     int start,
                     int num)
              throws IloException
Adds the new terms 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.

Parameters:
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.

addTerms

public void addTerms(double[] coef,
                     IloNumVar[] var)
              throws IloException
Adds the new terms 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.

Parameters:
coef - The coefficients of the added terms.
var - The variables of the added terms.

addTerms

public void addTerms(IloNumVar[] var,
                     double[] coef)
              throws IloException
Adds the new terms 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.

Parameters:
var - The variables of the added terms.
coef - The coefficients of the added terms.

add

public void add(IloLinearNumExpr sc)
         throws IloException
Adds all the terms found in the scalar product passed as argument to the invoking object. The caller must ensure that the variables being added are not yet part of the invoking 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.

Parameters:
sc - The scalar product expression, the terms of which are added to the invoking object.

clear

public void clear()
           throws IloException
Removes all terms from the invoking linear expression leaving a 0 expression behind.

getConstant

public double getConstant()
                   throws IloException
Queries the constant term from the invoking IloLinearIntExpr.
Returns:
The constant term.

setConstant

public void setConstant(double val)
                 throws IloException
Sets the constant term from the invoking IloLinearIntExpr to val.
Parameters:
val - The new constant term.

remove

public void remove(IloNumVar var)
            throws IloException
Removes a variable from the invoking 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.
Parameters:
var - The variable to be removed.

remove

public void remove(IloNumVar[] var,
                   int start,
                   int num)
            throws IloException
Removes variables from the invoking 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.
Parameters:
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.

remove

public void remove(IloNumVar[] var)
            throws IloException
Removes variables from the invoking 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.
Parameters:
var - The array of variables to be removed.

linearIterator

public IloLinearNumExpr.Iterator linearIterator()
Returns an iterator for the variables in the invoking IloLinearNumExpr expression.