NO FRAMES

Class IloExpr::LinearIterator

Definition file: ilconcert/iloexpression.h
An iterator over the linear part of an expression.

An instance of the nested class IloExpr::LinearIterator is an iterator that traverses the linear part of an expression.

Example

Start with an expression that contains both linear and non linear terms:

IloExpr e = 2*x + 3*y + cos(x);

Now define a linear iterator for the expression:

IloExpr::LinearIterator it(e);

That constructor creates a linear iterator initialized on the first linear term in e, that is, the term (2*x). Consequently, a call to the member function ok returns IloTrue.

it.ok(); // returns IloTrue

A call to the member function getCoef returns the coefficient of the current linear term.

it.getCoef(); // returns 2 from the term (2*x)

Likewise, the member function getVar returns the handle of the variable of the current linear term.

it.getVar(); // returns handle of x from the term (2*x)

A call to the operator++ at this point advances the iterator to the next linear term, (3*y). The iterator ignores nonlinear terms in the expression.

 ++it; // goes to next linear term (3*y)
 it.ok(); // returns IloTrue
 it.getCoef(); // returns 3 from the term (3*y)
 it.getVar(); // returns handle of y from the term (3*y)
 ++it; // goes to next linear term, if there is one in the expression
 it.ok(); // returns IloFalse because there is no linear term
 
Method Summary
public IloNumgetCoef() const
public IloNumVargetVar() const
public IloBoolok() const
public voidoperator++()
Method Detail

getCoef

public IloNum getCoef() const

This member function returns the coefficient of the current term.


getVar

public IloNumVar getVar() const

This member function returns the variable of the current term.


ok

public IloBool ok() const

This member function returns IloTrue if there is a current element and the iterator points to it. Otherwise, it returns IloFalse.


operator++

public void operator++()

This operator advances the iterator to point to the next term of the linear part of the expression.