50 :
Support::RawBitSetBase(
r,static_cast<unsigned int>(n)) {}
54 :
Support::RawBitSetBase(
r,static_cast<unsigned int>(n),ns) {}
65 return RawBitSetBase::get(
static_cast<unsigned int>(i));
69 RawBitSetBase::set(
static_cast<unsigned int>(i));
73 RawBitSetBase::clear(
static_cast<unsigned int>(i));
77 RawBitSetBase::copy(
static_cast<unsigned int>(n),ns);
81 RawBitSetBase::clearall(
static_cast<unsigned int>(n));
87 unsigned int n =
static_cast<unsigned int>(_n);
89 unsigned int pos = n /
bpb;
90 unsigned int bits = n %
bpb;
94 for (
unsigned int i=0; i<pos; i++) {
103 abc.
o(cwa.
data[pos],bits);
104 abc.
o(cwb.
data[pos],bits);
106 assert(cwa.
get(n) && cwb.
get(n));
116 : ns(ns0), c(ns.next(0)) {}
123 return static_cast<int>(c);
128 :
n(
r,m),
c(0),
w(0) {}
131 n.incl(i);
c++;
w += wi;
135 n.excl(i);
c--;
w -= wi;
142 bins(static_cast<unsigned int>(m)),
145 for (
int i=0; i<
nodes(); i++) {
158 assert(!
node[i].n.in(j) && !
node[j].n.in(i));
162 assert(
node[i].n.in(j) &&
node[j].n.in(i));
170 assert(
node[i].n.in(j) ==
node[j].n.in(i));
171 return node[i].n.in(j);
184 unsigned int m =
node[p].d;
185 while (i() <
nodes()) {
186 if (
node[i()].d > m) {
191 while (j() <
nodes()) {
192 if (
node[j()].d > m) {
213 assert(i ==
static_cast<int>(
cur.c));
228 unsigned int w =
node[i].w +
node[j].w;
231 max.n.incl(i);
max.n.incl(j);
244 max.n.incl(i);
max.n.incl(j);
max.n.incl(k);
251 bv[0]=
b[i]; bv[1]=
b[j]; bv[2]=
b[k];
264 for (
int i=0; i<
nodes(); i++) {
265 if ((
node[i].d == 1) || (
node[i].d == 2))
280 if ((
node[j].d == 1) || (
node[j].d == 2))
291 if ((
node[j].d == 2) || (
node[k].d == 2))
299 if ((
node[j].d == 1) || (
node[j].d == 2))
301 if ((
node[k].d == 1) || (
node[k].d == 2))
314 for (
int i=0; i<
nodes(); i++)
316 p.incl(i); empty =
false;
336 assert(j ==
static_cast<int>(
max.c));
Home class for posting propagators
Passing integer variables.
Clique(Region &r, int m)
Constructor for m nodes.
void excl(int i, unsigned int w)
Exclude node i with weight w.
NodeSet n
Nodes in the clique.
void incl(int i, unsigned int w)
Include node i with weight w.
unsigned int c
Cardinality of clique.
unsigned int w
Weight of clique.
void empty(int n)
Clear the whole node set for n nodes.
void incl(int i)
Include node i.
NodeSet(void)
Keep uninitialized.
static bool iwn(NodeSet &iwa, const NodeSet &a, NodeSet &iwb, const NodeSet &b, const NodeSet &c, int n)
void init(Region &r, int n)
Initialize node set for n nodes.
bool in(int i) const
Test whether node i is included.
void allocate(Region &r, int n)
Allocate node set for n nodes.
void copy(int n, const NodeSet &ns)
Copy elements from node set ns with n nodes.
void excl(int i)
Exclude node i.
Node(void)
Default constructor.
void operator++(void)
Move iterator to next node (if possible)
Nodes(const NodeSet &ns)
Initialize for nodes in ns.
int operator()(void) const
Return current node.
Clique cur
Current clique.
ExecStatus clique(void)
Report the current clique.
int nodes(void) const
Return number of nodes.
ExecStatus post(void)
Post additional constraints.
ConflictGraph(Home &home, Region &r, const IntVarArgs &b, int m)
Initialize graph.
int pivot(const NodeSet &a, const NodeSet &b) const
Find a pivot node with maximal degree from a or b.
~ConflictGraph(void)
Destructor.
bool adjacent(int i, int j) const
Test whether nodes i and j are adjacent.
Node * node
The nodes in the graph.
ExecStatus bk(NodeSet &p, NodeSet &x)
Run Bosch-Kerbron algorithm for finding max cliques.
unsigned int bins
Number of bins.
void edge(int i, int j, bool add=true)
Add or remove an edge between nodes i and j (i must be less than j)
const IntVarArgs & b
Bin variables.
Clique max
Largest clique so far.
IntSet maxclique(void) const
Return maximal clique found.
static ExecStatus post(Home home, ViewArray< View > &x)
Post propagator for views x.
static ExecStatus post(Home home, V0 x0, V1 x1)
Post propagator .
void free(void)
Free allocate memory.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
void init(bool setbits=false)
Initialize with all bits set if setbits.
void a(BitSetData a)
Perform "and" with a.
bool none(void) const
Whether no bits are set.
void o(BitSetData a)
Perform "or" with a.
bool get(unsigned int i) const
Access value at bit i.
void init(A &a, unsigned int sz, bool setbits=false)
Initialize for sz bits and allocator a (only after default constructor)
static const unsigned int bpb
Bits per base.
void allocate(A &a, unsigned int sz)
Allocate for sz bits and allocator a (only after default constructor)
BitSetData * data
Stored bits.
Stack with fixed number of elements.
void push(const T &x)
Push element x on top of stack.
T pop(void)
Pop topmost element from stack and return it.
bool empty(void) const
Test whether stack is empty.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Support algorithms and datastructures
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
@ ES_OK
Execution is okay.
@ ES_FAILED
Execution has resulted in failure.
Post propagator for SetVar x
#define GECODE_NEVER
Assert that this command is never executed.