Skip to main content
FRAMES NO FRAMES

Class IloRange

Definition file: ilconcert/ilolinear.h
Map of IloRangeIloRangeIloRangeIloConstraintIloIntExprArgIloNumExprArgIloExtractable
An instance of this class is a range in a model.

This class models a constraint of the form:

 lowerBound <= expression <= upperBound
 

You can create a range from the constructors in this class or from the arithmetic operators on numeric variables (instances of IloNumVar and its subclasses) or on expressions (instances of IloExpr and its subclasses):

After you create a constraint, such as an instance of IloRange, you must explicitly add it to the model in order for it to be taken into account. To do so, use the member function IloModel::add to add the range to a model and the member function IloAlgorithm::extract to extract the model for an algorithm.

Most member functions in this class contain assert statements. For an explanation of the macro NDEBUG (a way to turn on or turn off these assert statements), see the concept Assert and NDEBUG.

What Is Extracted

All the variables (that is, instances of IloNumVar or one of its subclasses) in the range (an instance of IloRange) will be extracted when an algorithm such as IloCplex, documented in the CPLEX C++ API Reference Manual, extracts the range.

Normalizing Linear Expressions: Reducing the Terms

Normalizing is sometimes known as reducing the terms of a linear expression.

Linear expressions consist of terms made up of constants and variables related by arithmetic operations; for example, x + 3y. In some linear expressions, a given variable may appear in more than one term, for example, x + 3y +2x. Concert Technology has more than one way of dealing with linear expressions in this respect, and you control which way Concert Technology treats linear expressions from your application.

In one mode (the default mode), Concert Technology analyzes linear expressions that your application passes it, and attempts to reduce them so that a given variable appears in only one term in the expression. You set this mode with the member function IloEnv::setNormalizer(IloTrue) .

Certain constructors and member functions in this class check this setting in the model and behave accordingly: they attempt to reduce expressions. This mode may require more time during preliminary computation, but it avoids the possibility of an assertion in some of the member functions of this class failing in the case of duplicates.

In the other mode, Concert Technology assumes that no variable appears in more than one term in any of the linear expressions that your application passes to Concert Technology. We call this mode assume normalized linear expressions. You set this mode with the member function IloEnv::setNormalizer(IloFalse).

Certain constructors and member functions in this class check this setting in the model and behave accordingly: they assume that no variable appears in more than one term in an expression. This mode may save time during computation, but it entails the risk that an expression may contain one or more variables, each of which appears in one or more terms. This situation will cause certain assert statements in Concert Technology to fail if you do not compile with the flag -DNDEBUG.

See Also:

Method Summary
public IloNumExprArggetExpr() const
public IloRangeI *getImpl() const
public IloNumgetLB() const
public IloExpr::LinearIteratorgetLinearIterator() const
public IloExpr::QuadIteratorgetQuadIterator() const
public IloNumgetUB() const
public IloRange()
public IloRange(IloRangeI * impl)
public IloRange(const IloEnv env, IloNum lb, IloNum ub, const char * name=0)
public IloRange(const IloEnv env, IloNum lhs, const IloNumExprArg expr, IloNum rhs=IloInfinity, const char * name=0)
public IloRange(const IloEnv env, const IloNumExprArg expr, IloNum rhs=IloInfinity, const char * name=0)
public IloAddValueToRangeoperator()(IloNum value) const
public voidsetBounds(IloNum lb, IloNum ub)
public voidsetExpr(const IloNumExprArg expr)
public voidsetLB(IloNum lb)
public voidsetLinearCoef(const IloNumVar var, IloNum value)
public voidsetLinearCoefs(const IloNumVarArray vars, const IloNumArray values)
public voidsetUB(IloNum ub)
Inherited Methods from IloConstraint
getImpl, IloConstraint, IloConstraint
Inherited Methods from IloIntExprArg
getImpl, IloIntExprArg, IloIntExprArg
Inherited Methods from IloNumExprArg
getImpl, IloNumExprArg, IloNumExprArg
Inherited Methods from IloExtractable
asConstraint, asIntExpr, asModel, asNumExpr, asObjective, asVariable, end, getEnv, getId, getImpl, getName, getObject, IloExtractable, isConstraint, isIntExpr, isModel, isNumExpr, isObjective, isVariable, removeFromAll, setLocation, setName, setObject
Method Detail

IloRange

public IloRange()
This constructor creates an empty handle. You must initialize it before you use it.

IloRange

public IloRange(IloRangeI * impl)
This constructor creates a handle object from a pointer to an implementation object.

IloRange

public IloRange(const IloEnv env, IloNum lb, IloNum ub, const char * name=0)

This constructor creates an empty range constraint. Before you use this constraint, you must fill the range. The optional argument name is set to 0 by default.

After you create a range constraint, you must explicitly add it to a model in order for it to be taken into account. To do so, use the member function IloModel::add.


IloRange

public IloRange(const IloEnv env, IloNum lhs, const IloNumExprArg expr, IloNum rhs=IloInfinity, const char * name=0)

This constructor creates a range constraint from an expression (an instance of the class IloNumExprArg) and its upper bound (rhs). The default bound for rhs is the symbolic constant IloInfinity. The optional argument name is set to 0 by default.

Note
When it accepts an expression as an argument, this constructor checks the setting of IloEnv::setNormalizer to determine whether to assume the expression has already been reduced or to reduce the expression before using it.

IloRange

public IloRange(const IloEnv env, const IloNumExprArg expr, IloNum rhs=IloInfinity, const char * name=0)

This constructor creates a range constraint from an expression (an instance of the class IloNumExprArg) and its upper bound (rhs). Its lower bound (lhs) will be -IloInfinity. The default bound for rhs is IloInfinity. The optional argument name is set to 0 by default.

Note
When it accepts an expression as an argument, this constructor checks the setting of IloEnv::setNormalizer to determine whether to assume the expression has already been reduced or to reduce the expression before using it.

getExpr

public IloNumExprArg getExpr() const

This member function returns the expression of the invoking IloRange object.


getImpl

public IloRangeI * getImpl() const
This member function returns a pointer to the implementation object of the invoking handle.

getLB

public IloNum getLB() const

This member function returns the lower bound of the invoking range.


getLinearIterator

public IloExpr::LinearIterator getLinearIterator() const

This member function creates and returns an iterator to traverse linear expressions in the invoking range.


getQuadIterator

public IloExpr::QuadIterator getQuadIterator() const

This member function creates and returns an iterator to traverse quadratic expressions in the invoking range.


getUB

public IloNum getUB() const

This member function returns the upper bound of the invoking range.


operator()

public IloAddValueToRange operator()(IloNum value) const

This operator creates the objects needed internally to represent a range in column-wise modeling. See the concept Column-Wise Modeling in CPLEX for an explanation of how to use this operator in column-wise modeling.


setBounds

public void setBounds(IloNum lb, IloNum ub)

This member function sets lb as the lower bound and ub as the upper bound of the invoking range, and it creates the appropriate instance of the undocumented class IloChange to notify algorithms about this change of an extractable object in the model.

Note
The member function setBounds notifies Concert Technology algorithms about this change of this invoking object.

setExpr

public void setExpr(const IloNumExprArg expr)

This member function sets expr as the invoking range, and it creates the appropriate instance of the undocumented class IloChange to notify algorithms about this change of an extractable object in the model.

Note
The member function setExpr notifies Concert Technology algorithms about this change of this invoking object.

setLB

public void setLB(IloNum lb)

This member function sets lb as the lower bound of the invoking range, and it creates the appropriate instance of the undocumented class IloChange to notify algorithms about this change of an extractable object in the model.

Note
The member function setLB notifies Concert Technology algorithms about this change of this invoking object.

setLinearCoef

public void setLinearCoef(const IloNumVar var, IloNum value)

This member function sets value as the linear coefficient of the variable var in the invoking range, and it creates the appropriate instance of the undocumented class IloChange to notify algorithms about this change of an extractable object in the model.

Note
The member function setLinearCoef notifies Concert Technology algorithms about this change of this invoking object.

If you attempt to use setLinearCoef on a non linear expression, it will throw an exception on platforms that support C++ exceptions when exceptions are enabled.


setLinearCoefs

public void setLinearCoefs(const IloNumVarArray vars, const IloNumArray values)

For each of the variables in vars, this member function sets the corresponding value of values (whether integer or floating-point) as its linear coefficient in the invoking range, and it creates the appropriate instance of the undocumented class IloChange to notify algorithms about this change of an extractable object in the model.

Note
The member function setLinearCoefs notifies Concert Technology algorithms about this change of this invoking object.

If you attempt to use setLinearCoef on a non linear expression, it will throw an exception on platforms that support C++ exceptions when exceptions are enabled.


setUB

public void setUB(IloNum ub)

This member function sets ub as the upper bound of the invoking range, and it creates the appropriate instance of the undocumented class IloChange to notify algorithms about this change of an extractable object in the model.

Note
The member function setUB notifies Concert Technology algorithms about this change of this invoking object.