Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

How to use forbidstart /end for vacations in the scheduling problem

  • 1.  How to use forbidstart /end for vacations in the scheduling problem

    Posted Wed July 15, 2015 06:55 AM

    Originally posted by: Zenzan


    Hello, 

     

    I was reading the OPL example "sched_calender" which uses step function and forbidden start/end to control the break time among the workers.

    Then I try to build my own one based on this example to control the vacation days among the workers when scheduling the shift roster. Since the time interval will be day in my case, I modified some of the parameters in my model. But the forbidden start/end constraint doesn't work in the solution. The solver still assigns shift to the worker who is on vacation on that day. Can you help me to find out what's going wrong in my model? Thank you!

     

    /****Data****/

    tuple Vacation {
      int sta;        // id of the start day of vacations
      int end;        // id of the end day of vacations
    };

    {Vacation} Vacations[employees] = ...;       // Vacations for each employee

    tuple Step {        
      int y;          // A value represents the employee's availability at a given date (value 0 for on vacation, 100 for available)
      key int x;      // A date represents the day at which the availablity changes its value
    };

    //Describe how the value of availability changes at each point in time where the employee's availablity changes
    //It means that the value 100 lasts until the start date of vacation, and the value 0 lasts until the end date of vacation.
        sorted {Step} Steps[e in employees][d in days] = 
           { <100, v.sta> | v in Vacations[e]: v.sta <= d } union 
           { <0, v.end>   | v in Vacations[e]: v.end >= d };
     
    //Create the intensity values (availability) for each employee which are batched to the interval variable later 
        stepFunction Avail [e in employees][d in days] = 
            stepwise (s in Steps[e][d]) { s.y -> s.x; 100 };

     

    /****Variables****/

    // The roster defines which shift to assign to wich employee on which day

        dvar interval roster[d in days][e in employees][s in shifts] 
        optional 
        intensity Avail [e][d];    


    /****Constraints****/
    subject to {

    // The employee is not available to assign shifts during his/her vacations
        forall (d in days, e in employees, s in shifts) {
            forbidStart (roster[d][e][s], Avail[e][d]);
            forbidEnd  (roster[d][e][s], Avail[e][d]);
        }

     

    And the following part is the example (retrieved from "sched_calender") which I was reading: 

    tuple Vacation {
      int s;
      int e;
    };

    {Vacation} Vacations[employees] = ...; 

    // Set of break steps
    tuple Step {
      int v;
      key int x;
    };
    sorted {Step} Steps[e in employees] = 
       { <100, b.s> | b in Vacations[e] } union 
       { <0, b.e>   | b in Vacations[e] };
       
    stepFunction Calendar[e in employees] = 
      stepwise (s in Steps[e]) { s.v -> s.x; 100 };

     

    dvar interval itvs[h in Houses, t in TaskNames] 
      size      Duration[t]
      intensity Calendar[Worker[t]];

     

      forall(h in Houses) {
        forall(p in Precedences)
          endBeforeStart(itvs[h][p.pre], itvs[h][p.post]);
        forall(t in TaskNames) {
          forbidStart(itvs[h][t], Calendar[Worker[t]]);
          forbidEnd  (itvs[h][t], Calendar[Worker[t]]);
        }
      }

     


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: How to use forbidstart /end for vacations in the scheduling problem

    Posted Thu July 16, 2015 08:14 AM

    Originally posted by: Zenzan


    I've found that the error lies in the measurement unit. The days should be converted into minutes so the solver can understand correctly. However in my model, I can't just simply convert the days into minutes because it will also affect the other parts of the model. Is there any other way to claim the vacation periods (unit: day) for various employees?   


    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: How to use forbidstart /end for vacations in the scheduling problem

    Posted Thu July 16, 2015 08:46 AM

    Originally posted by: ol


    Hello,

     forbidStart and  forbidEnd  only forbid the start or the end of the interval. I suspect you would get what you want by using forbidExtent.

    Regards,

    ol


    #ConstraintProgramming-General
    #DecisionOptimization