Originally posted by: SystemAdmin
[Stephen.Hill said:]
For others who are interested, I used:
IloNumVarArray chgVariables(env);
IloNumArray chgValues(env);
// set some variables using
IloNumVar variable = variables[(*arcIt).getVariable()];
chgVariables.add(variable);
chgValues.add(weight);
and
if (chgVariables.getSize()>0)
{
IloEnv env = model.getEnv();
IloObjective objective(env);
objective.setLinearCoefs(chgVariables, chgValues);
}
to change the objective coefficients.
To get variable bounds I used:
int variableIndex = (*headSink).getVariableIndex();
IloNumVar variable = variables[variableIndex];
IloRange range(env, variable);
double capacity = range.getUB();
This may seem obvious, but its not very well documented in the manuals IMHO. It still seems odd that I need to store and use a IloNumVarArray variables array to keep track of variables in the problem, and pass it to each of my methods, rather than get them directly from the model each time. Storing variables twice seems inefficient. Or have I missed something?
Stephen
#CPLEXOptimizers#DecisionOptimization