Presentation is loading. Please wait.

Presentation is loading. Please wait.

Event Scheduling Using Constraint Programming November 22, 2002 Martin Henz, School of Computing, NUS www.comp.nus.edu.sg/~henz/sma2002.

Similar presentations


Presentation on theme: "Event Scheduling Using Constraint Programming November 22, 2002 Martin Henz, School of Computing, NUS www.comp.nus.edu.sg/~henz/sma2002."— Presentation transcript:

1 Event Scheduling Using Constraint Programming November 22, 2002 Martin Henz, School of Computing, NUS www.comp.nus.edu.sg/~henz/sma2002

2 SMA / CS © NUS 20022 Overview  Constraint programming in a nutshell  Elements of constraint programming  Sport tournament scheduling  Production scheduling  Assessment

3 SMA / CS © NUS 20023 Overview  Constraint programming in a nutshell  Elements of constraint programming  Sport tournament scheduling  Production scheduling  Assessment

4 SMA / CS © NUS 20024 Constraint Programming in a Nutshell SEND MORE MONEY

5 SMA / CS © NUS 20025 Constraint Programming in a Nutshell SEND + MORE = MONEY

6 SMA / CS © NUS 20026 SEND + MORE = MONEY Assign distinct digits to the letters S, E, N, D, M, O, R, Y such that S E N D + M O R E = M O N E Y holds.

7 SMA / CS © NUS 20027 SEND + MORE = MONEY Assign distinct digits to the letters S, E, N, D, M, O, R, Y such that S E N D + M O R E = M O N E Y holds. Solution 9 5 6 7 + 1 0 8 5 = 1 0 6 5 2

8 SMA / CS © NUS 20028 Modeling Formalize the problem as a constraint problem:  n variables  m constraints: c 1,…,c m   n  problem: Find a = (v 1,…,v n )   n such that a  c i, for all 1  i  m

9 SMA / CS © NUS 20029 A Model for MONEY  8 variables: {S,E,N,D,M,O,R,Y}  5 constraints: c 1 = {(S,E,N,D,M,O,R,Y)   8 | 0  S,…,Y  9 } c 2 = {(S,E,N,D,M,O,R,Y)   8 | 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y}

10 SMA / CS © NUS 200210 A Model for MONEY (continued)  more constraints c 3 = {(S,E,N,D,M,O,R,Y)   8 | S  0 } c 4 = {(S,E,N,D,M,O,R,Y)   8 | M  0 } c 5 = {(S,E,N,D,M,O,R,Y)   8 | S…Y all different }

11 SMA / CS © NUS 200211 Solution for MONEY c 1 = {(S,E,N,D,M,O,R,Y)   8 | 0  S,…,Y  9 } c 2 = {(S,E,N,D,M,O,R,Y)   8 | 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y} c 3 = {(S,E,N,D,M,O,R,Y)   8 | S  0 } c 4 = {(S,E,N,D,M,O,R,Y)   8 | M  0 } c 5 = {(S,E,N,D,M,O,R,Y)   8 | S…Y all different } Solution: (9,5,6,7,1,0,8,2)   8

12 SMA / CS © NUS 200212 Constraint Programming  Choose propagation algorithms  all different: “singleton wakeup”  sum: “interval consistency”  Choose branching algorithms  “first-fail”  Choose exploration algorithms  “depth-first search” Exploiting constraints during tree search

13 SMA / CS © NUS 200213 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y S   E   N   D   M   O   R   Y  

14 SMA / CS © NUS 200214 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y S  {0..9} E  {0..9} N  {0..9} D  {0..9} M  {0..9} O  {0..9} R  {0..9} Y  {0..9} Propagate

15 SMA / CS © NUS 200215 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y S  {1..9} E  {0..9} N  {0..9} D  {0..9} M  {1..9} O  {0..9} R  {0..9} Y  {0..9} Propagate

16 SMA / CS © NUS 200216 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} Propagate

17 SMA / CS © NUS 200217 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Branching

18 SMA / CS © NUS 200218 S E N D + M O R E = M O N E Y 0  S,…,Y  9 S  0 M  0 S…Y all different 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Propagate

19 SMA / CS © NUS 200219 S E N D + M O R E = M O N E Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Branching S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8}

20 SMA / CS © NUS 200220 S E N D + M O R E = M O N E Y S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 Propagate S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1} O  {0} R  {8} Y  {2}

21 SMA / CS © NUS 200221 S E N D + M O R E = M O N E Y Complete Search Tree S  {9} E  {4..7} N  {5..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 4 E  4 S  {9} E  {6..7} N  {7..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} E = 5 E  5 S  {9} E  {5} N  {6} D  {7} M  {1} O  {0} R  {8} Y  {2} E = 6 E  6

22 SMA / CS © NUS 200222 The Art of Constraint Programming  Choose model  Choose propagation algorithms  Choose branching algorithms  Choose exploration algorithms

23 SMA / CS © NUS 200223 Demo: SEND + MORE = MONEY Click here for MONEY

24 SMA / CS © NUS 200224 Constraint Programming Systems Constraint programming languages CONSTRAINTS (Steele, Sussman 1980) CHIP (Dincbas, Hentenryck, Simonis, Aggoun 1988) CLP(R) (Jaffar, Maher, Stuckey, Yap 1992) Oz (Smolka and others 1995) OPL (Hentenryck 1998) Constraint programming library ILOG Solver (Puget 1993) support constraint programming with high-level constructs

25 SMA / CS © NUS 200225 Using OPL Syntax enum Letter {S,E,N,D,M,O,R,Y}; var int l[Letter] in 0..9; solve { alldifferent(l); l[S] <> 0; l[M] <> 0; l[S]*1000 + l[E]*100 + l[N]*10 + l[D] + l[M]*1000 + l[O]*100 + l[R]*10 + l[E] = l[M]*10000 + l[O]*1000 + l[N]*100 + l[E]*10 + l[Y] }; search { forall(i in Letter ordered by increasing dsize(l[i])) tryall(v in 0..9) l[i] = v; };  All Solutions; Execution  Run

26 SMA / CS © NUS 200226 Overview  Constraint programming in a nutshell  Elements of constraint programming  Sport tournament scheduling  Production scheduling  Assessment

27 SMA / CS © NUS 200227 Elements of Constraint Programming  The Approach  Propagation  Branching  Exploration

28 SMA / CS © NUS 200228 Elements of Constraint Programming  The Approach  Propagation  Branching  Exploration

29 SMA / CS © NUS 200229 Constraint Solving Given: a satisfiable constraint C and a new constraint C’. Constraint solving is deciding whether C  C’ is satisfiable. Example: C: n > 2 C’: a n + b n = c n

30 SMA / CS © NUS 200230 Completeness  General arithmetic constraints are undecidable (Hilbert’s Tenth Problem).  Constraint solving is not always possible.  Example: c 1 : n > 2 c 2 : a n + b n = c n

31 SMA / CS © NUS 200231 The Constraint Programming Approach Constraint programming separates constraints into  Basic constraints: constraint solving (complete)  Non-basic constraints: propagation (incomplete)

32 SMA / CS © NUS 200232 Basic Constraints vs. Propagators  Basic constraints  are conjunctions of constraints of the form x  S, where S is a finite set of integers  enjoy complete constraint solving  Propagators  can be arbitrarily expressive (arithmetic, symbolic)  implementation typically fast but incomplete

33 SMA / CS © NUS 200233 Basic Constraints in Constraint Programming  Basic constraints are conjunctions of constraints of the form X  S, where S is a finite set of integers.  Constraint solving is done by intersecting domains. Example: C = X  {1..10}, Y  {9..20}, C’ = X  {9..15}, Y  {14..30}.  In practice, we keep a solved form, storing the current domain of every variable.

34 SMA / CS © NUS 200234 Basic Constraints and Propagators S  {1..9} E  {0..9} N  {0..9} D  {0..9} M  {1..9} O  {0..9} R  {0..9} Y  {0..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y

35 SMA / CS © NUS 200235 Basic Constraints and Propagators S  {1..9} E  {0..9} N  {0..9} D  {0..9} M  {1} O  {0..9} R  {0..9} Y  {0..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y

36 SMA / CS © NUS 200236 Basic Constraints and Propagators S  {2..9} E  {0,2..9} N  {0,2..9} D  {0,2..9} M  {1} O  {0,2..9} R  {0,2..9} Y  {0,2..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y

37 SMA / CS © NUS 200237 Basic Constraints and Propagators S  {2..9} E  {0,2..9} N  {0,2..9} D  {0,2..9} M  {1} O  {0} R  {0,2..9} Y  {0,2..9} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y and so on

38 SMA / CS © NUS 200238 Basic Constraints and Propagators S  {9} E  {5..7} N  {6..8} D  {2..8} M  {1} O  {0} R  {2..8} Y  {2..8} all different(S,E,N,D, M,O,R,Y) 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E = 10000*M + 1000*O + 100*N + 10*E + Y

39 SMA / CS © NUS 200239 Elements of Constraint Programming  The Approach  Propagation  Branching  Exploration

40 SMA / CS © NUS 200240 Issues in Propagation  Expressivity: What kind of information can be expressed as propagators?  Completeness: What behavior can be expected from propagation?  Efficiency: How much computational resources does propagation consume?

41 SMA / CS © NUS 200241 Domain-Consistent Propagation  Given: Basic constraint C and propagator P.  Propagation for P is domain-consistent, if for every variable x and every value v in the domain of x, there is an assignment, in which x=v, that satisfies C and P.  Domain-consistent propagation is also called arc-consistent propagation.

42 SMA / CS © NUS 200242 Current Domain Let c be basic constraint. For a given variable x, the maximal set S such that c  x  S is consistent is called the current domain of x in c, denoted dom c (x). Example: C: x  {1..10}, y  {9..20}, x  {8..12} dom c (y) = {9..20}, dom c (x)={8..10}

43 SMA / CS © NUS 200243 Domain Consistency Assume a constraint d over variables x and y. A basic constraint c is domain consistent in x with respect to d, if for every i  dom c (x) there is a j  dom c (y) such that (i,j)  d. Example: d: x + y = 10 c: x  {7,9}, y  {1..20}

44 SMA / CS © NUS 200244 Domain Consistency Assume a constraint d over variables x and y. A basic constraint c is domain consistent in x with respect to d, if for every i  dom c (x) there is a j  dom c (y) such that (i,j)  d. Example: d: x + y = 10 c: x  {7,9}, y  {1,3}

45 SMA / CS © NUS 200245 Domain vs. Interval Consistency  Domain consistency: Check all elements of the domains of all variables known to the propagator  Interval consistency: Check only the boundaries of the domains of the variables

46 SMA / CS © NUS 200246 Interval Consistency Assume a constraint d over variables x and y. A basic constraint c is interval consistent in x with respect to d, if for i=min(dom c (x)) and for i=max(dom c (x)) there is a j  dom c (y) such that (i,j)  d. Example: d: x + y = 10 C: x  {7,9}, y  {1..20}

47 SMA / CS © NUS 200247 Interval Consistency Assume a constraint d over variables x and y. A basic constraint c is interval consistent in x with respect to d, if for i=min(dom c (x)) and for i=max(dom c (x)) there is a j  dom c (y) such that (i,j)  d. Example: d: x + y = 10 C: x  {7,9}, y  {1..3}

48 SMA / CS © NUS 200248 Domain and Interval Consistency OPL syntax for all-different  interval consistency: alldifferent(l);  domain consistency: alldifferent(l) domain;

49 SMA / CS © NUS 200249 Propagation vs Branching trade-off: complex propagation algorithms incur fewer, but more expensive nodes in tree Example: MONEY with alldiff and sum : only test fixed assignment alldiff : wait for fixed variables sum : interval cons. alldiff and sum : domain consistency

50 SMA / CS © NUS 200250 Elements of Constraint Programming  The Approach  Propagation  Branching  Exploration

51 SMA / CS © NUS 200251 Branching Algorithms Constraint programming systems come with  libraries of predefined branching algorithms  programming support for user-defined branching algorithms

52 SMA / CS © NUS 200252 Branching for MONEY enum Letter {S,E,N,D,M,O,R,Y}; var int l[Letter] in 0..9; solve { alldifferent(l); l[S] <> 0; l[M] <> 0; l[S]*1000 + l[E]*100 + l[N]*10 + l[D] + l[M]*1000 + l[O]*100 + l[R]*10 + l[E] = l[M]*10000 + l[O]*1000 + l[N]*100 + l[E]*10 + l[Y] }; search { forall(i in Letter ordered by increasing dsize(l[i])) tryall(v in 0..9) l[i] = v; };  All Solutions; Execution  Run

53 SMA / CS © NUS 200253 Basic Choice Points try x = y endtry; x < y x >= y

54 SMA / CS © NUS 200254 Choice Point Sequences try x = y endtry; try z = 1 | z = 2 endtry; x < yx >= y z = 1z = 2z = 1z = 2

55 SMA / CS © NUS 200255 Abbreviation: tryall tryall(i in 1..5) x = i; stands for try x=1|x=2|x=3|x=4|x=5 endtry;

56 SMA / CS © NUS 200256 Abbreviation: forall forall(i in 1..4) try a[i]=0 | a[i]=1 endtry; stands for try a[1] = 0 | a[1] = 1 endtry; try a[2] = 0 | a[2] = 1 endtry; try a[3] = 0 | a[3] = 1 endtry; try a[4] = 0 | a[4] = 1 endtry;

57 SMA / CS © NUS 200257 Examples of Branching Algorithms  Enumeration: Choose variable, choose value  naive enumeration: choose variables and values in a fixed sequence  first-fail enumeration: choose a variable with minimal domain size  Domain-splitting: try x = mid endtry;  Task sequencing for scheduling

58 SMA / CS © NUS 200258 Elements of Constraint Programming  The Approach  Propagation  Branching  Exploration

59 SMA / CS © NUS 200259 Exploration for MONEY enum Letter {S,E,N,D,M,O,R,Y}; var int l[Letter] in 0..9; solve { alldifferent(l); l[S] <> 0; l[M] <> 0; l[S]*1000 + l[E]*100 + l[N]*10 + l[D] + l[M]*1000 + l[O]*100 + l[R]*10 + l[E] = l[M]*10000 + l[O]*1000 + l[N]*100 + l[E]*10 + l[Y] }; search { forall(i in Letter ordered by increasing dsize(l[i])) tryall(v in 0..9) l[i] = v; };  All Solutions; Execution  Run

60 SMA / CS © NUS 200260 Exploration  Depth-first search (default in OPL)  Best-first search  Limited discrepancy search [Harvey/Ginsberg 95]  user-defined explorations

61 SMA / CS © NUS 200261 Specifying Exploration in OPL enum Letter {S,E,N,D,M,O,T,Y}; var int l[Letter] in 0..9; solve { alldifferent(l); l[S] <> 0; l[M] <> 0; l[S]*1000 + l[E]*100 + l[N]*10 + l[D] + l[M]*1000 + l[O]*100 + l[S]*10 + l[T] = l[M]*10000 + l[O]*1000 + l[N]*100 + l[E]*10 + l[Y] }; search { LDSearch(4) forall(i in Letter ordered by increasing dsize(l[i])) tryall(v in 0..9) l[i] = v; };

62 SMA / CS © NUS 200262 Other Search Components  Optimization  Interaction  Visualization

63 SMA / CS © NUS 200263 Optimization SEND + MOST = MONEY

64 SMA / CS © NUS 200264 Optimization in OPL enum Letter {S,E,N,D,M,O,T,Y}; var int l[Letter] in 0..9; maximize money subject to { money = l[M]*10000+l[O]*1000+l[N]*100+l[E]*10+l[Y] alldifferent(l); l[S] <> 0; l[M] <> 0; l[S]*1000 + l[E]*100 + l[N]*10 + l[D] + l[M]*1000 + l[O]*100 + l[S]*10 + l[T] = l[M]*10000 + l[O]*1000 + l[N]*100 + l[E]*10 + l[Y] }; search { forall(i in Letter ordered by increasing dsize(l[i])) tryall(v in 0..9) l[i] = v; };  All Solutions; Execution  Run

65 SMA / CS © NUS 200265 Interaction  First-solution search  All solution search  Last solution search  Search with user interaction

66 SMA / CS © NUS 200266 Visualization Example: Oz Explorer [Schulte 1997]. Oz Explorer combines  visualization  first/all solution / user interaction  branch-and-bound optimization  depth-first search

67 SMA / CS © NUS 200267 Overview  Constraint programming in a nutshell  Elements of constraint programming  Sport tournament scheduling  Production scheduling  Assessment

68 SMA / CS © NUS 200268 Sport Tournament Scheduling  CP Approach  Propagators  Example

69 SMA / CS © NUS 200269 Sport Tournament Scheduling  CP Approach  Propagators  Example

70 SMA / CS © NUS 200270 Round Robin Tournament Planning Problems  n teams, each playing a fixed number of times r against every other team  r = 1: single, r = 2: double round robin.  Each match is home match for one and away match for the other  Dense round robin:  At each date, each team plays at most once.  The number of dates is minimal.

71 SMA / CS © NUS 200271 CP Approach to Round Robins Rounds

72 SMA / CS © NUS 200272 CP Approach to Round Robins add given constraints Rounds

73 SMA / CS © NUS 200273 CP Approach to Round Robins run filtering algorithms until fixpoint is reached

74 SMA / CS © NUS 200274 CP Approach to Round Robins perform branching step team 3 plays against team 4 in round 2 team 3 plays against team 5 in round 2

75 SMA / CS © NUS 200275 Sport Tournament Scheduling  CP Approach  Propagators  Example

76 SMA / CS © NUS 200276 The All-Different Constraint

77 SMA / CS © NUS 200277 The All-Different Constraint 1 5 4 2 3 England Germany Brasil USA Italy

78 SMA / CS © NUS 200278 The All-Different Constraint 1 5 4 2 3 England Germany Brasil USA Italy Remove all edges that do not belong to a maximum matching in bipartite graph [Regin 94]

79 SMA / CS © NUS 200279 The All-Different Constraint 1 5 4 2 3 England Germany Brasil USA Italy...by applying maximum matching algorithm in bipartite graphs [Hopcroft, Karp 1973] O(|X| 2 d max 2 )

80 SMA / CS © NUS 200280 All-Different in OPL  weak but fast O(|X|): alldifferent(E,U,I,B,G) onValue  domain-consistent O(|X| 2 d max 2 ) : alldifferent(E,U,I,B,G) onDomain

81 SMA / CS © NUS 200281 The One-Factor Constraint

82 SMA / CS © NUS 200282 The One-Factor Constraint France Italy USA England Germany Brasil

83 SMA / CS © NUS 200283 The One-Factor Constraint France Italy USA England Germany Brasil Remove all edges that do not belong to a maximum matching [Regin 99]

84 SMA / CS © NUS 200284 The One-Factor Constraint France Italy USA England Germany Brasil... by modifying Edmond’s maximum matching algorithm [Edmonds 65]

85 SMA / CS © NUS 200285 Sport Tournament Scheduling  CP Approach  Propagators  Example

86 SMA / CS © NUS 200286 ACC 1997/98: A Success Story of Constraint Programming  Integer programming + enumeration, 24 hours Nemhauser, Trick: Scheduling a Major College Basketball Conference, Operations Research, 1998, 46(1)  Constraint programming, less than 1 minute. Henz: Scheduling a Major College Basketball Conference - Revisited, Operations Research, 2001, 49(1)

87 SMA / CS © NUS 200287 The ACC 1997/98 Problem  9 teams participate in tournament  Dense double round robin:  there are 2 * 9 dates  at each date, each team plays either home, away or has a “bye”  Alternating weekday and weekend matches

88 SMA / CS © NUS 200288 The ACC 1997/98 Problem (cont’d)  No team can play away on both last dates.  No team may have more than two away matches in a row.  No team may have more than two home matches in a row.  No team may have more than three away matches or byes in a row.  No team may have more than four home matches or byes in a row.

89 SMA / CS © NUS 200289 The ACC 1997/98 Problem (cont’d)  Of the weekends, each team plays four at home, four away, and one bye.  Each team must have home matches or byes at least on two of the first five weekends.  Every team except FSU has a traditional rival. The rival pairs are Clem-GT, Duke-UNC, UMD- UVA and NCSt-Wake. In the last date, every team except FSU plays against its rival, unless it plays against FSU or has a bye.

90 SMA / CS © NUS 200290 The ACC 1997/98 Problem (cont’d)  The following pairings must occur at least once in dates 11 to 18: Duke-GT, Duke-Wake, GT- UNC, UNC-Wake.  No team plays in two consecutive dates away against Duke and UNC. No team plays in three consecutive dates against Duke UNC and Wake.  UNC plays Duke in last date and date 11.  UNC plays Clem in the second date.  Duke has bye in the first date 16.

91 SMA / CS © NUS 200291 The ACC 1997/98 Problem (cont’d)  Wake does not play home in date 17.  Wake has a bye in the first date.  Clem, Duke, UMD and Wake do not play away in the last date.  Clem, FSU, GT and Wake do not play away in the fist date.  Neither FSU nor NCSt have a bye in the last date.  UNC does not have a bye in the first date.

92 SMA / CS © NUS 200292 Some Literature  Global Constraints for Round Robin Tournament Scheduling. Martin Henz, Tobias Müller, Sven Thiel. European Journal of Operational Research (EJORS), 2002 (to appear)  Scheduling a Major College Basketball Conference- Revisited. Martin Henz. Operations Research, 49(1), Jan/Feb 2001.  Constraint-based Round Robin Tournament Planning. Martin Henz, ICLP 1999.

93 SMA / CS © NUS 200293 Sports Scheduling in Practice  Non-round-robin formats  Optimization criteria / soft constraints  Commercial aspects:  niche market  research-intensive  flexible business models needed

94 SMA / CS © NUS 200294 Overview  Constraint programming in a nutshell  Elements of constraint programming  Sport tournament scheduling  Production scheduling  Assessment

95 SMA / CS © NUS 200295 Production Scheduling Problems  Scheduling Problems  Propagation Algorithms for Resource Constraints  Branching Algorithms  Exploration Algorithms  Literature

96 SMA / CS © NUS 200296 Production Scheduling Problems  Scheduling Problems  Propagation Algorithms for Resource Constraints  Branching Algorithms  Exploration Algorithms  Literature

97 SMA / CS © NUS 200297 Scheduling Problems Assign starting times (and sometimes durations) to tasks, subject to  resource constraints,  precedence constraints, and  various other constraints, and  an optimization function, typically to minimize overall schedule duration.

98 SMA / CS © NUS 200298 Example: Building a Bridge Show Problem  Resource constraints Example: a1 and a2 use excavator, cannot overlap in time  Precedence constraints Example: p1 requires a3, a3 must end before p1 starts Animate SolutionGantt Chart

99 SMA / CS © NUS 200299 Modeling  Indices: Task = {begin,a1,a2,a3,a4,a5,a6,p1,...,end}  Constants: duration of tasks duration = #[begin:0, a1:4, a2:2,...]#  Variables: represent each task with a finite domain variable representing its starting time. Activity a[t in Task](duration[t]) a[t].start is finite domain variable representing the starting time of a[t]

100 SMA / CS © NUS 2002100 Precedence Constraints For each two tasks t1, t2, where t1 must precede t2, introduce a constraint a[t1].start + a[t1].duration  a[t2].start In OPL, just write a[t1] precedes a[t2]

101 SMA / CS © NUS 2002101 Resource Constraints For each two tasks t1, t2 that require a unary resource r, we have the constraint a[t1].start + a[t1].duration  a[t2].start \/ a[t2].start + a[t2].duration  a[t1].start But: many constraints and weak propagation. Thus, introduce global resource constraints.

102 SMA / CS © NUS 2002102 Scheduling  Scheduling Problems  Propagation Algorithms for Resource Constraints  Branching Algorithms  Literature

103 SMA / CS © NUS 2002103 Global Resource Constraints in OPL  Declare resource UnaryResource excavator;  Require resource a[a1] requires excavator; a[a2] requires excavator;...  All “ requires ” constraints on a resource together form a global resource constraint.

104 SMA / CS © NUS 2002104 Propagation: Disjunctive Resource For all tasks t1, t2 using the same resource: a[t1].start + a[t1].duration  a[t2].start \/ a[t2].start + a[t2].duration  a[t1].start Weakest but fastest form of propagation for unary resources.

105 SMA / CS © NUS 2002105 Unary Resource: Example A B C D The four tasks, A, B, C, D, share a unary resource.

106 SMA / CS © NUS 2002106 Propagation: Edge finding For a given task t and set of tasks S, all sharing the same unary resource, find out whether t can occur  before all tasks in S,  after all tasks in S,  between two tasks in S, and infer corresponding basic constraints.

107 SMA / CS © NUS 2002107 Which Edge Finder? As usual, trade-off between run-time of propagation algorithm and strength of propagation. Edge finding can be expensive depending on what tasks are considered. Recent edge finders have complexity n 2 for one propagation step, where n is the number of tasks using the resource. Edge finding based on task intervals can be stronger than these, but typically have complexity n 3.

108 SMA / CS © NUS 2002108 Specifying Propagation Algorithms OPL fixes propagation for unary resources to an (undisclosed) edge-finding algorithm. For discrete (non-unary) resources, the user can choose between default, disjunctive and edgeFinder when declaring a resource. Example: DiscreteResource crane(3) using edgeFinder;

109 SMA / CS © NUS 2002109 Demo: Propagation for Unary Resources Bridge

110 SMA / CS © NUS 2002110 Scheduling  Scheduling Problems  Propagation Algorithms for Resource Constraints  Branching Algorithms  Literature

111 SMA / CS © NUS 2002111 Branching Algorithms: Serializers  Simple enumeration techniques such as first-fail are hopeless for scheduling.  Use unary resources to guide branching.  For two tasks t1, t2 sharing the same resource, use the constraints t1.start + t1.duration  t2.start and t2.start + t2.duration  t1.start for branching.

112 SMA / CS © NUS 2002112 Which Tasks To Serialize?  Resource-oriented serialization: Serialize all tasks of one resource completely, before tasks of another resource are serialized.  Most-used-resource serialization  Global slack  Local slack  Task-oriented serialization: Choose two suitable tasks at a time, regardless of resources.  Slack-based task serialization (see later)

113 SMA / CS © NUS 2002113 Most-used-resource Serialization “Most-used-resource” serialization: serialize first the resource that is used the most. Let T be a set of tasks running on resource r. demand(T) =  t  T t.duration Let S be the set of all tasks using resource r. demand(r) := demand(S), Serialize the resource r with maximal demand(r) first.

114 SMA / CS © NUS 2002114 Slack-based Resource Serialization Let T be a set of tasks running on resource r. supply(T) = lct(T) - est(T) demand(T) =  t  T t.duration slack(T) = supply(T) - demand(T) Let S be the set of all tasks using resource r. slack(r) := slack(S), S is set of all task running on r. Global slack serialization: Serialize resource with smallest slack first

115 SMA / CS © NUS 2002115 Local-Slack Resource Serialization Let I r be all task intervals on r. The local slack is defined as min {slack(I) | I  I r } Local slack serialization: Serialize resource with smallest local slack first. Use global slack for tie-breaking.

116 SMA / CS © NUS 2002116 Which Tasks Are Serialized? Ideas:  Use edge finding to look for possible first tasks (and last tasks)  Choose tasks according to their est, lst ( lct, ect ).

117 SMA / CS © NUS 2002117 Task-oriented Serialization Among all tasks using all resources, select a pair of tasks according to local/global slack criteria and other considerations, regardless what resources are serialized already. Provides more fine-grained control at the expense of runtime for finding candidate task pairs among all tasks.

118 SMA / CS © NUS 2002118 Programming Branching Algorithms in OPL  Scheduling-specific try constructs:  tryRankFirst(u,a): activity a comes first  tryRankLast(u,a): activity a comes last  rank(u): serialize all tasks using u  Reflective functions for unary resources:  isRanked(Unary): 1 if the resource is ranked  nbPossibleFirst(Unary): number of activities that can come first  globalSlack(Unary): global slack of u  localSlack(Unary): local slack of u

119 SMA / CS © NUS 2002119 Example: Task-oriented Serialization in OPL while not isRanked(tool) do select(r in Resources: not isRanked(tool[r])) select(t in tasks[r] : not isRanked(tool[r],a[t]) tryRankFirst(tool[r],a[t]);

120 SMA / CS © NUS 2002120 Demo: Serialization Algorithms Bridge

121 SMA / CS © NUS 2002121 Scheduling  Scheduling Problems  Propagation Algorithms for Resource Constraints  Branching Algorithms  Literature

122 SMA / CS © NUS 2002122 Pointers to Literature  Van Hentenryck: The OPL optimization programming language, 1999  Constraint Programming Tutorial of Mozart, 2000 (www.mozart-oz.org)  Various papers by Laburthe, Caseau, Baptiste, Le Pape, Nuijten, see “Overview of Finite Domain Constraint Programming” in www.comp.nus.edu.sg/~henz/publications

123 SMA / CS © NUS 2002123 Overview  Constraint programming in a nutshell  Elements of constraint programming  Sport tournament scheduling  Production scheduling  Assessment

124 SMA / CS © NUS 2002124 Assessment: Don’t Use It! Don’t use constraint programming for:  Problems for which there are known efficient algorithms or heuristics. Example: Traveling salesman.  Problems for which integer programming works well. Example: Many discrete assignment problems.  Problems with weak constraints and a complex optimization function. Example: many timetabling problems.

125 SMA / CS © NUS 2002125 Assessment: Do Use It! Use constraint programming for:  Problems for which integer programming does not work (linear models too large).  Problems for which there are no efficient solutions available.  Problems with tight constraints, where propagation can be employed. Example: ACC 97/98.  Problems for which strong branching algorithms exist. Example: Scheduling with unary resources.

126 SMA / CS © NUS 2002126 Myths Debunked  A fad! Constraint programming has been used successfully in a number of application areas, most spectacularly in scheduling  Universal! More failure stories than success stories.  All new! Many ideas come from AI search and Operations Research. In particular, the important ideas for scheduling come from OR.  Artificial Intelligence! All quite earthly algorithms. Constraint programming systems provide framework for different kinds of algorithms to interact.

127 SMA / CS © NUS 2002127 The Future  In OR, constraint programming is being added as a standard technique for solving combinatorial problems, along with local search (“heuristic approach”).  Constraint programming techniques will be tightly integrated with integer programming and local search.  Look at the Workshop Series on Integration of AI and OR Techniques for Combinatorial Optimization Problems (CP-AI-OR)


Download ppt "Event Scheduling Using Constraint Programming November 22, 2002 Martin Henz, School of Computing, NUS www.comp.nus.edu.sg/~henz/sma2002."

Similar presentations


Ads by Google