51 if (d > 0)
return true;
83 for (
int i = 0 ; i < _nliterals ; i++) {
84 e << _literals[i]._variable;
85 e << _literals[i]._value;
91 template<
class View,
int n,
class Val,
unsigned int a,
92 class Filter,
class Print>
100 :
ViewValBrancher<
View,n,
Val,a,Filter,Print>(home,
x, vs, vsc, bf, vvp),
108 template<
class View,
int n,
class Val,
unsigned int a,
109 class Filter,
class Print>
118 (home,
x,
vs,
vsc,syms,nsyms,bf,vvp);
121 template<
class View,
int n,
class Val,
unsigned int a,
122 class Filter,
class Print>
129 _prevPos(b._prevPos) {
131 for (
int i = 0 ; i <
_nsyms ; i++)
132 _syms[i] = b._syms[i]->copy(home);
135 template<
class View,
int n,
class Val,
unsigned int a,
136 class Filter,
class Print>
145 template<
class View,
int n,
class Val,
unsigned int a,
146 class Filter,
class Print>
155 int choicePos = pvc->
pos().
pos;
156 int choiceVal = pvc->
val();
163 std::deque<Literal> queue;
164 std::set<Literal> seen;
166 seen.insert(
Literal(choicePos, choiceVal));
167 queue.push_back(
Literal(choicePos, choiceVal));
173 for (
int i = 0 ; i <
_nsyms ; i++) {
175 for (
int j = 0 ; j < toExclude.
size() ; ++j) {
176 if (seen.find(toExclude[j]) == seen.end())
177 queue.push_back(toExclude[j]);
178 seen.insert(toExclude[j]);
181 }
while (queue.size() > 0);
184 int nliterals =
static_cast<int>(seen.size());
186 std::set<Literal>::iterator it = seen.begin();
187 for (
int i = 0 ; i < nliterals ; i++) {
192 return new LDSBChoice<Val>(*
this,a,choicePos,choiceVal, literals, nliterals);
196 template<
class View,
int n,
class Val,
unsigned int a,
197 class Filter,
class Print>
204 int nliterals; e >> nliterals;
206 for (
int i = 0 ; i < nliterals ; i++) {
217 return x.nq(home, v);
224 return x.nq(home, v);
228 template<
class View,
int n,
class Val,
unsigned int a,
229 class Filter,
class Print>
235 int choicePos = pvc.
pos().
pos;
236 int choiceVal = pvc.
val();
243 for (
int i = 0 ; i < this->_nsyms ; i++)
254 for (
int i = 0 ; i < nliterals ; i++) {
255 const Literal& l = literals[i];
264 template<
class View,
int n,
class Val,
unsigned int a,
265 class Filter,
class Print>
273 template<
class View,
int n,
class Val,
unsigned int a>
285 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
288 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
293 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
296 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
Base-class for both propagators and branchers.
int size(void) const
Return size of array (number of elements)
Argument array for non-primitive types.
Class without print function.
Class storing a print function.
Base-class for branchers.
Choice for performing commit
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Boolean view for Boolean variables.
Integer view for integer variables.
Symmetry-breaking brancher with generic view and value selection.
static void post(Home home, ViewArray< View > &x, ViewSel< View > *vs[n], ValSelCommitBase< View, Val > *vsc, SymmetryImp< View > **syms, int nsyms, BranchFilter< Var > bf, VarValPrint< Var, Val > vvp)
Brancher post function.
int _nsyms
Number of symmetry implementations.
SymmetryImp< View > ** _syms
Array of symmetry implementations.
virtual const Choice * choice(Space &home)
Return choice.
virtual Actor * copy(Space &home)
Perform cloning.
LDSBBrancher(Space &home, LDSBBrancher &b)
Constructor for cloning b.
virtual size_t dispose(Space &home)
Delete brancher and return its size.
Choice storing position and value, and symmetric literals to be excluded on the right branch.
int nliterals(void) const
Return number of literals.
const Literal * literals(void) const
Return literals.
LDSBChoice(const Brancher &b, unsigned int a, const Pos &p, const Val &n, const Literal *literals, int nliterals)
Initialize choice for brancher b, position p, value n, and set of literals literals (of size nliteral...
virtual void archive(Archive &e) const
Archive into e.
~LDSBChoice(void)
Destructor.
A Literal is a pair of variable index and value.
bool operator<(const Literal &rhs) const
Less than. The ordering is the lexicographical order on the (variable,value) pair.
Literal(void)
Constructor for an empty literal.
int _variable
Variable index. The ViewArray that the index is meant for is assumed to be known by context.
int _value
The value of the literal. For int and bool variables, this is the value itself; for set variables,...
Implementation of a single symmetry.
const Pos & pos(void) const
Return position in array.
Choice storing position and value
const Val & val(void) const
virtual void archive(Archive &e) const
Archive into e.
PosValChoice(const Brancher &b, unsigned int a, const Pos &p, const Val &n)
Initialize choice for brancher b, number of alternatives a, position p, and value n.
const int pos
Position of view.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
ViewArray< View > x
Views to branch on.
ViewSel< View > * vs[n]
View selection objects.
Abstract class for view selection.
Generic brancher by view and value selection.
virtual const Choice * choice(Space &home)
Return choice.
View::VarType Var
The corresponding variable.
ViewValBrancher(Space &home, ViewValBrancher &b)
Constructor for cloning b.
ValSelCommitBase< View, Val > * vsc
Value selection and commit object.
virtual size_t dispose(Space &home)
Delete brancher and return its size.
void update(const NoOffset &)
Integer-precision integer scale view.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
@ AP_DISPOSE
Actor must always be disposed.
Symmetry breaking for integer variables.
ModEvent prune(Space &home, View x, int v)
Exclude value \v from variable view \x.
ModEvent prune< Int::BoolView >(Space &home, Int::BoolView x, int v)
void postldsbbrancher(Home home, ViewArray< View > &x, ViewSel< View > *vs[n], ValSelCommitBase< View, Val > *vsc, SymmetryImp< View > **syms, int nsyms, BranchFilter< typename View::VarType > bf, VarValPrint< typename View::VarType, Val > vvp)
Post LDSB brancher.
ModEvent prune< Int::IntView >(Space &home, Int::IntView x, int v)
Gecode toplevel namespace
std::function< void(const Space &home, const Brancher &b, unsigned int a, Var x, int i, const Val &m, std::ostream &o)> VarValPrint
Function type for printing variable and value selection.
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
@ ES_OK
Execution is okay.
Post propagator for SetVar x
std::function< bool(const Space &home, Var x, int i)> BranchFilter
Function type for branch filter functions.
int ModEvent
Type for modification events.