Hello :)
I have a complex objective function where the final expression is created by the linear aggregation of expressions in the model. That is, lets assume following simplified objective function:
F = e1 + e2 +... where
e1 = x1+x2+...+xi
e2 = min(xj,xk,e') e': could be another linear expression in the model
.
.
Some parts of the objective function expression include min/max. I'm wondering if anybody can shed some lights for expression aggregation since there is no way to cast IloNumExpr to IloLinearNumExpr.
I'm grateful for some help on this topic.
Topic
This topic has been locked.
4 replies
Latest Post
 20120820T21:03:16Z by SystemAdmin
ACCEPTED ANSWER
Pinned topic expressions aggregation
20120726T18:24:39Z

Answered question
This question has been answered.
Unanswered question
This question has not been answered yet.
Updated on 20120820T21:03:16Z at 20120820T21:03:16Z by SystemAdmin

ACCEPTED ANSWER
Re: expressions aggregation
20120727T12:05:33Z in response to SystemAdminHello,
Could you precise your question ?
Why do you need to know whether the type of expression you define is linear or not ? Cannot you just use IloNumExpr ?
By the way, if you are using CPLEX optimizer and not CP Optimizer and if your question is more related to CPLEX modeling, I suggest you post your question on the CPLEX forum here.
Regards,
Philippe
ACCEPTED ANSWER
Re: expressions aggregation
20120727T15:39:31Z in response to SystemAdminThank you for your response here, Philippe! Actually I generate expressions individually for objective function in different steps according to particular patterns in a decision tree in my model. Afterward I sum up these expressions to construct the final expression. So I use IloLinearNumExpr to more easily build up linear expressions in loops. For instance,
IloLinearNumExpr e1,e2,e3
e1.addTerm(5, X[0]);
e1.addTerm(3, X[1]);
e1.addTerm(7, X[2]);
e1.setConstant(10);
e2.addTerm(10, X[6]);
....
e2.addTerm(n, X20);
IloNumExpr e3 = model.min(e1,e2);
...
...
en
and the final expression is the summation of all expressions: F = e1+e2+...+en
what is really needed to build up the final expression is casting IloNumExpr expressions (e.g., e3) to IloLinearNumExpr in the course of iteration to be able to create the final expression in a loop. However, the casting is not plausible. So I'm wondering how we can deal with it!
ACCEPTED ANSWER
Re: expressions aggregation
20120730T16:19:29Z in response to SystemAdminHello,
if I understand your problem, you only need to use the
operator on expressions. For example:+=
IloExpr objExp = IloIntExpr(env, 0); for (IloInt i = 0; i < n; i++) { for (IloInt j = i+1; j < n; j++) { objExp += a[i][j]*cost[i][j]; } }
Regards,
Olivier
ACCEPTED ANSWER
Re: expressions aggregation
20120820T21:03:16Z in response to olThanks a lot for your reply here, Olivier! It's been resolved


