Download presentation
Presentation is loading. Please wait.
Published byFrederick Craig Modified over 9 years ago
1
CONSTRAINT-BASED SCHEDULING AND PLANNING Speaker: Olufikayo Adetunji CSCE 921 4/08/2013Olufikayo Adetunji 1 Authors: Philippe Baptiste, Philippe Laborie, Claude Le Pape, Wim Nuijten CP Handbook, Chapter 22
2
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 2
3
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 3
4
Preliminaries The scheduling task is to allocate known activities to available resources over time respecting capacity, precedence (and other) constraints The planning task is to construct a sequence of actions that will transfer the initial state of the world into a state where the desired goal is satisfied Tasks are not known in advance Constraint-Based Scheduling & Constraint-Based Planning Solving these problems using Constraint Programming (CP) 4/08/2013Olufikayo Adetunji 4
5
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 5
6
CP Model for Scheduling Notations Set of Activities: {A 1, …, A n } Set of Resources: {R 1, …, R m } Scheduling Problem A set of activities has to be processed By a limited number of resources In a limited amount of time 4/08/2013Olufikayo Adetunji 6
7
Example: Bicycle Assembly 3 workers who can perform tasks 10 tasks with its own duration Precedence constraints (T i ‹‹ T j ) T i must be processed before T j No preemption activity cannot be interrupted during processing 4/08/2013Olufikayo Adetunji 7 3 8 2 2 2 8 T 10 T8T8 T6T6 T4T4 T9T9 T5T5 T3T3 T2T2 T7T7 T1T1 7 7 18 T1 T1 T2 T2 T7 T7 T4 T4 T 10 T8 T8 T6 T6 T5 T5 T3 T3 T9 T9 T4 T4 T 10 T8 T8 T6 T6 T5 T5 T3 T3 T9 T9 schedule optimal schedule T1 T1 T2 T2 T7 T7
8
Activity A Activity A is an entity needing some resources & time Variables: start(A), end(A), proc(A) start(A): start time of the activity end(A): completion time of the activity proc(A): processing time (duration) of the activity Domains: [r,d], time interval A which has to execute 4/08/2013Olufikayo Adetunji 8
9
CSP variables & Domains start(A): start time of the activity activity A cannot start before its release date lst(A) = max(start(A)), latest start time est(A) = min(start(A)), earliest start time end(A): completion time of the activity activity Amust finish before the deadline eet(A) = min(end(A), earliest end time lct(A) = max(end(A), latest completion time proc(A): processing time (duration) of the activity 4/08/2013Olufikayo Adetunji 9
10
Terminology Preemptive & non-preemptive activities Disjunctive & cumulative scheduling Temporal constraints Precedence constraints (before, after) Disjunctive constraints (not at the same time) Resources Alternative resources Reservoirs Breakable activities & calendars State resources 4/08/2013Olufikayo Adetunji 10
11
Activities: Types Non-preemptive activity cannot be interrupted: end(A) – start(A) = proc(A) Preemptive activity can be interrupted: end(A) – start(A) ≥ proc(A) proc(A) = proc(A[1]) + proc(A[2]) + proc(A[3]) + proc(A[4]) 4/08/2013Olufikayo Adetunji 11 0 1 2 3 4 5 6 7 8 9 10 A start(A) end(A) p(A) time 0 1 2 3 4 5 6 7 8 9 10 11 12 start(A) end(A) time A[1] A[2] A[3] A[4]
12
Resource Constraints Resources: disjunctive scheduling and cumulative scheduling Disjunctive scheduling: All resources have a unary capacity. i.e., cap(A) = 1 Resources are called machines At most one activity can be executed at a time Cumulative scheduling: Each activity uses some capacity of the resource cap(A) Resources can execute several activities in parallel if the resource capacity is not exceeded 3 2 1 4/08/2013Olufikayo Adetunji 12 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D E A C B D 0 1 2 3 4 5 6 7 8
13
Resource Constraints: disjunctive vs cumulative Disjunctive scheduling All resources have a unary capacity, cap(A) = 1 Resources are called machines At most one activity can be executed at a time Cumulative scheduling Each activity uses some capacity of the resource cap(A) Resources can handle several activities at the same time up to resource capacity 3 2 1 4/08/2013Olufikayo Adetunji 13 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D E A C B D 0 1 2 3 4 5 6 7 8
14
Temporal Constraints Temporal relations between activities expressed by linear constraints between start and end variables of activities Precedence constraint between activities A, B (sequencing A ‹‹ B of activities A,B) end(A) ≤ start(B) Disjunctive constraint: activities A and B cannot overlap A ‹‹ B or B ‹‹ A end(A) ≤ start(B) or end(B) ≤ start(A) 4/08/2013Olufikayo Adetunji 14 0 1 2 3 4 5 6 7 8 9 10 A B time
15
Extensions: Alternative Resources Activity A can be scheduled on any one resource from a set S of resources S is the set of alternative resources for A S is defined by domain variable altern(A) Example: Any of the persons can process a set of tasks. Resources are unrelated Different alternatives can have different costs Disjunctive scheduling ≡ Alternative unary resources Activity can be processed on any of the unary resources Cumulative scheduling ≡ One cumulative resource with resource capacity corresponding to the number of alternative unary resources 4/08/2013Olufikayo Adetunji 15
16
Extensions: Reservoirs Reservoir resource can be consumed and/or produced by activities Activity consumes some quantity of the resource cap(A)<0 Activity produces some quantity of the resource cap(A)>0 Cumulative resource is a special case of reservoir 4/08/2013Olufikayo Adetunji 16 +1
17
Extensions: Other types of resources Breakable activities & calendars Resources are governed by a calendar Calendar consists of breaks and productivity profile under which activities scheduled on the resource are executed State resources Resource of infinite capacity, with varying state over time 4/08/2013Olufikayo Adetunji 17
18
Optimization: Objective Functions Optimization problems optimize an objective function An objective function uses a variable criterion (equals the value of objective function Makespan (criterion): completion time of the last activity Modeling the makespan Introduce L, proc(L) = 0 Add precedence constraint for each T with no successor 4/08/2013Olufikayo Adetunji 18 B D C F E A L
19
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 19
20
Example: Timetabling Problem Create a schedule of N periods for classes with Given durations Given lecturers Given number of enrolled students Prohibited time periods M classrooms with specified seat capacities Where there are sets of classes creating a curriculum No class time overlap within the classes of a curriculum 4/08/2013Olufikayo Adetunji 20
21
Timetabling: Variable and Domains Class = Activity with given duration Start time variable for each class start(A) start(A) = {0, 1, …, N-1} start(A) ≠ prohibited(A) Classrooms = resources Classrooms are ordered by seat capacity: 0 to M-1 Classroom variable for each class resource(A) resource(A) = {K,..., M-1} such that K is the smallest classroom where the class fits by the number of students 4 classrooms with sizes 25, 30, 40, 75 corresponding to 0,1,2,3 class A wants a room with capacity 25: resource(A)={0,1,2,3} class B wants a room with capacity 35: resource(B)={2,3} class C wants a room with capacity 70: resource(C)=3 4/08/2013Olufikayo Adetunji 21
22
Timetabling: Resource Constraints Teacher represents a unary/disjunctive resource a lecturer can teach only one class at a time (no overlap) all classes of each lecturer are constrained by unary resource constraint classes are represented with their start(A) and proc(A) variables Curriculum represents a unary resource classes of one curriculum cannot overlap classes of one curriculum define one unary resource constraint classes are represented with their start(A) and proc(A) variables 4/08/2013Olufikayo Adetunji 22
23
Timetabling: Time & classrooms Constraint: At most one course must be taught at any classroom at each time slot All classrooms together represents one unary resource all classes request this resource each class is encoded by activity with the starting time start-resource(A) = start(A) + resource(A) * N and duration proc(A) 4/08/2013Olufikayo Adetunji 23 0 1 2 3 room s periods Room 0 Room 3Room 2 Room 1
24
Machine scheduling with disjunctive scheduling: Problem & example Given A set of tasks with est, lct, proc Precedence constraints from graph One machine of a unity capacity Question: Create a schedule while minimizing the makespan 4/08/2013Olufikayo Adetunji 24 Task Test(T)lct(T)proc(T) A0102 B0153 C5254 D0201 E10255 F053 B D C F E A
25
Machine scheduling with disjunctive scheduling: Variables Start time variables start(T) for each task T Start(T) = {est(T),..., lct(T)-proc(T)} Example Domains of tasks A={0..8}, B={0..2}, C={5..21}, D={0..19}, E={10..20}, F={0..2} 4/08/2013Olufikayo Adetunji 25 Task Test(T)lct(T)proc(T) A0102 B0153 C5254 D0201 E10255 F053
26
Machine scheduling with disjunctive scheduling: Constraints Precedence constraints for each tasks T1 ‹‹ T2 start(T1) + proc(T1) ≤ start(T2) Example: A+2 ≤ B, B+3 ≤ C, F+3 ≤ E, E+5 ≤ C, D+1 ≤ C, Unary resource for all tasks T given by start time variables start(T) duration p(T) Example: serialized([A,B,C,D,E,F],[2,3,4,1,5,3]) 4/08/2013Olufikayo Adetunji 26 B D C F E A Task Test(T)lct(T)proc(T) A0102 B0153 C5254 D0201 E10255 F053
27
Machine scheduling with disjunctive scheduling: Optimization New task L with proc(L)=0 added Precedence constraints between L and tasks with no successor added Example: C+4 ≤ L 4/08/2013Olufikayo Adetunji 27 B D C F E A L Minimize(makespan) = Minimize(startL)
28
Machine scheduling with disjunctive scheduling: Solution 4/08/2013Olufikayo Adetunji 28 Task Test(T)lct(T)proc(T) A0102 B0153 C5254 D0201 E10255 F053 B D C F E A 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F A D E B C time
29
Machine scheduling with cumulative scheduling: Problem and Example Problem: Create a schedule for several tasks with: earliest start time (est) and latest completion time (lct) processing time proc capacity of resource cap precedence constraints from graph on machine of capacity 3 such that the makespan is minimized. 4/08/2013Olufikayo Adetunji 29 B D C F E A Task Test(T)lct(T)proc(T)cap(T) A01021 B01532 C52542 D02013 E102552 F0532
30
Machine scheduling with cumulative scheduling: Problem & Example 4/08/2013Olufikayo Adetunji 30 B D C F E A Task Test(T)lct(T)proc(T)cap(T) A01021 B01532 C52542 D02013 E102552 F0532 Given A set of tasks with est, lct, proc Capacity of resource cap = 3 Precedence constraints from graph Question: Create a schedule while minimizing the makespan
31
Machine scheduling with cumulative scheduling: Modeling Same model as for scheduling with unary resource with unary resource replaced by cumulative resource Cumulative resource for all tasks T given by start time variables start(T) duration proc(T) requested capacity of the resource Example: cumulative([A,B,C,D,E,F],[2,3,4,1,5,3],[1,2,2,3,2,2],3) 4/08/2013Olufikayo Adetunji 31 Task Test(T)lct(T)proc(T)cap(T) A01021 B01532 C52542 D02013 E102552 F0532
32
Machine scheduling with cumulative scheduling: Solution 4/08/2013Olufikayo Adetunji 32 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F A D E B C time B D C F E A resource capacity Task Test(T)lct(T)proc(T)cap(T) A01021 B01532 C52542 D02013 E102552 F0532
33
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 33
34
Constraint Propagation for Resource Constraints: Unary resources - Notations est(A) earliest start time of activity A ect(A) earliest completion time of activity A lst(A) latest start time of activity A lct(A) latest completion time of activity A Ω is the set of activities p Ω = ∑ A∈Ω p(A) r Ω = min { est ( A ) | A ∈ Ω} d Ω = max { lct ( A ) | A ∈ Ω} 4/08/2013Olufikayo Adetunji 34
35
Unary resources: disjunctive constraint propagation 2 activities A and B, requiring the same unary resource cannot overlap in time. Solution: A ‹‹B ˅ B ‹‹A Ensure no overlap with formula: [end(A) ≤ start(B)] ˅ [end(B) ≤ start(A)] Whenever: d(A) > r(B) ⇒ B <<A d(B) > r(A) ⇒ A <<B 4/08/2013Olufikayo Adetunji 35 If none holds then there is a contradiction
36
Unary resources: Edge-finding What can we notice? How do we fix this? 4/08/2013Olufikayo Adetunji 36 B(6) A(9) B(6) A(9) 3 20 7 3 14 20 7
37
Unary resources: Edge-finding Edge-finding involves deducing that some activity from a given set Ω must, can, or cannot execute first (last) in Ω The basic rules are as follows (for all Ω, and for all A not in Ω): Edge-finding rules p Ω ∪ { A } > d Ω ∪ { A } − r Ω ⇒ A <<Ω A << Ω ⇒ end ( A ) ≤ min {d Ω′ − p Ω′ | Ω′ ⊆ Ω} Edge-finding (symmetrical rules) p Ω ∪ { A } > d (Ω − r Ω ∪ { A } ⇒Ω<< A Ω << A ⇒ start ( A ) ≤ max { r Ω ′ + p Ω′ | Ω′ ⊆ Ω} 4/08/2013Olufikayo Adetunji 37
38
Unary resources: Edge-finding Applying a rule to the example p Ω ∪ { A } > d Ω ∪ { A } − r Ω ⇒ A <<Ω A << Ω ⇒ end ( A ) ≤ min {d Ω′ − p Ω′ | Ω′ ⊆ Ω} 4/08/2013Olufikayo Adetunji 38 B(6) A(9) B(6) A(9) 3 20 7 3 12 20 7 17>(20-7) 12≤(20-6)
39
Unary resources: Not-first and Not-last rules What of this? How do we fix it? 4/08/2013Olufikayo Adetunji 39 A(8) B(5) 3 20 7 C(5) 20 9 A(8) B(5) 3 20 7 C(5) 20 9
40
Unary resources: Not-first and Not-last rules Negative counterpart to edge-finding. Deduces that an activity A cannot be first (or last) to execute in Ω ∪ {A} “not first” rules ( for all Ω, and for all A not in Ω ): p (Ω ∪ { A }) > d Ω − r A ⇒ start ( A ) ≥ min { ect ( B )| B ∈ Ω} “not last” rules ( for all Ω, and for all A not in Ω ): p (Ω ∪ { A }) > d A − r Ω ⇒ end ( A ) ≤ max { lst ( B )| B ∈ Ω} 4/08/2013Olufikayo Adetunji 40
41
Unary resources: Not-first and Not-last rules p (Ω ∪ { A }) > d A − r Ω ⇒ end ( A ) ≤ max { lst ( B )| B ∈ Ω} 18 > (20-7) ⇒ 11 ≤ 15 4/08/2013Olufikayo Adetunji 41 A(8) B(5) 3 12 20 7 C(5) 20 9 A(8) B(5) 3 20 7 C(5) 20 9
42
Constraint Propagation for Resource Constraints: Cumulative resources Each activity uses some capacity of the resource cap(A) Activities can be processed in parallel, if a resource capacity is not exceeded 4/08/2013Olufikayo Adetunji 42
43
Cumulative resources: Timetable Constraint (Example) Initial case Restrictions caused by capacity Solution 4/08/2013Olufikayo Adetunji 43 0 {0,1} 0 r(A) d(A)lst(a) ect(A) X{A,t} 0 {0,1} 0 r(A) d(A)lst(a) ect(A) X{A,t} {0,1} 0 0 0 r(A) d(A)lst(a) ect(A) X{A,t} {0,1 } 1
44
Cumulative resources: Timetable Constraint The timetable is used to maintain information about resource utilization and resource availability over time. Time must be discrete We do not want the capacity to be exceeded ∀ t ∑ cap ( A i ) ≤ MaxCapacity Timetable for activity A is a set of Boolean domain variables X (A, t ) ∀ t ∑ cap ( A i ) ≤ MaxCapacity where, start ( A i ) ≤ t ≤ end(A i ) ⇔ X ( A i, t) 4/08/2013Olufikayo Adetunji 44 start ( A i )≤t≤end (A i ) AiAi
45
Cumulative resources: Disjunctive constraint A and B are activities: min(cap(A)) + min(cap(B)) > MaxCapacity A and B cannot overlap: A ‹‹B ˅ B ‹‹A (disjunctive constraint) [cap(A) + cap(B) ≤ MaxCapacity] ˅ [end(A) ≤ start(B)] ˅ [end(B) ≤ start(A)] 4/08/2013Olufikayo Adetunji 45
46
Cumulative resources: Energy Reasoning Compares the amount of energy provided by a resource over some interval [t 1, t 2 ) to the amount of energy required by activities that have to be processed over this interval i.e., the minimal contribution W Sh (A, t 1, t 2 ) of each activity to a given interval. 4/08/2013Olufikayo Adetunji 46
47
Cumulative resources: Energy Reasoning Given A and [t 1, t 2 ): “Left-Shift/Right-Shift” W Sh (A, t 1, t 2 ) = min(cap(A))*min(t 2 -t 1, p + (t 1 ), p - (t 2 )) t 2 -t 1 : the length of the interval p+(t 1 ) = max(0, p – max(0, t 1 - r)): No of time units during which A executes after time t 1 if A is left-shifted, i.e., scheduled as soon as possible p - (t 1 ) = max(0, p – max(0, d - t 1 )): No of time units during which A executes after time t 1 if A is left-shifted, i.e., scheduled as soon as possible 4/08/2013Olufikayo Adetunji 47
48
Cumulative resources: Energy Reasoning Given A and [t 1, t 2 ): “Left-Shift/Right-Shift” W Sh (A, t 1, t 2 ) = min(cap(A))*min(t 2 -t 1, p + (t 1 ), p - (t 2 )) W Sh (A, 2, 7) = 2 min(5,5,4) = 8 4/08/2013Olufikayo Adetunji 48 rdpmin(cap) A01072 0 1 23 5467 89
49
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 49
50
Conjunctive Reasoning between Temporal and Resources Constraint Propagation techniques that reason on the combination of time bounds of activities on multiple unary resources and the temporal constraints linking these activities Precedence Graph Propagation techniques that reason on the combination of activity time bounds and temporal constraints on one cumulative resource. Energy precedence constraint 4/08/2013Olufikayo Adetunji 50
51
Precedence Graph Maintenance of a temporal network representing the relations between time points of all activities (start and end times) using the point algebra Relations between time points are denoted by: { ≠, =, ≾, ≿, ≺, ≻, ?, ∅ } For example: end(B) ≤ start(A) implies there is a temporal relation in the precedence graph where e(B) ≾ s(A) 4/08/2013Olufikayo Adetunji 51
52
Energy Precedence Constraint Energy precedence propagation for an activity A on a cumulative resource R Ensures that for each subset Φ of predecessor activities of A The resource provides enough energy to execute all activities In Φ between r Φ and s. ∀ Φ ⊆ {B | e B ≾ s A } start(A) ≥ r Φ + ┌E Φ /cap(R k )┐ 4/08/2013Olufikayo Adetunji 52
53
Overview Introduction Preliminaries Constraint Programming Model for Scheduling Activities Resource Constraints Temporal Constraints Extensions Objective Function Examples Timetabling Machine scheduling with disjunctive scheduling Machine scheduling with cumulative scheduling Constraint Propagation for Resource Constraints Unary Resource Cumulative Resource Conjunctive Reasoning between Temporal and Resource Constraint Heuristic Search Conclusion 4/08/2013Olufikayo Adetunji 53
54
Heuristic Search Same principles around search in CP Constraint propagation is not enough Use heuristic search to generate solutions When solution is found, heuristic search will either stop (if solution is ok) or continue (require a lower cost) If continuing, add a constraint that states the need for a solution with a lower cost Multiple criteria ⇒ set of constraints Slow-down some criteria if it improves others Basic heuristic: Focus on the more constrained variables first 4/08/2013Olufikayo Adetunji 54
55
Heuristic Search: Branching Strategy Choosing the right branching strategy depends on the optimization criteria Regular: An optimization criteria to minimize (e.g. makespan) If it increases with the end times of the activities Solution S1 is strictly better than S2 if some activity A finishes earlier in S1 Solve resource constraints by ordering activities On any given branch, the value of criterion obtained by replacing each end time variable by its lower bound is a lower bound for the optimization function. Possibility of the dominance properties 4/08/2013Olufikayo Adetunji 55
56
Heuristic Search: Branching Strategy Choosing the right branching strategy depends on the optimization criteria Sequence-dependent: if it depends only on the relative order in which activities are executed Solve resource constraints by ordering activities The est and ect that result from constraint propagation can be used as a solution Dominance properties cannot be applied After solving, a linear program can be used to determine the optimal solution for the chosen sequences 4/08/2013Olufikayo Adetunji 56
57
Heuristic Search: Local search Very large search spaces Look for “good” solutions Local-search is used by Mixing constraint-based search with Local search (taken as alternative to explore search space) Implementing local search with constraint Local moves considered are “Repair” moves swap two activities scheduled on same machine to shrink or reduce the number of critical paths “Shuffle” moves keep part of the solution and search through the rest of the solution space to complete it 4/08/2013Olufikayo Adetunji 57
58
Heuristic Search: Mixed Integer Programming Hybrid combination of CP and MIP. More efficient in most cases than the individual ones The optimal continuous solution of the linear sub-problem is guaranteed to be integral Solution either satisfies all resource constraints and is optimal; or Violates some resource constraint which can be used to branch on the order of two conflicting activities CP is used to limit and select the explored branches 4/08/2013Olufikayo Adetunji 58
59
Questions and Discussion 4/08/2013Olufikayo Adetunji 59
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.