Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Ranges with variable bounds

  • 1.  Ranges with variable bounds

    Posted Tue May 21, 2013 09:10 AM

    Originally posted by: sonny.plankton


    Hi,

    i have a problem with a range of Days [D] = 1..14 (planning horizon) and a range of Active Days A depending on range

    D. The lower bound of A is d in Days and the upper bound depends on that day d:

    if d <= 9 -> A = d..d+6;

    if d >9    -> A = d..14-d+1;

     

    I´ve tried everything from forall statements to if/else conditions but couln´t find a solution.

     

    It would be terrific, if someone can help me with ideas to model the active day range.

     

    Best regards

    Philipp


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Ranges with variable bounds

    Posted Tue May 21, 2013 11:00 AM

    Hi

    are you sure you did not mean

    if d >9    -> A = 14-d+1..d;

    instead of

    if d >9    -> A = d..14-d+1;

    In that case, I would write

    range Days=1..14;

    {int} activeDays[d in Days]={ i | i in Days :
    (
    (i>=d) && (d<=9) && (i<=d+6) || (i<=d) &&(d>9) && (i<=14-d+1)
    )};

    execute
    {
      activeDays;
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Ranges with variable bounds

    Posted Tue May 21, 2013 03:06 PM

    Originally posted by: sonny.plankton


    Hi Alex,

    thanks a lot for your reply, but your suggestion does not solve my problem. :(

     

    Indeed I mean d..14-d+1. The model comes from a Health Care simulation

    assignment. Patients which come to the hospital in day 12 stay in the hospital

    until the end of the planning horizon (for example). But i see your point. Perhaps

    the assignment means the cardinality of a set of active days.

     

    But if have a decision variable which uses Active days as an index (also given by

    the assignment), but to the best of my knowledge, sets can´t be used as index.

     

    I need something like this:

    range D = 1..14;

    range A[D..9] = d..d+6;

    range A[10..D] = d..14-d+1;

    but i know... it´s a bit to simple.

     

    Would be great if you have further ideas.

     

    Best regards from Munich

     

    Philipp


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Ranges with variable bounds

    Posted Tue May 21, 2013 03:41 PM

    Could

    range Days=1..14;

    {int} activeDays[d in Days]=
    (d<=9)
    ?
    asSet(d..d+6)
    :
    asSet(d..14-d+1);


    execute
    {
      activeDays;
    }  
     

    help ?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Ranges with variable bounds

    Posted Wed May 22, 2013 03:53 AM

    Originally posted by: sonny.plankton


     

    My current approach is

    range D = 1..14;

    range A = 1..14;

    //constraints
      subject to {
       forall (d in D: d<10||d>=10){ 
       forall (w in W, p in P, a in A, s in S){
       sum(w in W) y[w] <= BEDS;   //restriction of number of beds
       sum(p in P, a in A: (d<10)? a <= d+6: a<=14-d+1, w in W) x[p][a] <= y[w]; //restriction number of new patients <= beds assinged to ward
       sum (s in S, a in A: (d<10)? a <= d+6: a<=14-d+1) z[s][a] <= BLOCKS;  //
       sum (s in S, a in A: (d<10)? a <= d+6: a<=14-d+1, p in P) dur[p]*x[p][a] <= z[s][a]*LENGTH;
       LB[p]<=sum (a in A: (d<10)? a <= d+6: a<=14-d+1, p in P) x[p][a] <= UB[p];}      
    }};

     

    with a logical condition (d<10)? and the related if/then expressions to control the sum. But i don´t know why it´s still not working.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Ranges with variable bounds

    Posted Wed May 22, 2013 04:20 AM

    Hi,

    can you attach you model and data ?

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Ranges with variable bounds

    Posted Wed May 22, 2013 04:28 AM

    Originally posted by: sonny.plankton


    Hi,

    yes sure, the model is based on the attached research paper and assignment

     

     

    //Declaration of time range
     range D = 1..14;    //planning horizon
     range S = 1..4;     //surgical groups
     range P = 1..4;     //patient groups
     range W = 1..3;     //wards
     range A = 1..14; //active days range
     
     //Declaration of Parameters
     int SW[W][S]=[[1,2,4],[1,2],[1,3]];    //surgical subgroups (ward specific)
     int PW[W][P]=[[1,2,3],[2,3,4],[2,4]];  //patient subgroups (ward specific)
     int PS[S][P]=[[1,4],[2,4],[3]];     //patient subgroups (surgical specific)
     int r[P] = [2200,4100,1070,600];      //profit values
     int dur[P] = [120,60,160,200];      //surgery duration
     int LB[P] = [10,5,6,2];        //Lower Bound of patients treated
     int UB[P] = [30,15,17,22];    //Upper Bound of patients treated
     int BLOCKS = 5;      //sugery blocks
     int LENGTH = 480;      //block length 
     int BEDS = 100;      //bed capacity
     
     
     //Declaration of decision variables
    dvar int y[W];       //assigned Beds to Wards
    dvar int x[P][A];      //treated patients
    dvar int z[S][A];      //assinged surgery blocks
     
     //Objective Function
     maximize sum (p in P) r[p]* sum (p in P, a in A) x[p][a]; //maximize revenue
     
    //constraints
      subject to {
       forall (d in D){ 
       forall (w in W, p in P, a in A, s in S){
       sum(w in W) y[w] <= BEDS;   //restriction of number of beds
       sum(p in P, a in A: (d<10)? a <= d+6: a<=14-d+1, w in W) x[p][a] <= y[w]; //restriction number of new patients <= beds assinged to ward
       sum (s in S, a in A: (d<10)? a <= d+6: a<=14-d+1) z[s][a] <= BLOCKS;  //restriction of blocks
       sum (s in S, a in A: (d<10)? a <= d+6: a<=14-d+1, p in P) dur[p]*x[p][a] <= z[s][a]*LENGTH; //surgery duration do not exceed block length
       LB[p]<=sum (a in A: (d<10)? a <= d+6: a<=14-d+1, p in P) x[p][a] <= UB[p];}      //treated patiens within lower and upper bounds
    }};

     

    Tanks again for your help


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Ranges with variable bounds

    Posted Wed May 22, 2013 09:42 AM

    Hi

    I think

    dvar int+ y[W];       //assigned Beds to Wards
    dvar int+ x[P][A];      //treated patients
    dvar int+ z[S][A];      //assinged surgery blocks

    would be better


    #DecisionOptimization
    #OPLusingCPLEXOptimizer