Originally posted by: KristianSchmidt
Hi
I'm trying to traverse a INumExpr that I have built using the Sum and Prod methods. The expression is linear, but since it is built sequentially, it looks like this:
constant1 + a * x + b * x + constant + constant + e * (c * y) + d * y etc. where only x and y are variables.
Normally I would just do (here the variable con is an IRange):
ILinearNumExprEnumerator e = ((ILinearNumExpr)con.Expr).GetLinearEnumerator();
while (e.MoveNext())
{
}
But if I try it with this expression, it says that it cannot cast from CpxLinkedExpr to ILinearNumExpr. Do I need to traverse CpxLinkedExpr in a different way, or can I force cplex to calculate the expression to its shortest form, where it will be a regular linear expression?
Thanks!
#CPLEXOptimizers#DecisionOptimization