42 namespace Gecode {
namespace Int {
namespace Extensional {
51 Incremental<View>::SupportAdvisor::
52 SupportAdvisor(Space& home, Propagator&
p, Council<SupportAdvisor>&
c,
54 : Advisor(home,
p,
c),
i(i0) {}
58 Incremental<View>::SupportAdvisor::
59 SupportAdvisor(Space& home,
bool share, SupportAdvisor&
a)
60 : Advisor(home,share,
a),
i(
a.
i) {}
64 Incremental<View>::SupportAdvisor::
65 dispose(Space& home, Council<SupportAdvisor>&
c) {
66 Advisor::dispose(home,
c);
159 return home.fl_alloc<
sizeof(
WorkEntry)>();
211 int literals = static_cast<int>(
ts()->domsize*
x.size());
213 for (
int i = literals;
i--; )
220 for (
int i =
x.size();
i--; ) {
221 int pos = (
i*static_cast<int>(
ts()->domsize)) + (
l[
i] -
ts()->
min);
246 for (
int j =
x.size(); j--; ) {
249 int pos = (j*(static_cast<int>(
ts()->domsize))) + ov;
254 while ((*a)->t !=
l) {
255 assert((*a)->next() != NULL);
283 for (
int i =
x.size();
i--; )
287 x[
i].subscribe(home,*
new (home) SupportAdvisor(home,*
this,ac,
i));
295 for (
int i =
x.size();
i--; )
301 View::schedule(home,*
this,
309 if (!w_support.empty() || !w_remove.empty() || (unassigned == 0))
310 View::schedule(home,*
this,
318 for (
int i =
x.size();
i--; ) {
329 :
Base<View,false>(home,share,
p), support_data(NULL),
330 unassigned(
p.unassigned) {
334 for (
int i = static_cast<int>(
ts()->domsize*
x.size());
i--; ) {
369 int literals = static_cast<int>(ts()->domsize*
x.size());
370 for (
int i = literals;
i--; )
371 if (support_data[
i]) {
373 while (lastse->
next() != NULL)
374 lastse = lastse->
next();
375 support_data[
i]->
dispose(home, lastse);
381 return sizeof(*this);
387 assert(!w_support.empty() || !w_remove.empty() || unassigned==0);
396 while (!w_support.empty() || !w_remove.empty()) {
397 while (!w_remove.empty()) {
399 w_remove.pop(home,
i,
n);
401 if (
dom[
i].get(static_cast<unsigned int>(
n-ts()->
min))) {
403 dom[
i].clear(static_cast<unsigned int>(
n-ts()->
min));
406 while (!w_support.empty()) {
408 w_support.pop(home,
i,
n);
410 if (
dom[
i].get(static_cast<unsigned int>(
n-ts()->
min)))
411 find_support(home,
dom,
i,
n);
424 SupportAdvisor&
a = static_cast<SupportAdvisor&>(
_a);
426 bool scheduled = !w_support.empty() || !w_remove.empty();
430 for (
int n = ts()->
min;
n <= ts()->max;
n++) {
431 if (vv() && (
n == vv.
val())) {
436 remove_support(home, s->t,
a.i,
n);
439 for (
int n =
x[
a.i].min(
d);
n <=
x[
a.i].max(
d);
n++)
441 remove_support(home, s->t,
a.i,
n);
448 if (((w_support.empty() && w_remove.empty()) || scheduled) &&
453 }
else if ((w_support.empty() && w_remove.empty()) || scheduled) {
SupportEntry * next(void) const
Return next support entry.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Work w_remove
Work for removing values.
void init_dom(Space &home, Domain dom)
Initialize domain information.
Description of work to be done.
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
virtual void reschedule(Space &home)
Schedule function.
ExecStatus ES_SUBSUMED(Propagator &p)
void update(Space &home, bool share, Council< A > &c)
Update during cloning (copies all advisors)
Tuple find_support(Domain dom, int i, int n)
Find support for view at position i and value n.
FreeList * next(void) const
Return next freelist object.
void dispose(Space &home)
Free memory for this element.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
WorkEntry(int i, int n, WorkEntry *ne)
Initialize with position i, value n, and next entry ne.
size_t dispose(Space &home)
Delete propagator and return its size.
bool pos(const View &x)
Test whether x is postive.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
int ModEvent
Type for modification events.
ExecStatus ES_NOFIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed and its propagator must be run
Value iterator for integer views.
void dispose(Space &home, SupportEntry *l)
Free memory for all elements between this and l (inclusive)
Propagation has computed fixpoint.
void add_support(Space &home, Tuple l)
Add support.
WorkEntry * next(void) const
Return next work entry.
void init_support(Space &home)
Initialize support.
int val(void) const
Return current value.
Base-class for both propagators and branchers.
SupportEntry ** support_data
Support information.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
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.
void remove_support(Space &home, Tuple l, int i, int n)
Remove support for view at position i and value n.
SupportEntry(Tuple t)
Initialize with Tuple t.
ViewArray< View > x
Variables.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
bool failed(void) const
Check whether space is failed.
Entry for storing support.
FreeList ** nextRef(void)
Return pointer to next link in freelist object.
unsigned int domsize
Domain size.
void find_support(Space &home, Domain dom, int i, int n)
Find a next support for view at position i and value n.
size_t size
The size of the propagator (used during subsumption)
int min
Minimum and maximum in domain-values.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
ExecStatus ES_FIX_DISPOSE(Council< A > &c, A &a)
Advisor a must be disposed
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
int unassigned
Number of unassigned views.
Work(void)
Initialize as empty.
Post propagator for SetVar SetOpType SetVar SetRelType r
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Class represeting a set of tuples.
SupportEntry ** nextRef(void)
Return reference to field for next support entry.
void push(Space &home, int i, int n)
Push new work entry for position i and value n.
Work w_support
Work for finding support.
Domain consistent extensional propagator.
static PropCost cubic(PropCost::Mod m, unsigned int n)
Cubic complexity for modifier m and size measure n.
Generic domain change information to be supplied to advisors.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &t)
Post propagator for views x.
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
bool empty(void) const
Check whether work stack is empty.
Incremental(Space &home, bool share, Incremental< View > &p)
Constructor for cloning p.
bool assigned(View x, int v)
Whether x is assigned to value v.
SupportEntry * support(int i, int n)
Creat support entry for view at position i and value n.
Base-class for freelist-managed objects.
TupleSet::TupleSetI * ts(void)
void fl_dispose(FreeList *f, FreeList *l)
Return freelist-managed memory to freelist.
Post propagator for SetVar x
Propagation has not computed fixpoint.
Base for domain consistent extensional propagation
Gecode toplevel namespace
void pop(Space &home, int &i, int &n)
Pop current top entry and set position i and value n.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
#define GECODE_NEVER
Assert that this command is never executed.
void rfree(void *p, size_t s)
Free memory previously allocated with alloc (might be reused later)