Generated on Sat Feb 7 2015 02:01:38 for Gecode by doxygen 1.8.9.1
SportsLeague Class Reference

Example: Sports league scheduling More...

Public Member Functions

 SportsLeague (const SizeOptions &opt)
 Setup model. More...
 
 SportsLeague (bool share, SportsLeague &s)
 Constructor for cloning s. More...
 
virtual Spacecopy (bool share)
 Copy during cloning. More...
 
virtual void print (std::ostream &os) const
 Print solution. More...
 
- Public Member Functions inherited from Gecode::Driver::ScriptBase< BaseSpace >
 ScriptBase (void)
 Default constructor. More...
 
 ScriptBase (bool share, ScriptBase &e)
 Constructor used for cloning. More...
 
virtual void compare (const Space &, std::ostream &os) const
 Compare with s. More...
 

Protected Member Functions

int weeks (void) const
 Return number of weeks. More...
 
int periods (void) const
 Return number of periods. More...
 
IntVarh (int p, int w)
 Home team in period p and week w. More...
 
const IntVarh (int p, int w) const
 Home team in period p and week w. More...
 
IntVara (int p, int w)
 Away team in period p and week w. More...
 
const IntVara (int p, int w) const
 Away team in period p and week w. More...
 
IntVarg (int p, int w)
 Return game number for game in period p and week w. More...
 
const IntVarg (int p, int w) const
 Return game number for game in period p and week w. More...
 

Protected Attributes

const int teams
 number of teams More...
 
IntVarArray home
 home teams More...
 
IntVarArray away
 away teams More...
 
IntVarArray game
 game numbers More...
 

Related Functions

(Note that these are not member functions.)

int main (int argc, char *argv[])
 Main-function. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Gecode::Driver::ScriptBase< BaseSpace >
static std::ostream & select_ostream (const char *name, std::ofstream &ofs)
 Choose output stream according to name. More...
 
template<class Script , template< class > class Engine, class Options >
static void run (const Options &opt, Script *s=NULL)
 

Detailed Description

Example: Sports league scheduling

  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.

See also problem 26 at http://www.csplib.org/.

Definition at line 178 of file sports-league.cpp.

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 220 of file sports-league.cpp.

SportsLeague::SportsLeague ( bool  share,
SportsLeague s 
)
inline

Constructor for cloning s.

Definition at line 294 of file sports-league.cpp.

Member Function Documentation

int SportsLeague::weeks ( void  ) const
inlineprotected

Return number of weeks.

Definition at line 186 of file sports-league.cpp.

int SportsLeague::periods ( void  ) const
inlineprotected

Return number of periods.

Definition at line 190 of file sports-league.cpp.

IntVar& SportsLeague::h ( int  p,
int  w 
)
inlineprotected

Home team in period p and week w.

Definition at line 194 of file sports-league.cpp.

const IntVar& SportsLeague::h ( int  p,
int  w 
) const
inlineprotected

Home team in period p and week w.

Definition at line 198 of file sports-league.cpp.

IntVar& SportsLeague::a ( int  p,
int  w 
)
inlineprotected

Away team in period p and week w.

Definition at line 202 of file sports-league.cpp.

const IntVar& SportsLeague::a ( int  p,
int  w 
) const
inlineprotected

Away team in period p and week w.

Definition at line 206 of file sports-league.cpp.

IntVar& SportsLeague::g ( int  p,
int  w 
)
inlineprotected

Return game number for game in period p and week w.

Definition at line 210 of file sports-league.cpp.

const IntVar& SportsLeague::g ( int  p,
int  w 
) const
inlineprotected

Return game number for game in period p and week w.

Definition at line 214 of file sports-league.cpp.

virtual Space* SportsLeague::copy ( bool  share)
inlinevirtual

Copy during cloning.

Definition at line 302 of file sports-league.cpp.

virtual void SportsLeague::print ( std::ostream &  os) const
inlinevirtual

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< BaseSpace >.

Definition at line 306 of file sports-league.cpp.

Friends And Related Function Documentation

int main ( int  argc,
char *  argv[] 
)
related

Main-function.

Definition at line 336 of file sports-league.cpp.

Member Data Documentation

const int SportsLeague::teams
protected

number of teams

Definition at line 180 of file sports-league.cpp.

IntVarArray SportsLeague::home
protected

home teams

Definition at line 181 of file sports-league.cpp.

IntVarArray SportsLeague::away
protected

away teams

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

IntVarArray SportsLeague::game
protected

game numbers

Definition at line 183 of file sports-league.cpp.


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