Originally posted by: gkirlik
Dear All,
I have an additional question about this topic. I have already succeed to modify the bounds of the constraints (Thanks for Paul Rubin). I also want to access all coefficients of the imported model's constraints. I can access objective function coefficients and variables by using following code.
cplex.importModel(model, "model.mps");
vector<IloNumVar> varArray;
vector<IloNum> numArray;
for(IloModel::Iterator it(model); it.ok(); ++it)
{
IloExtractable extr = it.operator *();
if (extr.isObjective() == true)
{
IloObjective objective = extr.asObjective();
IloExpr objexpr= objective.getExpr();
for (IloExpr::LinearIterator it2 = objexpr.getLinearIterator(); it2.ok(); ++it2)
{
varArray.push_back(it2.getVar()); //variable
numArray.push_back(it2.getCoef()); //coefficient
}
}
}
Similar to IloObjective, IloRange (rng) has also getExpr() method. After I use this method (IloExpr expr= rng.getExpr()), iterator of the expr object returns IloFalse. So that, I can not access any coefficient or variable of the expr.
How can I access imported model's constraints' coefficients and variables?
#CPLEXOptimizers#DecisionOptimization