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,
66 :
PosValChoice<Val>(b,a,p,n), _literals(literals), _nliterals(nliterals)
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>
117 template<
class View,
int n,
class Val,
unsigned int a>
123 BranchFilter bf, VarValPrint vvp) {
124 return *
new (home)
LDSBBrancher<View,n,Val,a>(home,x,vs,vsc,syms,nsyms,bf,vvp);
127 template<
class View,
int n,
class Val,
unsigned int a>
133 _prevPos(b._prevPos) {
139 template<
class View,
int n,
class Val,
unsigned int a>
147 template<
class View,
int n,
class Val,
unsigned int a>
156 int choicePos = pvc->
pos().pos;
157 int choiceVal = pvc->
val();
160 _prevPos = choicePos;
164 std::deque<Literal> queue;
165 std::set<Literal> seen;
167 seen.insert(
Literal(choicePos, choiceVal));
168 queue.push_back(
Literal(choicePos, choiceVal));
174 for (
int i = 0 ;
i < _nsyms ;
i++) {
176 for (
int j = 0 ; j < toExclude.
size() ; ++j) {
177 if (seen.find(toExclude[j]) == seen.end())
178 queue.push_back(toExclude[j]);
179 seen.insert(toExclude[j]);
182 }
while (queue.size() > 0);
185 int nliterals = seen.
size();
187 std::set<Literal>::iterator it = seen.begin();
188 for (
int i = 0 ;
i < nliterals ;
i++) {
193 return new LDSBChoice<Val>(*
this,
a,choicePos,choiceVal, literals, nliterals);
197 template<
class View,
int n,
class Val,
unsigned int a>
203 int nliterals; e >> nliterals;
205 for (
int i = 0 ;
i < nliterals ;
i++) {
216 return x.nq(home,
v);
223 return x.nq(home,
v);
227 template<
class View,
int n,
class Val,
unsigned int a>
233 int choicePos = pvc.
pos().pos;
234 int choiceVal = pvc.
val();
240 for (
int i = 0 ;
i < this->_nsyms ;
i++)
241 this->_syms[
i]->update(
Literal(choicePos, choiceVal));
250 for (
int i = 0 ;
i < nliterals ;
i++) {
260 template<
class View,
int n,
class Val,
unsigned int a>
const Pos & pos(void) const
Return position in array.
int _nsyms
Number of symmetry implementations.
const Val & val(void) const
Return value to branch with.
A Literal is a pair of variable index and value.
Actor must always be disposed.
int size(void) const
Return size of array (number of elements)
bool operator<(const Literal &rhs) const
Less than. The ordering is the lexicographical order on the (variable,value) pair.
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 Actor * copy(Space &home, bool share)
Perform cloning.
virtual size_t size(void) const
Report size occupied.
virtual ExecStatus commit(Space &home, const Choice &c, unsigned int b)
Perform commit for choice c and alternative b.
int ModEvent
Type for modification events.
virtual const Choice * choice(Space &home)
Return choice.
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...
SymmetryImp< View > ** _syms
Array of symmetry implementations.
Base-class for both propagators and branchers.
int nliterals(void) const
Return number of literals.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
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.
virtual size_t dispose(Space &home)
Delete brancher and return its size.
Generic brancher by view and value selection.
Literal(void)
Constructor for an empty literal.
Symmetry-breaking brancher with generic view and value selection.
~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.
Integer view for integer variables.
Implementation of a single symmetry.
virtual const Choice * choice(Space &home)
Return choice.
Node * x
Pointer to corresponding Boolean expression node.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Choice for performing commit
static BrancherHandle post(Home home, ViewArray< View > &x, ViewSel< View > *vs[n], ValSelCommitBase< View, Val > *vsc, SymmetryImp< View > **syms, int nsyms, BranchFilter bf, VarValPrint vvp)
Brancher post function.
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
virtual void archive(Archive &e) const
Archive into e.
LDSBBrancher(Space &home, bool share, LDSBBrancher &b)
Constructor for cloning b.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
const Literal * literals(void) const
Return literals.
virtual void archive(Archive &e) const
Archive into e.
virtual ExecStatus commit(Space &home, const Choice &c, unsigned int b)
Perform commit for choice c and alternative b.
Home class for posting propagators
Choice storing position and value
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Boolean view for Boolean variables.