Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0

Example: Sports league scheduling More...

Public Member Functions

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

Protected Member Functions

int weeks (void) const
 Return number of weeks.
int periods (void) const
 Return number of periods.
IntVarh (int p, int w)
 Home team in period p and week w.
const IntVarh (int p, int w) const
 Home team in period p and week w.
IntVara (int p, int w)
 Away team in period p and week w.
const IntVara (int p, int w) const
 Away team in period p and week w.
IntVarg (int p, int w)
 Return game number for game in period p and week w.
const IntVarg (int p, int w) const
 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

(Note that these are not member symbols.)

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

Additional Inherited Members

Static Public Member Functions inherited from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > >
static std::ostream & select_ostream (const char *sn, std::ofstream &ofs)
 Choose output stream according to sn.
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 174 of file sports-league.cpp.

Constructor & Destructor Documentation

◆ SportsLeague() [1/2]

SportsLeague::SportsLeague ( const SizeOptions & opt)
inline

Setup model.

(h,a) and (a,h) are the same game, focus on home (that is, h

Column constraint: each team occurs exactly once

Row constraint: no team appears more than twice

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

◆ SportsLeague() [2/2]

SportsLeague::SportsLeague ( SportsLeague & s)
inline

Constructor for cloning s.

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

Member Function Documentation

◆ weeks()

int SportsLeague::weeks ( void ) const
inlineprotected

Return number of weeks.

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

◆ periods()

int SportsLeague::periods ( void ) const
inlineprotected

Return number of periods.

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

◆ h() [1/2]

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

Home team in period p and week w.

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

◆ h() [2/2]

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

Home team in period p and week w.

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

◆ a() [1/2]

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

Away team in period p and week w.

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

◆ a() [2/2]

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

Away team in period p and week w.

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

◆ g() [1/2]

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

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

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

◆ g() [2/2]

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

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

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

◆ copy()

virtual Space * SportsLeague::copy ( void )
inlinevirtual

Copy during cloning.

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

◆ print()

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

Print solution.

Reimplemented from Gecode::Driver::ScriptBase< Driver::IgnoreStepOption< Space > >.

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

◆ main()

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

Main-function.

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

Member Data Documentation

◆ teams

const int SportsLeague::teams
protected

number of teams

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

◆ home

IntVarArray SportsLeague::home
protected

home teams

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

◆ away

IntVarArray SportsLeague::away
protected

away teams

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

◆ game

IntVarArray SportsLeague::game
protected

game numbers

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


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