Generated on Wed Jan 4 17:49:16 2006 for Gecode by doxygen 1.4.6

SportsLeague Class Reference
[Example scripts (models)]

Inherits Example.

List of all members.


Detailed Description

Example: Sports League Scheduling

Prob026: round robin tournaments from http://www.csplip.org

  1. There are $ t $ teams ($ t $ even).
  2. The season lasts $ t - 1 $ weeks.
  3. Each game between two different teams occurs exactly once.
  4. Every team plays one game in each week of the season.
  5. There are $ \displaystyle\frac{t}{2} $ periods and each week every period is scheduled for one game.
  6. No team plays more than twice in the same period over the course of the season.

Definition at line 60 of file sports-league.cc.

Public Member Functions

IntVar & h (int p, int w)
 Access the home team in period p and week w.
IntVar & a (int p, int w)
 Access the away team in period p and week w.
IntVar & g (int p, int w)
 Access the game number associated with the game in period p and week w.
Playrrs (int p, int w)
 Access the entry in the round robin schedule for period p and week w.
int gn (int h, int a)
 Compute game numbers.
void init_rrs (void)
 Build a feasible schedule.
 SportsLeague (const Options &op)
 SportsLeague (bool share, SportsLeague &s)
virtual Space * copy (bool share)
 Copying member function.
virtual void print (void)

Protected Member Functions

int digit (int n)
void blank (int n)
void blankv (int n)
void blank_only (int n)


Constructor & Destructor Documentation

SportsLeague::SportsLeague const Options op  )  [inline]
 

Symmetrie breaking: we consider (h, a) and (a, h) as the same game and focus on the home game for h, i.e. (h, a) with h < a

Constraint on each column: each team occurs exactly once. (you need two teams in order to form a match).

Constraint on each row: no team appears more than twice (you do not want a team to play more than twice a week in the same slot the same time.)

Definition at line 233 of file sports-league.cc.

SportsLeague::SportsLeague bool  share,
SportsLeague s
[inline]
 

Definition at line 356 of file sports-league.cc.


Member Function Documentation

int SportsLeague::digit int  n  )  [inline, protected]
 

Definition at line 85 of file sports-league.cc.

void SportsLeague::blank int  n  )  [inline, protected]
 

Definition at line 96 of file sports-league.cc.

void SportsLeague::blankv int  n  )  [inline, protected]
 

Definition at line 103 of file sports-league.cc.

void SportsLeague::blank_only int  n  )  [inline, protected]
 

Definition at line 110 of file sports-league.cc.

IntVar& SportsLeague::h int  p,
int  w
[inline]
 

Access the home team in period p and week w.

Definition at line 118 of file sports-league.cc.

IntVar& SportsLeague::a int  p,
int  w
[inline]
 

Access the away team in period p and week w.

Definition at line 123 of file sports-league.cc.

IntVar& SportsLeague::g int  p,
int  w
[inline]
 

Access the game number associated with the game in period p and week w.

Definition at line 131 of file sports-league.cc.

Play& SportsLeague::rrs int  p,
int  w
[inline]
 

Access the entry in the round robin schedule for period p and week w.

Definition at line 139 of file sports-league.cc.

int SportsLeague::gn int  h,
int  a
[inline]
 

Compute game numbers.

Given the game $ (h,a) $ between a home team $ h $ and an away team $ a $ this function computes the unique game number $g = (h - 1) * t + a \Leftrightarrow t = t * h + a - g$

Definition at line 152 of file sports-league.cc.

void SportsLeague::init_rrs void   )  [inline]
 

Build a feasible schedule.

The games of the first week are fixed as: $ \langle 1,2 \rangle \cup \{\langle p + 2, t - p + 1\rangle | p \geq 1\}$.
The remaining games are computed by transforming a game $ \langle h, a, g \rangle $ from the previous week in a new game $ \langle h', a'\rangle $, where:
$ h' = \left\{ \begin{tabular}{l c l} 1 & & if $h = 1$ \\ 2 & & if $h = t$ \\ $h + 1$ & & otherwise \end{tabular}\right. $ and $ a' = \left\{ \begin{tabular}{l c l} 2 & & if $h = t$ \\ a + 1 & & otherwise \end{tabular}\right. $

Definition at line 182 of file sports-league.cc.

virtual Space* SportsLeague::copy bool  share  )  [inline, virtual]
 

Copying member function.

Must create a new object using the constructor for cloning.

Implements Gecode::Space.

Definition at line 367 of file sports-league.cc.

virtual void SportsLeague::print void   )  [inline, virtual]
 

Reimplemented from Example.

Definition at line 371 of file sports-league.cc.


The documentation for this class was generated from the following file: