| Overview | Group | Tree | Graph | Index | Concepts | 

An instance of this class represents a numeric variable in a model. A
 numeric variable may be either an integer variable or a floating-point
 variable; that is, a numeric variable has a type, a value of the nested
 enumeration IloNumVar::Type. By default, its
 type is Float. It also has a lower and upper bound. A numeric
 variable cannot assume values less than its lower bound, nor greater than
 its upper bound.
If you are looking for a class of variables that can assume only
 constrained integer values, consider the class IloIntVar. If you are looking for a class of binary decision
 variables that can assume only the values 0 (zero) or 1 (one), then consider
 the class IloBoolVar.
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.
Programming Hint
For each enumerated value in the nested enumeration IloNumVar::Type, Concert Technology offers an equivalent
 predefined C++ #define to make programming easier. For example,
 in your applications, you may write either statement:
IloNumVar x(env, 0, 17, IloNumVar::Int); // using the enumeration IloNumVar x(env, 0, 17, ILOINT); // using the #define
IloIntVar or an IloNumVar with Type = Int)
 in the constructors of via a modifier (setUB, setLB,
 setBounds), they are inward rounded to an integer value. LB
 is rounded down and UB is rounded up.See Also:
IloBoolVar, IloIntVar, IloModel, IloNumVarArray, IloNumVar::Type
| Constructor Summary | |
|---|---|
public  | IloNumVar() | 
public  | IloNumVar(IloNumVar::ImplClass *) | 
public  | IloNumVar(const IloEnv, IloNum, IloNum, IloNumVar::Type, const char *) | 
public  | IloNumVar(const IloEnv, IloNum, IloNum, const char *) | 
public  | IloNumVar(const IloAddNumVar &, IloNum, IloNum, IloNumVar::Type, const char *) | 
public  | IloNumVar(const IloEnv, const IloNumArray, IloNumVar::Type, const char *) | 
public  | IloNumVar(const IloAddNumVar &, const IloNumArray, IloNumVar::Type, const char *) | 
public  | IloNumVar(const IloConstraint) | 
| Method Summary | |
|---|---|
public IloNumVar::ImplClass * | getImpl() | 
public IloNum | getLB() | 
public void | getPossibleValues(IloNumArray) | 
public IloNumVar::Type | getType() | 
public IloNum | getUB() | 
public void | setBounds(IloNum, IloNum) | 
public void | setLB(IloNum) | 
public void | setPossibleValues(const IloNumArray) | 
public void | setUB(IloNum) | 
Inherited Methods from IloNumExprArg | 
|---|
getImpl | 
Inherited Methods from IloExtractable | 
|---|
end, getEnv, getId, getImpl, getName, getObject, setName, setObject | 
| Inner Enumeration | 
|---|
| IloNumVar::Type | 
| Constructor Detail | 
|---|
This constructor creates a constrained numeric variable and makes it part
 of the environment env.  By default, the numeric variable
 ranges from 0.0 (zero) to the symbolic constant IloInfinity,
 but you can indicate other upper and lower bounds yourself. By default, the
 numeric variable assumes floating-point values. However, you can constrain
 it to be an integer by setting its type = Int. By default, its
 name is indicated by the empty string, but you can indicate a
 name of your own choice.
This constructor creates a constrained numeric variable and makes it part
 of the environment env.  The bounds of the variable are set by
 lowerBound and upperBound.  By default, its name
 is indicated by the empty string, but you can indicate a name
 of your own choice.
This constructor creates a constrained numeric variable in column format. For more information on adding columns to a model, refer to the concept Column-Wise Modeling.
This constructor creates a constrained discrete numeric variable and
 makes it part of the environment env. The new discrete variable
 will be limited to values in the set indicated by the array
 values. By default, its name is indicated by the empty string,
 but you can indicate a name of your own choice. You can use the member
 function IloNumVar::setPossibleValues with instances
 created by this constructor.
This constructor creates a constrained discrete numeric variable
 from var by limiting its domain to the values indicated in the
 array values. You may use the member function IloNumVar::setPossibleValues with instances created by this
 constructor.
This constructor creates a constrained numeric variable which is equal to
 the truth value of constraint. The truth value of
 constraint is either 0 for IloFalse or 1 for
 IloTrue. You can use this constructor to cast a constraint to a
 constrained numeric variable. That constrained numeric variable can then be
 used like any other constrained numeric variable. It is thus possible to
 express sums of constraints, for example. The following line expresses the
 idea that all three variables cannot be equal:
model.add((x != y) + (y != z) + (z != x) >= 2);
| Method Detail | 
|---|
This member function returns the lower bound of the invoking numeric variable.
This member function accesses the possible values of the invoking numeric
 variable and puts them in the array values.
This member function returns the type of the invoking numeric variable,
 indicating whether it is integer (Int) or floating-point
 (Float).
This member function returns the upper bound of the invoking numeric variable.
This member function sets lb as the lower bound and
 ub as the upper bound of the invoking numeric variable.
setBounds notifies Concert Technology
 algorithms about this change of bounds in this numeric variable.  This member function sets num as the lower bound of the
 invoking numeric variable. 
setLB notifies Concert Technology
 algorithms about this change of bound in this numeric variable.  This member function sets values as the domain of the
 invoking discrete numeric variable. This member function can be called only
 on instances of IloNumVar that have been created with one of
 the two discrete constructors; that is, instances of
 IloNumVar which have been defined by an explicit array of
 discrete values. 
setPossibleValues notifies Concert
 Technology algorithms about this change of domain in this discrete numeric
 variable.  This member function sets num as the upper bound of the
 invoking numeric variable.  
setUB notifies Concert Technology
 algorithms about this change of bound in this numeric variable.  | Inner Enumeration Detail | 
|---|
This nested enumeration enables you to indicate whether an instance of
 IloNumVar is of type integer
 (Int), Boolean (Bool), or floating-point
 (Float).
Programming Hint
For each enumerated value in IloNumVar::Type, there is a
 predefined equivalent C++ #define in the Concert Technology
 include files to make programming easier.  For example, instead of writing
 IloNumVar::Int in your application, you can write
 ILOINT. Likewise, ILOFLOAT is defined for
 IloNumVar::Float and ILOBOOL for
 IloNumVar::Bool.
See Also:
| Fields | 
|---|
| Int | |
| Float | |
| Bool |