Professional Football Scheduling with Barcelogic

Robert Nieuwenhuis

Barcelogic, Technical University Catalonia (UPC) Jordi Girona 1, 08034 Barcelona, Spain www.lsi.upc.edu/~roberto

Abstract. Over the last five years, the Barcelogic research group has developed new, surprisingly powerful software for professional sports scheduling. Here we describe its application in practice, using as a case study the complex constraints –in number and difficulty– posed by the Dutch professional football Ere- and Eerste Divisies.

1 The tradition: table-based scheduling

Here we consider professional sports match scheduling, typically for (but not limited to) double round-robin leagues. A possible schedule for a single round- robin league with 20 teams is given by the following table:

Round Matches 1 1 – 20 19 – 2 18 – 3 17 – 4 16 – 5 15 – 6 14 – 7 13 – 8 12 – 9 11 – 10 2 2 – 1 3 – 19 4 – 18 5 – 17 6 – 16 7 – 15 8 – 14 9 – 13 10 – 12 20 – 11 3 1 – 3 2 – 20 19 – 4 18 – 5 17 – 6 16 – 7 15 – 8 14 – 9 13 – 10 12 – 11 4 4 – 1 3 – 2 5 – 19 6 – 18 7 – 17 8 – 16 9 – 15 10 – 14 11 – 13 20 – 12 5 1 – 5 2 – 4 3 – 20 19 – 6 18 – 7 17 – 8 16 – 9 15 – 10 14 – 11 13 – 12 6 6 – 1 5 – 2 4 – 3 7 – 19 8 – 18 9 – 17 10 – 16 11 – 15 12 – 14 20 – 13 7 1 – 7 2 – 6 3 – 5 4 – 20 19 – 8 18 – 9 17 – 10 16 – 11 15 – 12 14 – 13 8 8 – 1 7 – 2 6 – 3 5 – 4 9 – 19 10 – 18 11 – 17 12 – 16 13 – 15 20 – 14 9 1 – 9 2 – 8 3 – 7 4 – 6 5 – 20 19 – 10 18 – 11 17 – 12 16 – 13 15 – 14 10 10 – 1 9 – 2 8 – 3 7 – 4 6 – 5 11 – 19 12 – 18 13 – 17 14 – 16 20 – 15 11 1 – 11 2 – 10 3 – 9 4 – 8 5 – 7 6 – 20 19 – 12 18 – 13 17 – 14 16 – 15 12 12 – 1 11 – 2 10 – 3 9 – 4 8 – 5 7 – 6 13 – 19 14 – 18 15 – 17 20 – 16 13 1 – 13 2 – 12 3 – 11 4 – 10 5 – 9 6 – 8 7 – 20 19 – 14 18 – 15 17 – 16 14 14 – 1 13 – 2 12 – 3 11 – 4 10 – 5 9 – 6 8 – 7 15 – 19 16 – 18 20 – 17 15 1 – 15 2 – 14 3 – 13 4 – 12 5 – 11 6 – 10 7 – 9 8 – 20 19 – 16 18 – 17 16 16 – 1 15 – 2 14 – 3 13 – 4 12 – 5 11 – 6 10 – 7 9 – 8 17 – 19 20 – 18 17 1 – 17 2 – 16 3 – 15 4 – 14 5 – 13 6 – 12 7 – 11 8 – 10 9 – 20 19 – 18 18 18 – 1 17 – 2 16 – 3 15 – 4 14 – 5 13 – 6 12 – 7 11 – 8 10 – 9 19 – 20 19 1 – 19 2 – 18 3 – 17 4 – 16 5 – 15 6 – 14 7 – 13 8 – 12 9 – 11 20 – 10 The traditional way of match scheduling is to assign actual teams to the numbers in the table, e.g., by means of a random draw. For a double round- robin tournament, rounds 20 to 38 are typically the returns of rounds 1-19. Using such a table has several advantages. It minimizes doubles for each team, that is, two consecutive home matches, or two consecutive away matches (triples are forbidden). It also provides symmetric pairs of teams: for each team there is one other team that plays a fully opposite home-away pattern. The latter is important for, e.g., pairs of clubs from the same city that should not coincide at home in the same round. Unfortunately, table-based match scheduling also has numerous disadvan- tages. One of them is the so-called carry-over effect: for everyone, after playing against team n, the following opponent is team n + 1. This can lead to impor- tant sportive unfairnesses. For example, in the Spanish (still table-based) Liga 08-09, Villarreal’s opponents always had played just before consecutively against FC Barcelona and Real Madrid, and were hence more likely to be weakened by moral or physical fatigue, injuries, or sanctions. But of course the most important disadvantage of a table-based scheduling is that it offers almost no room for imposing desired economic, sportive, public- order and other organizational characteristics.

2 Advantages of a well-designed schedule

The Barcelogic software easily equals the features of table-based scheduling: min- imizing doubles, no triples, symmetric teams wherever needed, etc. Therefore, here we focus on its additional benefits. Sportive. Of course a well-designed schedule can —and must— be fair from a sportive point of view. In particular, the carry-over effect completely disappears, as well as other undesired properties such as long sequences of consecutive strong opponents, or many “distracted” opponents that are just before or after playing in European competitions. Economic. On the one hand, a certain economic fairness among teams is desir- able; for example, home matches on weekdays could be evenly distributed among clubs, since weekday matches typically yield lower revenues. But what matters is not just a fair distribution of the existing economical revenues, but also an overall increase of TV, merchandising, ticketing and other revenues for all clubs, and a minimization of the costs: – One can maximize revenues from TV rights by adequately placing TV- attractive matches. – One can make the league more attractive by placing on concrete days certain traditional matches, or specific matches requested by clubs. – A club can forbid home matches on certain days and is hence able to rent out its stadium (long in advance) for concerts or other events. – A well-designed schedule can reduce clubs’ travel expenses. – Clubs can avoid home matches on days on which a sub-normal attendance is expected due to, e.g., local festivals or other local events.

Public Order. Clubs may save costs on security personnel, and authorities will be grateful if they can influence the match schedule. For example, they may want to avoid certain high-risk matches on certain days, or have them take place only by daylight, avoid simultaneous high-risk matches in the same (police) region, avoid supporters travelling on certain busy days for public transportation, etc. Adjust to international competitions. One may find it desirable to avoid important matches just before or after important international matches both at the club level and at the national team level. For example, in the Spanish Liga 08- 09 “El Cl´asico”Real Madrid - FC Barcelona, which settled the championship, was scheduled just in between both Champions League semifinal legs, which turned out to be Chelsea - FC Barcelona, the three matches being played in eight days. This kind of situations are harmful for the sportive and economic interests of clubs and national teams, and are of course avoided in a well-designed schedule.

3 Barcelogic in the Dutch Professional Leagues

Tailored round-robin sports scheduling is computationally well-known to be hard and has been extensively studied [NT98,Sch99,ENT01,Hen01,AMHV03]. No ef- ficient algorithms were known for it. Indeed, a brute-force analysis of the astro- nomical number of possible candidate schedules would take billions of computer- years. Our new Barcelogic software uses innovative logic-based techniques. In our work for the KNVB (the Royal Dutch Football Federation), we have successfully applied Barcelogic for the yearly scheduling of the last five Dutch professional football Ere- and Eerste Divisies. In that context, we have developed many new techniques for flexibly expressing scheduling problems, and can use our solver for solving, fully automatically, in seconds very large real-world scheduling problems with thousands of constraints of different types. We are not aware of any other technology at this level. It is important to remark that each league has different specific kinds of con- straints. Therefore, the flexible logic-based modeling in Barcelogic also becomes a crucial factor for reducing development costs. Data collection. The KNVB has special forms for collecting constraints from clubs and elsewhere (police, railways), based on the calendar of playing days for the following national and international season. The KNVB also adds its own numerous sportive and commercial constraints. As soon as the information becomes available about which clubs may become to play which international competitions, for each club a 34×17 matrix is created, where for each one of the 34 rounds, information is given under which conditions it is possible to play a home match against each one of the 17 other clubs. Entries have meanings such as “fully blocked”, “only on Saturday”, “not on Sunday”, or “if on Sunday it must be movable to Saturday due to Champions League the Tuesday thereafter”. These matrices together contain all (thousands of) constraints referring to single matches. But many other constraints are not expressed in the matrices, since they involve forbidden combinations of matches. For instance, there are constraints of the form “teams A and B should not play both home on the same day” (or on the same round, a stronger constraint). Similarly, one can have “if team A plays home, then no match B-C on same round/day”, or “matches A-B and C-D should not coincide”, etc. For example, if Ajax and both play away matches, their hooligans should not meet each other at the Utrecht railway station, which blocks several combinations of away matches for these two clubs. There are also global constraints about the “” (Ajax, Feyenoord, PSV): no one should meet two of them consecutively, or all three of them away in the first (or second) competition half, and matches between the big three should be carefully spread over the season. Other important global constraints involve TV rights, and in particular that on weekends there should be at least four matches on Sunday and one (with sufficiently diverse teams) on Friday. Interaction KNVB - Barcelogic. All constraints are sent in a simple text form to Barcelogic, where any changes, such as new constraints with respect to the previous season are modeled. Then the Barcelogic software is ready to be run, generating either an ex- planation of why no schedule can exist, or else a correct schedule satisfying all constraints, together with a complete analysis of all its properties in different presentation forms, including a colored pdf one. All this information automati- cally appears in a few seconds on a restricted-access web page. Typically then real-time interaction by telephone takes place, in which the KNVB and Barcelogic representatives propose to try small changes, and succes- sive new schedules appear on the website and are discussed. Such an interactive session may be repeated on later days, e.g., if a committee requests any further changes. Once the schedule is definitive, a similar new process starts for the , which has 20 teams and also different types of constraints, some of which depend on the Eredivisie schedule.

References

[AMHV03] A. Anagnostopoulos, L. Michel, P. Van Hentenryck, and Y. Vergados. A simulated annealing approach to the traveling tournament problem. Techni- cal Report CS-03-01, Department of Computer Science, Brown University, February 2003. [ENT01] Kelly Easton, George Nemhauser, and Michael Trick. The traveling tour- nament problem description and benchmarks. Lecture Notes in Computer Science, 2239:580–595, 2001. [Hen01] M. Henz. Scheduling a major college basketball conference – revisited. Operations Research, 49(1):163–168, 2001. [NOT06] Robert Nieuwenhuis, Albert Oliveras, and Cesare Tinelli. Solving SAT and SAT Modulo Theories: from an Abstract Davis-Putnam-Logemann- Loveland Procedure to DPLL(T). Journal of the ACM, 53(6):937–977, November 2006. [NT98] G. L. Nemhauser and M. A. Trick. Scheduling a major college basketball conference. Operations Research, 46:1–8, 1998. [Sch99] Andrea Schaerf. Scheduling sport tournaments using constraint logic pro- gramming. Constraints, 4(1):43–65, 1999.