MCPcopy Create free account
hub / github.com/Gecode/gecode / Photo

Method Photo

examples/photo.cpp:97–130  ·  view source on GitHub ↗

Actual model

Source from the content-addressed store, hash-verified

95 };
96 /// Actual model
97 Photo(const SizeOptions& opt) :
98 IntMinimizeScript(opt),
99 spec(opt.size()),
100 pos(*this,spec.people(), 0, spec.people()-1),
101 violations(*this,0,spec.preferences()),
102 rnd(opt.seed()), p(opt.relax())
103 {
104 // Map preferences to violation
105 BoolVarArgs viol(spec.preferences());
106 for (int i=0; i<spec.preferences(); i++) {
107 int pa = spec.preference(i,0);
108 int pb = spec.preference(i,1);
109 viol[i] = expr(*this, abs(pos[pa]-pos[pb]) > 1);
110 }
111 rel(*this, violations == sum(viol));
112
113 distinct(*this, pos, opt.ipl());
114
115 // Break some symmetries
116 rel(*this, pos[0] < pos[1]);
117
118 switch (opt.branching()) {
119 case BRANCH_NONE:
120 branch(*this, pos, INT_VAR_NONE(), INT_VAL_MIN());
121 break;
122 case BRANCH_DEGREE:
123 branch(*this, pos, tiebreak(INT_VAR_DEGREE_MAX(),INT_VAR_SIZE_MIN()),
124 INT_VAL_MIN());
125 break;
126 case BRANCH_AFC_SIZE:
127 branch(*this, pos, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN());
128 break;
129 }
130 }
131 /// Slave function for restarts
132 bool slave(const MetaInfo& mi) {
133 if ((mi.type() == MetaInfo::RESTART) &&

Callers

nothing calls this directly

Calls 15

distinctFunction · 0.85
INT_VAR_NONEFunction · 0.85
INT_VAL_MINFunction · 0.85
tiebreakFunction · 0.85
INT_VAR_DEGREE_MAXFunction · 0.85
INT_VAR_SIZE_MINFunction · 0.85
INT_VAR_AFC_SIZE_MAXFunction · 0.85
peopleMethod · 0.80
relaxMethod · 0.80
preferenceMethod · 0.80
branchingMethod · 0.80
exprFunction · 0.50

Tested by

no test coverage detected