Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  expressions aggregation

    Posted 07/26/12 02:25 PM

    Originally posted by: SystemAdmin


    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.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: expressions aggregation

    Posted 07/27/12 08:06 AM

    Originally posted by: SystemAdmin


    Hello,
    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
    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: expressions aggregation

    Posted 07/27/12 11:40 AM

    Originally posted by: SystemAdmin


    Thank 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!
    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: expressions aggregation

    Posted 07/30/12 12:19 PM

    Originally posted by: ol


    Hello,
    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
    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: expressions aggregation

    Posted 08/20/12 05:03 PM

    Originally posted by: SystemAdmin


    Thanks a lot for your reply here, Olivier! It's been resolved
    #ConstraintProgramming-General
    #DecisionOptimization