Originally posted by: SystemAdmin
[alain.chabrier said:]
Hi,
the IloExpr::LinearIterator should work with all expressions, althought it will only iterate on the linear part.
In your example, you should use IloCos instead of cos.
Then the way to get the iterator is using the getLinearIterator method.
Working code is :
int issue(IloEnv env) {
IloCplex cplex(env);
IloNumVar x(env), y(env);
IloExpr e = 2*x + 3*y + IloCos(x);
IloExpr::LinearIterator it = e.getLinearIterator();
it.ok(); // returns IloTrue
cout << it.getCoef() << endl; // returns 2 from the term (2*x)
cout << it.getVar() << endl;<br />
cplex.end();
return 0;
}
#CPLEXOptimizers#DecisionOptimization