Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Getter/Setter for objective coefficients

    Posted 05/14/14 04:16 AM

    Originally posted by: trebron


    Dear all,

     

    OPL offers the possibility to set the objective-coeeficients by OPL-Script

     for( i in model.idx){
    //     model.getObjective().setCoef(model.x[i],5);
         myCplex.setObjCoef(model.x[i],20);
      }

     

    Is there as well a getter-method for the coefficient, like, e.g.

        model.getObjective().getCoef(model.x[i]);
         myCplex.getObjCoef(model.x[i]);

     

    Cheers,

       Norbert


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Getter/Setter for objective coefficients

    Posted 05/20/14 05:45 AM

    Hi,

    I do not have any nice way in mind but two workaround:

    1)

    Use IloLinearNumExprIterator linearIterator() after an external java call

    2)

    Do a white solve in order to know the coef as in

    dvar float+ Gas;
    dvar float+ Chloride;


    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
      ctMaxTotal2:    
        3 * Gas + 4 * Chloride <= 180;
      ctMaxChloride:  
        Chloride <= 40;
    }

    main
    {
     thisOplModel.Gas.UB=1;
     thisOplModel.Chloride.UB=0;
     thisOplModel.Gas.LB=1;
     thisOplModel.Chloride.LB=0;
     thisOplModel.generate();
     cplex.solve();
     writeln(cplex.getObjValue());
     
    }  
     

    which gives 40

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Getter/Setter for objective coefficients

    Posted 05/20/14 05:56 AM

    Originally posted by: trebron


    Dear Alex,

    many thanks for your reply.

    To me it is surprising that there are setter-Methodsbut no getter-Methods. Changing the coeff can do more harm than just having a look at it ...  Can you put it on the "wish-list"?

    Concerning your workarounds:

    (1)  Seems to fail as well, as the hasNext() method always returns null in that setting, i.e. you can not iterate over the variables.

    (2) Seems to me like 'overkill' in order to obtain the objective coeeficients. That works well for your small example. For more compex problems it is out of scope to wait several hours for the problem to be solved in order to access the objective coefficients.

     

    Best regards

        Norbert


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Getter/Setter for objective coefficients

    Posted 05/20/14 07:31 AM


  • 5.  Re: Getter/Setter for objective coefficients

    Posted 04/19/16 11:38 AM

    Now, the wish is logged at

    https://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=53791

    anyone can vote ...

    And now we have

    getObjCoef
    {number} getObjCoef(dvar)
    Returns the coefficient of a decision variable in the objective expression

    and

    getCoef
    {number} getCoef(ct, dvar)
    returns the coefficient of the variable in the constraint; returns 0 if not mentioned

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer