Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

should we use model.add(expr1 ==expr2) or model.add(expr3==0)?

  • 1.  should we use model.add(expr1 ==expr2) or model.add(expr3==0)?

    Posted Mon December 14, 2020 11:44 AM

    IloExpr expr1(env);
    IloExpr expr2(env);
    IloExpr expr3(env);
    for(int i=0;i<n;i++)
    {
            expr1+=x[i];
    }
    for(int i=0;i<n;i++)
    {
            expr2+=y[i];
    }
    expr3=expr1-expr2;
    model.add(expr1 ==expr2)/model.add(expr3==0);
    expr1.end();
    expr2.end();
    expr3.end();

    when adding the constraint to CPLEX model, should we use model.add(expr1 ==expr2) or use the command model.add(expr3==0)?


    ------------------------------
    Zhaojin LI
    ------------------------------

    #DecisionOptimization


  • 2.  RE: should we use model.add(expr1 ==expr2) or model.add(expr3==0)?

    Posted Fri December 18, 2020 10:17 AM

    Hello,

    It is according to what you prefer.
    Actually CPLEX extracts the model in a same way with the 2 formulations.
    You can check this with exportModel.

    Regards,

    Chris B.



    ------------------------------
    Christiane Bracchi
    ------------------------------