| 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 | |