42 using namespace Gecode;
54 _w(
"-w",
"number of weeks",9),
55 _g(
"-g",
"number of groups",8),
56 _s(
"-s",
"number of players per group",4) {
62 int w(
void)
const {
return _w.value(); }
64 int g(
void)
const {
return _g.value(); }
66 int s(
void)
const {
return _s.value(); }
97 g(opt.g()), s(opt.s()), w(opt.w()),
98 groups(*this,g*w,
IntSet::empty,0,g*s-1,s,s) {
102 SetVar allPlayers(*
this, 0,g*s-1, 0,g*s-1);
103 for (
int i=0;
i<w;
i++)
107 for (
int i=0;
i<groups.
size()-1;
i++)
108 for (
int j=
i+1; j<groups.
size(); j++)
111 if (opt.
model() == MODEL_SYMMETRY) {
122 for (
int j=0; j<w; j++) {
123 for (
int p=0;
p < g*s;
p++) {
125 for (
int i=0;
i<g;
i++)
132 for (
int j=0; j<w; j++) {
134 for (
int i=0;
i<g;
i++)
143 for (
int i=0;
i<w;
i++)
158 os <<
"Tournament plan" << std::endl;
160 for (
int j=0; j<w; j++) {
161 os <<
"Week " << j <<
": " << std::endl <<
" ";
162 os << schedule.
row(j) << std::endl;
168 groups.update(*
this, share, s.
groups);
173 return new Golf(share,*
this);
187 opt.
parse(argc,argv);
188 Script::run<Golf,DFS,GolfOptions>(
opt);
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
SetVarArray groups
The sets representing the groups.
SetExpr singleton(const LinIntExpr &e)
Singleton expression.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
int size(void) const
Return size of array (number of elements)
virtual void print(std::ostream &os) const
Print solution.
SetValBranch SET_VAL_MIN_INC(void)
Include smallest element.
int s
Number of players in a group.
Golf(bool share, Golf &s)
Constructor for copying s.
Parametric base-class for scripts.
Golf(const GolfOptions &opt)
Actual model.
SetExpr setdunion(const SetVarArgs &x)
Disjoint union of set variables.
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int s(void) const
Return number of players per group.
GolfOptions(void)
Constructor.
Slice< A > row(int r) const
Access row r.
void precede(Home home, const IntVarArgs &x, int s, int t, IntConLevel)
Post propagator that s precedes t in x.
virtual Space * copy(bool share)
Copy during cloning.
Passing integer variables.
Passing Boolean variables.
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
struct Gecode::@519::NNF::@60::@61 b
For binary nodes (and, or, eqv)
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
Model with symmetry breaking.
int g
Number of groups in a week.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
void solutions(unsigned int n)
Set default number of solutions to search for.
int g(void) const
Return number of groups.
Matrix-interface for arrays.
int main(int argc, char *argv[])
Main-function.
void model(int v)
Set default model value.
BrancherHandle branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl)
Select variable with smallest minimum unknown element.
int w(void) const
Return number of weeks.