Skip to content

Instantly share code, notes, and snippets.

@ianmurrays
Created June 12, 2011 21:14
Show Gist options
  • Save ianmurrays/1021992 to your computer and use it in GitHub Desktop.
Save ianmurrays/1021992 to your computer and use it in GitHub Desktop.
Constraints
// -----------------------------------------------------------------------------------
/**
* Makes sure that, if team A plays against B on a round, team B plays against team A
* on the same round.
*/
bool RTTP::roundConsistency()
{
/*for (size_t d = 0; d < (size_t)this->numberOfDays; d++)
{
for (size_t i = 0; i < (size_t)this->numberOfTeams; i++)
{
for (size_t i2 = 0; i2 < (size_t)this->numberOfTeams; i2++)
{
if (i != i2 && this->O[i][d] == this->O[i2][d])
{
return false;
}
}
}
}*/
for (size_t d = 0; d < (size_t)this->numberOfDays; d++)
{
for (size_t i = 0; i < (size_t)this->numberOfTeams; i++)
{
if ((int)this->O[i][d] != O_NOOPONENT && this->O[this->O[i][d]][d] != (int)i)
{
return false;
}
}
}
return true;
}
// -----------------------------------------------------------------------------------
/**
* Makes sure the number of free games per round is even.
*/
bool RTTP::freeGamesConsistency()
{
for (size_t d = 0; d < (size_t)this->numberOfDays; d++)
{
int freeGames = 0;
for (size_t i = 0; i < (size_t)this->numberOfTeams; i++)
{
if (this->G[i][d] == G_OFFDAY)
{
freeGames++;
}
}
if (freeGames % 2 != 0)
{
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment