51 : n_names(n_n), n_prefs(n_p), prefs(p) {}
56 0,2, 1,4, 2,3, 2,4, 3,0, 4,3, 4,0, 4,1
63 0,2, 0,4, 0,7, 1,4, 1,8, 2,3, 2,4, 3,0, 3,4,
64 4,5, 4,0, 5,0, 5,8, 6,2, 6,7, 7,8, 7,6
98 pos(*this,spec.n_names, 0, spec.n_names-1),
99 violations(*this,0,spec.n_prefs)
104 int pa = spec.
prefs[2*
i+0];
105 int pb = spec.
prefs[2*
i+1];
106 viol[
i] =
expr(*
this,
abs(pos[pa]-pos[pb]) > 1);
108 rel(*
this, violations ==
sum(viol));
113 rel(*
this, pos[0] < pos[1]);
132 return new Photo(share,*
this);
137 os <<
"\tpos[] = " << pos << std::endl
138 <<
"\tviolations: " << violations << std::endl;
159 opt.
parse(argc,argv);
160 IntMaximizeScript::run<Photo,BAB,SizeOptions>(
opt);
void size(unsigned int s)
Set default size.
PhotoSpec(const int n_n, const int n_p, const int *p)
Options for scripts with additional size parameter
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
const PhotoSpec p_small(5, 8, s_prefs)
Small Photo example.
Example: Placing people on a photo
const PhotoSpec & spec
Photo specification.
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
virtual Space * copy(bool share)
Copy during cloning.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
Parametric base-class for scripts.
const int n_names
Number of people on picture.
void iterations(unsigned int i)
Set default number of iterations.
int main(int argc, char *argv[])
Main-function.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
int p
Number of positive literals for node type.
const int l_prefs[]
Preferences for large example.
Gecode::IntArgs i(4, 1, 2, 3, 4)
IntVarBranch INT_VAR_DEGREE_MAX(BranchTbl tbl)
Select variable with largest degree.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
unsigned int size(I &i)
Size of all ranges of range iterator i.
virtual void print(std::ostream &os) const
Print solution.
void branching(int v)
Set default branching value.
IntVarArray pos
Person's position on photo.
Passing Boolean variables.
virtual IntVar cost(void) const
Return solution cost.
const int s_prefs[]
Preferences for small example.
const int * prefs
Array of preferences.
TieBreak< VarBranch > tiebreak(VarBranch a, VarBranch b)
Combine variable selection criteria a and b for tie-breaking.
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
const int n_prefs
Number of preferences.
const PhotoSpec p_large(9, 17, l_prefs)
Large Photo example.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Photo(const SizeOptions &opt)
Actual model.
void distinct(Home home, const IntVarArgs &x, IntConLevel icl)
Post propagator for for all .
void solutions(unsigned int n)
Set default number of solutions to search for.
Choose variables from left to right.
Photo(bool share, Photo &s)
Constructor for cloning s.
Specifications for the photo example.
Bounds propagation or consistency.
Gecode toplevel namespace
LinFloatExpr sum(const FloatVarArgs &x)
Construct linear float expression as sum of float variables.
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.
IntVar violations
Number of violated preferences.
Choose variable with largest degree.
void icl(IntConLevel i)
Set default integer consistency level.