Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

parallel machine scheduling problem

  • 1.  parallel machine scheduling problem

    Posted 01/27/09 07:18 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    I would like to solve a parallel machine scheduling problem using OPL.
    Assume to schedule "n" tasks on "m" machines;
    1. every task may be processed on a subset of all the machines;
    2. between each task and one of its available machine, there are a series of time windows;
    3. the task's span is shorter than one of its alternative time windows, i.e. there is slack time in the time

    window;
    4. the transition time is a function on the neighbouring two processing time of the respective tasks;


    so the problem has to determine:
    -whether a task should be processed;
    -if so, it should be scheduled on which machine, and then which time window;
    -and then the start time in the time window

    the objective is to maximaze the summed weight (every task attaching a positive weight) of all the scheduled tasks.

    i tried to model it using OPL for several days, but got stuck in it.

    Thank you in advance.

    Pei
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: parallel machine scheduling problem

    Posted 01/28/09 12:14 AM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    I realize one of the difficulty lies in the sparsity with respect to the avail subset of all the machines for a certain task.
    If every task can be processed on all the machine, then i can easily model like this:

    dvar interval tasks[i in 1..n] ;
    dvar interval tasksOnMachines[i in 1..n][k in 1..K][q in 1..nbTW[i]] optional;
    dvar sequence machines[k in 1..K] in all(i in 1..n, q in 1..nbTW[i]) tasksOnMachines[i][k][q];

    constraints {
      forall(i in 1..n)
        alternative(tasks[i], all(k in 1..K, q in q.. nbTW[i]) tasksOnMachines[i][k][q]);
      forall(k in 1..K)
        noOverlap(machines[k]);
    };

    but now, tasksOnMachines[i in 1..n][k in specialSubsetsOfMachines][q in 1..nbTW[i]] is hard to describe using OPL;

    who can help me?

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: parallel machine scheduling problem

    Posted 01/28/09 11:40 AM

    Originally posted by: SystemAdmin


    [phlab said:]

    Hello,

    You should define a tuple that models a possible machine m for a task t:

    tuple PossibleAssignment {
      int t;
      int m;
    };

    And use the set of possible machine assignments to index the array of optional interval variables.

    {PossibleAssignment} PossibleAssignments = ...;

    dvar interval tasks[i in 1..n] ;
    dvar interval tasksOnMachines[PossibleAssignments][q in 1..nbTW] optional;
    dvar sequence machines[k in 1..K] in all(p in PossibleAssignments, q in 1..nbTW: p.m==k) tasksOnMachines[p][q];

    constraints {
      forall(i in 1..n)
        alternative(tasks[i], all(p in PossibleAssignments, q in 1.. nbTW: p.t==i) tasksOnMachines[p][q]);
      forall(k in 1..K)
        noOverlap(machines[k]);
    };


    An additional remark: if the time-windows for pairs machine/task have fixed dates it will be much more efficient to avoid modeling them as alternatives (because it adds additional decision variables). You can model them using an array of step functions timewindow[p in PossibleAssignments]. Step function timewindow[p] takes its values in {0,1} (value 1 when the machine can process the task, that is, within the time-windows and 0 when it cannot, that is, outside the time-windows). Then you can use a constraint forbidExtent(tasksOnMachines[p],timewindow[p]) to forbid the interval to overlap a point of the function where the function is zero. For the syntax for defining step functions, see the OPL documentation:
    ILOG OPL Development Studio > Language > Language Reference Manual > OPL, the modeling language > Scheduling > Piecewise linear and stepwise functions

    Philippe

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: parallel machine scheduling problem

    Posted 01/28/09 07:05 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    Thanks!

    I found stepwise function declaration syntax kinds of restricted.

    does it only support declare a stepwise function like this:

    stepFunction F3 = stepwise(i in 0..51, p in 0..1) { 100*p -> (7*i)+(5*p) ; 0 };

    if I attach one step function for each pair between machine and task, then i must let value vector iterate from the start time and end time of every time window, but i think i can not incorporate such complexity in the above declaration sentense.

    What should i do?
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: parallel machine scheduling problem

    Posted 01/28/09 07:21 PM

    Originally posted by: SystemAdmin


    [phlab said:]

    Assuming the set of time windows is defined as a set of tuples:

    tuple TimeWindow { int start; int end; }
    {TimeWindow} TWindows = { <10,21>, <33,36>, <41,52> };


    Then, you can create a sorted set of function steps (Steps) and use it to build the function:

    tuple FunctionStep { int time; int value; }
    sorted { FunctionStep } Steps = { <w.start,0> | w in TWindows } union {<w.end,1> | w in TWindows};
    stepFunction F = stepwise(s in Steps) { s.value -> s.time; 0 };


    The built function F will be:

    stepwise{ 0 -> 10; 1 -> 21; 0 -> 33; 1 -> 36; 0 -> 41; 1 -> 52; 0 }

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: parallel machine scheduling problem

    Posted 01/28/09 07:46 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    thank you very much!

    I have one more question, if there is time slack in every time window, that is, the start time of the task has some candidate positions in a certain time window, then how can i get the start time information from the model using stepwise funtions for time windows?
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: parallel machine scheduling problem

    Posted 01/28/09 07:52 PM

    Originally posted by: SystemAdmin


    [phlab said:]

    The start time information will be the start of the task that is: startOf(tasks[i ]). I'm probably missing something, do you need more than that? Do you have constraints on the position of the task within a time-window that depends on the time-window?
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: parallel machine scheduling problem

    Posted 01/28/09 09:39 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    The task processing time should be within a chosen time window, what's more, the transition time of two consecutive tasks on one machine  depends on the exact position of the two neighboring tasks in their respective time windows.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: parallel machine scheduling problem

    Posted 01/29/09 11:53 AM

    Originally posted by: SystemAdmin


    [phlab said:]

    The task processing time should be within a chosen time window...

    Do you mean you have a range of values [ptmin,ptmax] for the processing time of the task? In this case, you can specify it at the construction of the task interval:

    dvar interval tasks[i in 1..n] size in ptmin[i]..ptmax[i];

    Or do you mean that the task should be completely processed within a single time-window, that is, it cannot overlap two time-windows. In this case, the forbidExtent constraint should do it.

    ... what's more, the transition time of two consecutive tasks on one machine  depends on the exact position of the two neighboring tasks in their respective time windows.

    What is the exact definition of this transition time? Does it hold only on the set of tasks executed in the same time-window or also between consecutive tasks in different time-windows? If you could formalize a little bit more this concept of transition time, that would help.

    Philippe
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 10.  Re: parallel machine scheduling problem

    Posted 01/29/09 12:50 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    each task has a group of alternative time windows, and the task's processing time span is a prior, so are the start time and end time of every time window. for example,
    tuple PossibleAssignment
    {
      int machine;
      int task;
      int cnTW;//the number of time windows between task and machine, may be different on different machines
      int processSpan; // the processing time is a constant, but may be different on different machines for one task
    }

    tuple TimeWindow
    {
      int machine;
      int task;
      int indexOfTW; // indexOfTW == 1..cnTW for the related subset of TimeWindows for a possibleAssignment
      int start time;
      int end time; //processSpan of the relative task is usually less than (end time-start time), so we have to identify the start time of the task in a chosen time window
    }

    and each task must choose one time window from its alternative time windows, and therefore must be completely processed within the chosen time window.

    With regard to the transition time, we can use the following simplified formulation:

    assume task[1] and task[2] are consecutive tasks on machine[1];
    and task[1] finally chooses its time window <10, 20>; while task[2] chooses its time window <30, 42>;
    and the processing span of task[1] is 4 while task[2] 6;
    we define
    offset[task] = the processing middle position - related time window middle position
    assume task[1] finally starts at 10, and end at 10+4=14, then
    offset[task[1]] = (10+4/2) - (10+ (20-10)/2) = 12 - 15 = -3
    assume task[2] processes from 35 to 41, then
    offset[task[2]] = (35+3) - (30+6) = 2;

    then the transition time of the two consecutive tasks is a stepwise function of the difference between the two offsets:

    transition time =
    - high value v1 if difference is above a threshold t1, e.g. v1 =10, t1=4 , so for the example above , the transition time will be 10 because the offset difference is 2-(-3) = 5>4;
    - middle value v2 if difference is between  threshold t1 and  t2,
    - low value v3 if difference is below threshold t3.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 11.  Re: parallel machine scheduling problem

    Posted 01/29/09 01:24 PM

    Originally posted by: SystemAdmin


    [phlab said:]

    Thanks for the detailed description, it's very clear. This transition time does not seem trivial to model without defining a large number of variables. Do you have an idea of the typical size of the problem (number of tasks, of machines, of possible assignments (tasks/machine), of time-window per machine)?

    Philippe
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 12.  Re: parallel machine scheduling problem

    Posted 01/29/09 03:41 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    the problem scale could be hundreds of tasks, dozens of machines; between each machine and each task, there should be 1-3 time windows when the planning horizon is one day large, each task could be processed by at least half of all the machines. Time window could be twice larger than the related task processing span.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 13.  Re: parallel machine scheduling problem

    Posted 01/30/09 02:06 PM

    Originally posted by: SystemAdmin


    [phlab said:]

    I think you cannot directly model your transition time using the notion of transition distance of the noOverlap constraint in OPL because your transition time does not only depend on some interval types on the sequence.

    There are two possibilities: (1) either you simplify the transition time further on so that it can be modeled in OPL without creating new decision variables in your problem or (2) you model it exactly but that will imply creating a large number of additional interval variables (quadratic with the number of intervals on the machines!). I will try to sketch the two approaches.

    1. Simplifying the transition time.

    For a given pair (task1,window1), (task2,window2) on a machine, I'll denote tt(t1,t2) the transition time function computed using your description where t1 and t2 are respectively the start values of task1 and task2 in their window.
    And I will denote window1=[sw1,ew1], window2=[sw2,ew2].

    A few ideas:

    - for a given pair (task1,window1), (task2,window2) on a machine, you could pre-compute the minimal value of the minimal delay d12 that must elapse between the end of task 1 and the start of task 2 if they are executed respectively in the windows window1 and window2 and consecutively on the resource:

    d12 = min (t1 in sw1..ew1-pt1, t2 in sw2..ew2-pt2: t1+pt1<=t2) max(t2-(t1+pt1), tt(t1,t2))<br />
    Maybe this lower bound on the delay between the two tasks can be tight enough, especially if the two time-windows overlap and, as this delay only depends on the pairs (task1,window1), (task2,window2) it could be expressed as a transition distance.

    - also, if the set of time-windows on a resource are quite separated and do not overlap a lot, you could directly add precedence constraints between the tasks that belongs to two non-overlapping time-windows with a delay expression computed using the tasks start/end times and your exact function.

    The two cases above suppose that the transition time satisfies the triangular inequality that is, if task1 is scheduled before task2 and task2 before task 3 on the resource, then transition(task1,task3) >= transition(task1,task2)+duration(task2)+transition(task2,task3).

    - in general, if the objective is to schedule the tasks "as close as possible" to the middle of the time-window, you could also consider adding some kind of earliness/tardiness cost with respect to this "ideal date" in the window.

    2. Modeling the problem with a quadratic number of intervals

    The idea, if you have n intervals (acts[i in 1..n]) in a sequence is to create a set of n additional chained intervals (chain[p in 1..n]) that represent the final sequence: one interval for each position in the sequence. Then, you need additional n^2 intervals (!) actAtPos[i ][p] that represent the possible position p in the chain for a given activity i. Activity acts[i ] is an alternative over all its possible positions in the sequence and chain[p] is an alternative over all the activities at position p. Then, you can express the transition time as a delay for the precedence constraint between two consecutive intervals in the chain. I attach a code sample where the transition time between two consecutive intervals i and j is the end time of i modulo 5.


    using CP;

    int n=10;
    int ptmin=1;
    int ptmax=n;

    dvar interval acts[i in 1..n] size i;
    dvar interval chain[p in 1..n] size ptmin..ptmax;
    dvar interval actAtPos[i in 1..n][p in 1..n] optional;

    minimize max(i in 1..n) endOf(acts[i]);
    constraints {
      forall(p in 2..n)
        endBeforeStart(chain[p-1],chain[p],endOf(chain[p-1])%5);
      forall(i in 1..n)
        alternative(acts[i], all(p in 1..n)actAtPos[i][p]);
      forall(p in 1..n)
        alternative(chain[p], all(i in 1..n)actAtPos[i][p]);
      noOverlap(acts);
    }


    But this can scale only for a few ten of intervals.

    In your case, intervals acts[i ] are optional because they are themselves member of some alternatives and as a consequence, you do not know the number of intervals in the chain. You can define them as optional and add the constraint that only the first ones will be present: presenceOf(chain[p])=>presenceOf(chain[p-1]). You can of course decrease the number of intervals in the chain in case you have an upper bound on the final number of intervals on the resource.

    Given your figures, I don't think it will scale on the complete problem but you could maybe run a first phase using a relaxed or approximated version of the problem (see above) and for instance keep the resource allocation for tasks or even the resource/windows allocations and run this second step with a smaller number of intervals on each resource.

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 14.  Re: parallel machine scheduling problem

    Posted 02/01/09 05:46 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    Thank you very much for your insight and instruction!

    I still have something unclear.

    For the first idea, how could i precompute lower bound d12 when it seems unpractical to enumerate all the possible t1 and t2, since the minmax problem is  usually hard in Optimization.

    With regard to the second idea, does it apply to a very extreme circumstance where the n to-be-scheduled intervals overlap a lot, even could share a same scheduling horizon as their respectively big time window?
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 15.  Re: parallel machine scheduling problem

    Posted 02/02/09 12:19 PM

    Originally posted by: SystemAdmin


    [phlab said:]

    For the first idea, I think that you do not need to enumerate the times. I didn't think about it in detail but you can exploit the fact the function that gives the transition time has a limited number of steps. For a given step of the function you have a value v for the transition time and a range on the offset difference. From that, I guess you can split the time-windows of the two tasks into a few sub-time-windows for which the minimal transition time is given either by start2-(start1+pt1) or by one of the value of the step function.

    For the second idea, it is completely general and does not assume anything on time-windows. It just pre-computes a chain of interval variables that represents the value of the sequence variable and the alternative constraints allow mapping the interval in the sequence on the intervals in the chain.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 16.  Re: parallel machine scheduling problem

    Posted 02/02/09 12:52 PM

    Originally posted by: SystemAdmin


    [hidedeep2008 said:]

    Thanks!

    For the second idea, how can i incorporate the transition time in the formulation?  I noticed from the following sentence that I still have to replace "endOf(chain[p-1])%5" with my special transition time. Am i right?

    endBeforeStart(chain[p-1],chain[p],endOf(chain[p-1])%5);


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 17.  Re: parallel machine scheduling problem

    Posted 02/02/09 01:11 PM

    Originally posted by: SystemAdmin


    [phlab said:]

    [quote author=hidedeep2008 link=topic=876.msg2633#msg2633 date=1233568304]
    Thanks!

    For the second idea, how can i incorporate the transition time in the formulation?  I noticed from the following sentence that I still have to replace "endOf(chain[p-1])%5" with my special transition time. Am i right?

    endBeforeStart(chain[p-1],chain[p],endOf(chain[p-1])%5);


    Yes you need to replace it with your transition time. But here, you directly can manipulate the start/end of consecutive intervals in the sequence and, thanks to the boolean status (presenceOf) of the interval variables actAtPos[i ][p], you know the task/resource/time-window that is executed at position p.
    #DecisionOptimization
    #OPLusingCPOptimizer