64 static Block*
allocate(
unsigned int n, Block*
p=NULL);
72 static const unsigned int n_dpow = 8U;
85 double decay(
void)
const;
89 void set(Counter&
c,
double a);
91 double val(Counter&
c);
93 static void*
operator new(
size_t s);
95 static void operator delete(
void*
p);
98 static const unsigned int size_min = 32;
100 static const unsigned int size_max = 32 * 1024;
111 unsigned int use_cnt;
121 static void*
operator new(
size_t s);
123 static void operator delete(
void*
p);
128 Object* object(
void)
const;
130 bool local(
void)
const;
132 void local(Object* o);
134 void global(
void* mo);
145 double decay(
void)
const;
147 void fail(Counter&
c);
149 void set(Counter&
c,
double a);
151 double afc(Counter&
c);
164 GlobalAFC::DecayManager::decay(
double d0) {
175 GlobalAFC::DecayManager::DecayManager(
void)
179 GlobalAFC::DecayManager::decay(
void)
const {
183 GlobalAFC::DecayManager::decay(Counter&
c) {
184 assert((
t >= c.t) && (
d != 1.0));
185 unsigned int n =
t - c.t;
190 c.c *=
pow(
d,static_cast<double>(n));
196 GlobalAFC::DecayManager::inc(Counter& c) {
201 c.c += 1.0; c.t = ++
t;
205 GlobalAFC::DecayManager::val(Counter& c) {
211 GlobalAFC::DecayManager::set(Counter& c,
double a) {
215 GlobalAFC::DecayManager::operator
new(
size_t s) {
219 GlobalAFC::DecayManager::operator
delete(
void*
p) {
230 GlobalAFC::Object::operator
new(
size_t s) {
235 GlobalAFC::Object::operator
delete(
void*
p) {
240 GlobalAFC::Block::allocate(
unsigned int n, GlobalAFC::Block*
p) {
241 Block*
b =
static_cast<Block*
>(
heap.
ralloc(
sizeof(Block)+
242 (n-1)*
sizeof(Counter)));
249 : mutex(m), parent(p), use_cnt(1),
size(size_min), free(size_min),
251 if (parent == NULL) {
252 decay =
new DecayManager;
254 decay = parent->decay;
259 GlobalAFC::object(
void)
const {
263 GlobalAFC::local(
void)
const {
267 GlobalAFC::local(Object* o) {
272 GlobalAFC::global(
void* o) {
285 Object* o = object();
295 Object* c = object();
296 DecayManager*
decay = c->decay;
297 while ((c != NULL) && (--c->use_cnt == 0)) {
301 Block*
d =
b; b=b->next;
305 Object*
d =
c; c = c->parent;
320 object()->decay->inc(c);
328 object()->decay->set(c,a);
337 d = object()->decay->val(c);
347 d = object()->decay->decay();
356 object()->decay->decay(d);
369 local(
new Object(
object()->mutex,
object()));
373 Object* o = object();
376 if (2*o->size <= size_max)
379 o->cur = Block::allocate(o->size,o->cur);
382 Counter* c = &o->cur->c[--o->free];
bool marked(void *p)
Check whether p is marked.
double c
The counter value.
void rfree(void *p)
Free memory block starting at p.
~GlobalAFC(void)
Destructor.
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for $n 0$.
void acquire(void)
Acquire the mutex and possibly block.
void * ralloc(size_t s)
Allocate s bytes from heap.
GlobalAFC(void)
Initialize.
Heap heap
The single global heap.
A mutex for mutual exclausion among several threads.
void fail(Counter &c)
Increment failure count.
void * funmark(void *p)
Return unmarked pointer for a possibly marked pointer p.
void release(void)
Release the mutex.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void init(void)
Initialize.
double decay(void) const
Return decay factor.
Class for storing timed-decay value.
Globally shared object for propagator information.
double afc(Counter &c)
Return failure count.
Counter & allocate(void)
Allocate new propagator info.
void * fmark(void *p)
Return marked pointer for p (possibly already marked)
void set(Counter &c, double a)
Set failure count to a.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
unsigned long int t
The time-stamp.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.