41 namespace Gecode {
namespace Int {
namespace LDSB {
45 : _variable(-1), _value(-1) {}
49 : _variable(idx), _value(val) {}
55 if (
d > 0)
return true;
64 const Val&
n,
const Literal* literals,
93 for (
int i = 0 ;
i < _nliterals ;
i++) {
94 e << _literals[
i]._variable;
95 e << _literals[
i]._value;
101 template<
class View,
int n,
class Val,
unsigned int a,
102 class Filter,
class Print>
110 :
ViewValBrancher<View,
n,Val,
a,Filter,Print>(home,
x, vs, vsc, bf, vvp),
118 template<
class View,
int n,
class Val,
unsigned int a,
119 class Filter,
class Print>
128 (home,
x,vs,vsc,syms,nsyms,bf,vvp);
131 template<
class View,
int n,
class Val,
unsigned int a,
132 class Filter,
class Print>
139 _prevPos(
b._prevPos) {
145 template<
class View,
int n,
class Val,
unsigned int a,
146 class Filter,
class Print>
155 template<
class View,
int n,
class Val,
unsigned int a,
156 class Filter,
class Print>
165 int choicePos = pvc->
pos().pos;
166 int choiceVal = pvc->
val();
169 _prevPos = choicePos;
173 std::deque<Literal> queue;
174 std::set<Literal> seen;
176 seen.insert(
Literal(choicePos, choiceVal));
177 queue.push_back(
Literal(choicePos, choiceVal));
183 for (
int i = 0 ;
i < _nsyms ;
i++) {
185 for (
int j = 0 ; j < toExclude.
size() ; ++j) {
186 if (seen.find(toExclude[j]) == seen.end())
187 queue.push_back(toExclude[j]);
188 seen.insert(toExclude[j]);
191 }
while (queue.size() > 0);
194 int nliterals =
static_cast<int>(seen.size());
196 std::set<Literal>::iterator it = seen.begin();
197 for (
int i = 0 ;
i < nliterals ;
i++) {
202 return new LDSBChoice<Val>(*
this,
a,choicePos,choiceVal, literals, nliterals);
206 template<
class View,
int n,
class Val,
unsigned int a,
207 class Filter,
class Print>
214 int nliterals; e >> nliterals;
216 for (
int i = 0 ;
i < nliterals ;
i++) {
227 return x.nq(home,
v);
234 return x.nq(home,
v);
238 template<
class View,
int n,
class Val,
unsigned int a,
239 class Filter,
class Print>
245 int choicePos = pvc.
pos().pos;
246 int choiceVal = pvc.
val();
253 for (
int i = 0 ;
i < this->_nsyms ;
i++)
254 this->_syms[
i]->update(
Literal(choicePos, choiceVal));
264 for (
int i = 0 ;
i < nliterals ;
i++) {
266 ModEvent me = prune<View>(home, this->x[
l._variable],
l._value);
274 template<
class View,
int n,
class Val,
unsigned int a,
275 class Filter,
class Print>
283 template<
class View,
int n,
class Val,
unsigned int a>
295 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
298 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
303 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
306 ::post(home,
x,vs,vsc,syms,nsyms,bf,vvp);
virtual ExecStatus commit(Space &home, const Choice &c, unsigned int b)
Perform commit for choice c and alternative b.
int size(void) const
Return size of array (number of elements)
virtual size_t size(void) const
Report size occupied.
A Literal is a pair of variable index and value.
Actor must always be disposed.
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...
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.
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.
int ModEvent
Type for modification events.
virtual void archive(Archive &e) const
Archive into e.
int _value
The value of the literal. For int and bool variables, this is the value itself; for set variables...
int _variable
Variable index. The ViewArray that the index is meant for is assumed to be known by context...
Class storing a print function.
const Pos & pos(void) const
Return position in array.
Class without print function.
Base-class for both propagators and branchers.
virtual ExecStatus commit(Space &home, const Choice &c, unsigned int b)
Perform commit for choice c and alternative b.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
virtual size_t dispose(Space &home)
Delete brancher and return its size.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
bool operator<(const Literal &rhs) const
Less than. The ordering is the lexicographical order on the (variable,value) pair.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Choice storing position and value, and symmetric literals to be excluded on the right branch...
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
int n
Number of negative literals for node type.
Argument array for non-primitive types.
Generic brancher by view and value selection.
Literal(void)
Constructor for an empty literal.
std::function< bool(const Space &home, Var x, int i)> BranchFilter
Function type for branch filter functions.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
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.
Symmetry-breaking brancher with generic view and value selection.
const Val & val(void) const
Return value to branch with.
virtual const Choice * choice(Space &home)
Return choice.
~LDSBChoice(void)
Destructor.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
int nliterals(void) const
Return number of literals.
Integer view for integer variables.
Implementation of a single symmetry.
virtual void archive(Archive &e) const
Archive into e.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Choice for performing commit
Post propagator for SetVar x
int _nsyms
Number of symmetry implementations.
SymmetryImp< View > ** _syms
Array of symmetry implementations.
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
const Literal * literals(void) const
Return literals.
LDSBBrancher(Space &home, bool share, LDSBBrancher &b)
Constructor for cloning b.
Gecode toplevel namespace
Home class for posting propagators
Choice storing position and value
virtual const Choice * choice(Space &home)
Return choice.
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
virtual Actor * copy(Space &home, bool share)
Perform cloning.
Boolean view for Boolean variables.