Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  decision variable

    Posted 04/20/09 07:36 AM

    Originally posted by: SystemAdmin


    [chaomengqing said:]

    HEY~i'm new here but really need your help!

    i have constrains like:
    [i]float a_max=1;
    float a_min=10;

    dvar float+ b;
    dvar float+ over;[/i]

    and i want to use a constrain to choose like:
    [i]if(b>a_max) over ==b-a_max;
    else if(b<a_min) over == a_min-b;
          else over==0;[/i]

    however, as the variable [i]b[/i] will be got also in the same model, i cannot use [i]if[/i] which i really need.
    does anybody know how to deal with this kind of problem?
    Thank you very much!
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: decision variable

    Posted 04/20/09 04:14 PM

    Originally posted by: SystemAdmin


    [jfk said:]

    Hello,
    in your example in the if's there seems to be some confusing logic:
    1. the first condition says if "b>1" is true then you require "over == b-1". OK
    2. after the first "else" the condition is "NOT(b>1) AND b<10" which means "b<=1 AND b<10" which will be true if b<=1. For this condition you would like to have "over == 10-b"; still OK though...<br />3. then after the last "else" the condition is (NOT(NOT(b>1)AND(b<10)) -> b>1 OR b>=10. For this condition you would like to have over == 0;

    so according to no.3 if b>1... then over==0 but according to no.1 if b>1 then over==b-1, which can never happen at the same time. 

    anyway...


    in OPL with the logical operators "=> - implication", "&& - AND", "|| - OR" you can do the following:

    float a_max=1;
    float a_min=10;
    float eps=0.001;

    dvar float+ b;
    dvar float+ over;

    //minimize
    //  b;
    subject to {
      b>=a_max+eps => over == b-a_max;
      b<=a_max && b<=a_min-eps => over == a_min-b;
      b>=a_max+eps || b>=a_min => over ==0;
    }; 


    note: the strict greater (smaller) had to be changed with greater(smaller) or equal so I introduced eps=0.001

    otherwise you have to introduce some indicator variable(s) with bigM and post some constraints. Say t={0,1} integer, and t=1 means the case where
    if b>=a_max+eps then over == b-a_max;

    with "t" you can express this by:
    b>=t*(a_max+eps) -(1-t)*BigMr;
    over>=b-a_max - (1-t)*BigM;
    over<=b-a_max + (1-t)*BigM;<br />
    I hope it helps

    cheers
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: decision variable

    Posted 04/21/09 10:37 AM

    Originally posted by: SystemAdmin


    [chaomengqing said:]

    oh~~i'm so sorry that i've made a mistake...
    the constrains at the front should be:
    [i]a_max=10;
    a_min=1;[/i]

    but~thank you for your help, i'll try now
    #DecisionOptimization
    #MathematicalProgramming-General


  • 4.  Re: decision variable

    Posted 04/21/09 11:17 AM

    Originally posted by: SystemAdmin


    [chaomengqing said:]

    it works~~~really really thank you very much!
    #DecisionOptimization
    #MathematicalProgramming-General