Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Set set objective coefficients in cp

  • 1.  Set set objective coefficients in cp

    Posted Thu July 07, 2016 11:08 AM

    Originally posted by: noneless


    Hello all

    How can I return interval variable values which calculated in main block in cp. I mean something like cplex.setObjCoef function in cplex.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Set set objective coefficients in cp

    Posted Thu July 07, 2016 02:03 PM

    Hi,

    you may use setCoef on a constraint where you define the objective:

    using CP;

    dvar int x in 0..10;
    dvar int obj;

    minimize obj;
    subject to
    {
    ctObj:-obj+x==0;
    x==1;
    }

    execute
    {
    writeln(obj);
    }

    main
    {
    thisOplModel.generate();
    cp.solve();
    thisOplModel.postProcess();

    thisOplModel.ctObj.setCoef(thisOplModel.x,2);

    cp.solve();
    thisOplModel.postProcess();

    }

    which gives

    1
    2

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Set set objective coefficients in cp

    Posted Sat July 09, 2016 11:27 AM

    Originally posted by: noneless


    Thanks AlexFleischer

    I did what you said.Now I have faced a new problem.I get a "You can not change the coefficient of an aggregate expression"  error. how can I avoid this error and change the coefficients?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Set set objective coefficients in cp

    Posted Mon July 11, 2016 06:50 AM

    Hi,

    in setCoef documentation you may read

    Changes the coefficient of a decision variable in the invoking constraint. This method is limited to constraints that use simple real linear expressions with no aggregation.

    regards

     


    #DecisionOptimization
    #OPLusingCPOptimizer