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

Method slave

examples/qcp.cpp:215–248  ·  view source on GitHub ↗

Slave function for portfolio search

Source from the content-addressed store, hash-verified

213 }
214 /// Slave function for portfolio search
215 virtual bool slave(const MetaInfo& mi) {
216 if (mi.type() == MetaInfo::PORTFOLIO) {
217 double tbf = opt.tbf();
218 Rnd r(seeds[mi.asset() % n_seeds]);
219 switch (opt.branching()) {
220 case BRANCH_SIZE:
221 {
222 auto tbl =
223 [tbf] (const Space&, double w, double b) {
224 assert(w >= b);
225 return b + (w - b) * tbf;
226 };
227 branch(*this, e, tiebreak(INT_VAR_SIZE_MIN(tbl),
228 INT_VAR_RND(r)),
229 INT_VAL_MIN());
230 }
231 break;
232 case BRANCH_AFC_SIZE:
233 {
234 auto tbl =
235 [tbf] (const Space&, double w, double b) {
236 assert(b >= w);
237 return b - (b - w) * tbf;
238 };
239 branch(*this, e, tiebreak(INT_VAR_AFC_SIZE_MAX(opt.decay(), tbl),
240 INT_VAR_RND(r)),
241 INT_VAL_MIN());
242 }
243 break;
244 default: ;
245 }
246 }
247 return true;
248 }
249 /// Constructor for cloning \a s
250 QCP(QCP& s)
251 : Script(s), opt(s.opt), spec(s.spec) {

Callers

nothing calls this directly

Calls 11

tiebreakFunction · 0.85
INT_VAR_SIZE_MINFunction · 0.85
INT_VAR_RNDFunction · 0.85
INT_VAL_MINFunction · 0.85
INT_VAR_AFC_SIZE_MAXFunction · 0.85
assetMethod · 0.80
branchingMethod · 0.80
branchFunction · 0.50
typeMethod · 0.45
tbfMethod · 0.45
decayMethod · 0.45

Tested by

no test coverage detected