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

Function relax

gecode/search/relax.hh:50–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49 template<class VarArgs, class Post>
50 forceinline void
51 relax(Home home, const VarArgs& x, const VarArgs& sx, Rnd r,
52 double p, Post& post) {
53 if (home.failed())
54 return;
55 Region reg;
56 // Which variables to assign
57 Support::BitSet<Region> ax(reg, static_cast<unsigned int>(x.size()));
58 // Select randomly with probability p to relax value
59 for (int i=0; i<x.size(); i++)
60 if (r(UINT_MAX) >=
61 static_cast<unsigned int>(p * static_cast<double>(UINT_MAX)))
62 ax.set(static_cast<unsigned int>(i));
63 if (ax.all())
64 // Choose one variable uniformly and unset it
65 ax.clear(r(static_cast<unsigned int>(x.size())));
66 for (Iter::Values::BitSet<Support::BitSet<Region> > i(ax); i(); ++i)
67 if (post(home, x[i.val()], sx[i.val()]) != ES_OK) {
68 home.failed();
69 return;
70 }
71 }
72
73}}
74

Callers

nothing calls this directly

Calls 9

rFunction · 0.85
iFunction · 0.50
postFunction · 0.50
failedMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45
allMethod · 0.45
clearMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected