SportsLeague Class Reference
[Scripts for problems]
Inherits Example.
Detailed Description
Example: Sports League Scheduling
- There are teams ( even).
- The season lasts weeks.
- Each game between two different teams occurs exactly once.
- Every team plays one game in each week of the season.
- There are periods and each week every period is scheduled for one game.
- No team plays more than twice in the same period over the course of the season.
See also problem 26 at http://www.csplib.org/.
Definition at line 181 of file sports-league.cc.
Public Member Functions | |
SportsLeague (const SizeOptions &opt) | |
Setup model. | |
SportsLeague (bool share, SportsLeague &s) | |
Constructor for cloning s. | |
virtual Space * | copy (bool share) |
Copy during cloning. | |
virtual void | print (std::ostream &os) |
Print solution. | |
Protected Member Functions | |
int | weeks (void) const |
Return number of weeks. | |
int | periods (void) const |
Return number of periods. | |
IntVar & | h (int p, int w) |
Home team in period p and week w. | |
IntVar & | a (int p, int w) |
Away team in period p and week w. | |
IntVar & | g (int p, int w) |
Return game number for game in period p and week w. | |
Protected Attributes | |
const int | teams |
number of teams | |
IntVarArray | home |
home teams | |
IntVarArray | away |
away teams | |
IntVarArray | game |
game numbers |
Constructor & Destructor Documentation
SportsLeague::SportsLeague | ( | const SizeOptions & | opt | ) | [inline] |
Setup model.
(h,a) and (a,h) are the same game, focus on home (that is, h<a)
Column constraint: each team occurs exactly once
Row constraint: no team appears more than twice
Definition at line 211 of file sports-league.cc.
SportsLeague::SportsLeague | ( | bool | share, | |
SportsLeague & | s | |||
) | [inline] |
Member Function Documentation
int SportsLeague::weeks | ( | void | ) | const [inline, protected] |
int SportsLeague::periods | ( | void | ) | const [inline, protected] |
IntVar& SportsLeague::h | ( | int | p, | |
int | w | |||
) | [inline, protected] |
IntVar& SportsLeague::a | ( | int | p, | |
int | w | |||
) | [inline, protected] |
IntVar& SportsLeague::g | ( | int | p, | |
int | w | |||
) | [inline, protected] |
Return game number for game in period p and week w.
Definition at line 205 of file sports-league.cc.
virtual Space* SportsLeague::copy | ( | bool | share | ) | [inline, virtual] |
virtual void SportsLeague::print | ( | std::ostream & | os | ) | [inline, virtual] |
Member Data Documentation
const int SportsLeague::teams [protected] |
IntVarArray SportsLeague::home [protected] |
IntVarArray SportsLeague::away [protected] |
IntVarArray SportsLeague::game [protected] |
The documentation for this class was generated from the following file:
- examples/sports-league.cc (Revision: 6033)