54 _w(
"w",
"number of weeks",9),
55 _g(
"g",
"number of groups",8),
56 _s(
"s",
"number of players per group",4) {
103 g(opt.
g()),
s(opt.
s()),
w(opt.
w()),
105 static_cast<unsigned int>(
s),static_cast<unsigned int>(
s)) {
110 for (
int i=0; i<
w; i++)
123 int playerCount =
g *
s;
126 for (
int p1=0; p1<playerCount-1; p1++)
127 for (
int p2=p1+1; p2<playerCount; p2++)
128 ts.
add({p1, p2, pairCount++});
139 for (
int p1=0; p1<group.
size()-1; ++p1) {
140 for (
int p2=p1+1; p2<group.
size(); ++p2) {
141 IntVar pair(*
this, 0, pairCount);
144 args << group[p1] << group[p2] << pair;
167 for (
int j=0; j<
w; j++) {
168 for (
int p=0;
p <
g*
s;
p++) {
170 for (
int i=0; i<
g; i++)
177 for (
int j=0; j<
w; j++) {
179 for (
int i=0; i<
g; i++)
180 m[i] =
expr(*
this,
min(schedule(i,j)));
188 for (
int i=0; i<
w; i++)
203 os <<
"Tournament plan" << std::endl;
205 for (
int j=0; j<
w; j++) {
206 os <<
"Week " << j <<
": " << std::endl <<
" ";
207 os << schedule.
row(j) << std::endl;
218 return new Golf(*
this);
232 opt.propagation(
Golf::PROP_SET,
"set",
"Use set intersection cardinality for pair play constraints");
233 opt.propagation(
Golf::PROP_INT,
"int",
"Use integer distinct for pair play constraints");
234 opt.propagation(
Golf::PROP_MIXED,
"mixed",
"Use set interesection cardinality and integer distinct for pair play constraints");
237 opt.
parse(argc,argv);
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
int size(void) const
Return size of array (number of elements)
void add(Driver::BaseOption &o)
Add new option o.
Passing Boolean variables.
void value(int v)
Set default value to v.
Parametric base-class for scripts.
static void run(const Options &opt, Script *s=NULL)
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
Passing integer variables.
Matrix-interface for arrays.
Slice< A > row(int r) const
Access row r.
Class represeting a set of tuples.
TupleSet & add(const IntArgs &t)
Add tuple t to tuple set.
void finalize(void)
Finalize tuple set.
int size(void) const
Return size of array (number of elements)
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
int g(void) const
Return number of groups.
int s(void) const
Return number of players per group.
GolfOptions(void)
Constructor.
int w(void) const
Return number of weeks.
int main(int argc, char *argv[])
Main-function.
@ MODEL_PLAIN
A simple model.
@ MODEL_SYMMETRY
Model with symmetry breaking.
virtual void print(std::ostream &os) const
Print solution.
int g
Number of groups in a week.
virtual Space * copy(void)
Copy during cloning.
int s
Number of players in a group.
SetVarArray groups
The sets representing the groups.
@ PROP_MIXED
Propagation of pair play amount using both set and int variables.
@ PROP_SET
Propagation of pair play amount using set variables.
@ PROP_INT
Propagation of pair play amount using int variables and distinct.
Golf(const GolfOptions &opt)
Actual model.
Golf(Golf &s)
Constructor for copying s.
void parse(int argc, char *argv[])
Parse commandline arguments.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
void precede(Home home, const IntVarArgs &x, int s, int t, IntPropLevel=IPL_DEF)
Post propagator that s precedes t in x.
@ IPL_DOM
Domain propagation Options: basic versus advanced propagation.
Gecode toplevel namespace
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
IntVar expr(Home home, const LinIntExpr &e, const IntPropLevels &ipls=IntPropLevels::def)
Post linear expression and return its value.
void distinct(Home home, const IntVarArgs &x, IntPropLevel ipl=IPL_DEF)
Post propagator for for all .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Select variable with smallest minimum unknown element SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl=nullptr)
SetExpr setdunion(const SetVarArgs &)
Disjoint union of set variables.
SetExpr singleton(const LinIntExpr &)
Singleton expression.
Include smallest element SetValBranch SET_VAL_MIN_INC(void)
LinIntExpr cardinality(const SetExpr &)
Cardinality of set expression.