Originally posted by: SystemAdmin
> 1) IloNumVar x(env,ILOFLOAT);
This will result in the creation of a continuous variable with a lowerbound of 2 (x>=2).
This is because the ILOFLOAT is an enum which gets assigned a value of 2 since its Type=Float
The compiler will then try to match the closest constructor for IloNumVar and since the
second argument there is the lowerbound value, hence the result.
> 2) IloNumVar x(env);
This will result in the creation of a continuous variable with a lowerbound of 0 (x>=0).
When no bounds are explicitly mentioned, as in this case, CPLEX assigns a lowerbound of 0
and an upperbound of +IloInfinity. An equivalent call would be IloNumVar x(env,0,IloInfinity,ILOFLOAT);
I would suggest you to use ILOFLOAT only after explicitly specifying the LB and UB values to avoid mismatches.
Also, it might be a good idea to assign a name to the variable for tracking purposes, if you were to
export the model to a human readable LP/MPS format instead of the engine assigning names default names.
One such declaration could look like the following:
IloNumVar x(env,0,IloInfinity,ILOFLOAT,"x");
Hope this helps.
#CPLEXOptimizers#DecisionOptimization