© j. christopher beck 20051 lecture 21: ip and cp models for sports scheduling

22
© J. Christopher Beck 2005 1 Lecture 21: IP and CP Models for Sports Scheduling

Upload: herbert-black

Post on 18-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 1

Lecture 21: IP and CP Models forSports Scheduling

Page 2: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 2

Outline Single Round Robin IP Model 3-Step Algorithm Again IP Models for the 3-Step Algorithm CP Models for the 3-Step Algorithm

Page 3: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 3

Single Round Robin Tournament

Assume n teams and that n is even Every team plays every other team It is possible to construct a

schedule with n-1 slots each with n/2 games

Page 4: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 4

IP for Simple Single RR

1,...,1;,...,11)(1

ntnjxxn

ijitijt

jixxn

tjitijt

1

1

1)(

Each team plays one game in each slot

Each team plays each other team exactly once

Pure IP model xijt = 1 iff team i plays at home

against team j in slot t

Page 5: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 5

Recall the (MoreComplex) Problem

Double RR tournament Minimize “breaks”

Two consecutive Homeor Away games

A variety of otherconstraints and preferences “rival” pairings 2 Home or 1 Home, 1 Bye in first 5 weeks

Page 6: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 6

3-Step Approach

Step 1: HAPs Find at least n HAPs

HAP – string of H, A, B Find a set of n consistent HAPs

Step 2: Assign games to HAPs Step 3: Assign teams to HAPs

Page 7: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 7

ACC Scheduling Solution

Findfeasiblepatterns

Findpattern

sets

Assigngames

Assignteams topatterns

Choosefinal

schedule

38 patternsof length 18

17 patternsets

826 timetables 17 schedules

Step 1 Step 2 Step 3

Figure 10.3

Page 8: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 8

Step 1: HAPs

Create a consistent set of HAPs What’s wrong with these HAPs?

slot 1 2 3 4 5

Team a H A H A A

Team b H B A H A

Team c A A B H H

Team d A A H A H

Team e B H A B A

Teams: UofT, Western, Queens,McGill, Waterloo

Page 9: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 9

Step 1: HAPs List preferred HAPs (and

a few others) E.g., All HAPs with 1 or 0

breaks Can you pick a

consistent set of 5 HAPs?

H A H A B

H A H B A

H A B A H

H B H A H

B A H A H

A H A H B

A H A B H

A H B H A

A B A H A

B H A H A

Page 10: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 10

Step 2: Assign Games

You’ve got a set of consistent HAPs Match the Hs with the As

slot 1 2 3 4 5

Team a H A H A B

Team b H B A H A

Team c A A B H H

Team d B H H A A

Team e A H A B H

Teams: UofT, Western, Queens,McGill, Waterloo

Page 11: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 11

Step 2: Assign Games

You’ve got a set of consistent HAPs Match the Hs with the As

slot 1 2 3 4 5

Team a H A H A B

Team b H B A H A

Team c A A B H H

Team d B H H A A

Team e A H A B H

Teams: UofT, Western, Queens,McGill, Waterloo

Page 12: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 12

Step 2: IP Model

S is a set of n consistent HAPs T is the set of slots/rounds xijt = 1 iff the team with pattern i

plays in round t at the site of the team associated with pattern j Only defined if the ith pattern has a A

is slot t and the jth pattern has an H F is the set of such triples (i, j, t)

Page 13: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 13

Step 2: IP Model

jiSjiFtjixxn

t

n

tjitijt

;,;),,(11

1

1

1

TtSiFtjixxn

j

n

jjitijt

;;),,(11 1

Ftjixijt ),,(}1,0{

One game between team withpattern i and team with pattern j

Team with pattern i plays at mostone game is slot t

Page 14: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 14

Step 3: Assign Teams to HAPs

Map teams to patterns to maximize preferences

slot 1 2 3 4 5

Team a H A H A B

Team b H B A H A

Team c A A B H H

Team d B H H A A

Team e A H A B H

UofTWesternQueensMcGillWaterloo

Page 15: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 15

Step 3: IP Model

yik = 1 iff team i is assigned to HAP k cik = cost of team assignment yik

nkyn

iik ,...,11

1

niyn

kik ,...,11

1

n

i

n

kikik yc

1 1

minimize

One team assigned to eachpatternOne pattern assigned to

each team

Page 16: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 16

Constraint Programming Models

Double RR with odd n Break is now 3 consecutive Hs or

As No breaks are allowed

H or B in at least 2 of first 4 rounds No team can be away in both of

the final 2 games

Page 17: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 17

Step 1: CP Model 1

ht, at, bt – 0,1 variables denoting home, away, bye for a given team in slot t

4

1

212

21

21

2

1

22,...,12

22,...,12

2,...,11

ii

nn

ttt

ttt

ttt

a

aa

nthhh

ntaaa

ntbah

No breaks

No team away for bothof final 2 games

H or B in at least 2 of first 4 slots

Page 18: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 18

A Different CP Model:The Distribute Constraint

distribute(card, value, base) card – array of variables value – array of values base – array of variables value[i] is taken by card[i] elements

of basedistribute([{0,1}, {1,3}], [0, 1], [w1, …, wn])

card value base

Page 19: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 19

Step 1: CP Model 2

gt є {H,A,B} – variable denoting home, away, bye for a given team in slot t

No breaks

No team away for bothof final 2 games

H or B in at least 2 of first 4 slots

distribute([{0,1,2}, {0,1,2}], [H, A], [gt, gt+1, gt+2])t = 1, …, 2n-2

(g2n ≠ A) OR (g2n-1 ≠ A)

distribute([{0,1,2}], [A], [g1, g2, g3 , g4])

Page 20: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 20

Step 1: CP Model 2

Some additional constraints

2 Bs, Equal # As & Hs

distribute([{n-1}, {n-1}, {2}], [H, A, B], [g1, …, g2n])

1 Bs, Equal # As & Hs

distribute([{(n-1)/2}, {(n-1)/2}, {1}], [H, A, B], [t1, …, tn])

Let t1, … tn, be the HAP for one slot (across all teams)

Page 21: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 21

Step 1: CP Model

With either of these models, you can then easily generate all possible HAPs

You could also add a cost function to generate only “good” HAPs

Page 22: © J. Christopher Beck 20051 Lecture 21: IP and CP Models for Sports Scheduling

© J. Christopher Beck 2005 22

Step 2: Assign Games

Given a set of consistent HAPs Devise a CP model to assign games

The one in the book is overly complicated!

slot 1 2 3 4 5 6 7 8 9 10

Team a H A H A B H A H A B

Team b H B A H A H B A H A

Team c A A B H H A A B H H

Team d B H H A A B H H A A

Team e A H A B H A H A B H