56 return new (home)
Pack(home,*
this);
98 }
else if (
_eq >= 0) {
123 int* s = region.
alloc<
int>(m);
125 for (
int j=0; j<m; j++)
132 for (
int i=0; i<n; i++)
133 if (
bs[i].assigned()) {
134 int j =
bs[i].bin().val();
139 s[j.val()] +=
bs[i].size();
144 for (
int i=0; i<n; i++) {
145 assert(!
bs[i].assigned());
147 s[j.val()] +=
bs[i].size();
153 for (
int j=0; j<m; j++) {
156 min -=
l[j].max();
max -=
l[j].min();
160 for (
bool mod =
true;
mod; ) {
162 for (
int j=0; j<m; j++) {
163 int lj_min =
l[j].min();
164 me =
l[j].gq(home,
min +
l[j].
max());
168 max += lj_min -
l[j].min();
mod =
true;
170 int lj_max =
l[j].max();
171 me =
l[j].lq(home,
max +
l[j].
min());
175 min += lj_max -
l[j].max();
mod =
true;
181 assert(
l.assigned());
190 for (
int i=0; i<n; i++) {
192 if (
bs[i].
size() >
l[j.val()].max())
194 if (s[j.val()] -
bs[i].size() <
l[j.val()].min())
199 if (
bs[i].assigned()) {
200 int j =
bs[i].bin().val();
223 for (
int j=0; j<m; j++)
227 for (
int i=0; i<n; i++) {
228 assert(!
bs[i].assigned());
233 for (
int j=0; j<m; j++) {
251 for (
int i=0; i<n; i++) {
252 assert(!
bs[i].assigned());
257 if (
nosum(s[j.val()],
258 l[j.val()].min() -
bs[i].size(),
259 l[j.val()].max() -
bs[i].size()))
262 if (
nosum(s[j.val()],
l[j.val()].min(),
l[j.val()].max()))
266 if (
bs[i].assigned()) {
267 int j =
bs[i].bin().val();
283 int c =
bs[0].size();
284 for (
int j=0; j<m; j++)
285 c = std::max(c,
l[j].
max());
288 int* n_s = region.
alloc<
int>(c+1);
290 for (
int i=0; i<c+1; i++)
294 for (
int i=0; i<n; i++)
301 for (
int j=0; j<m; j++)
302 if (
l[j].
max() < 0) {
304 }
else if (c >
l[j].
max()) {
305 n_s[c -
l[j].max()]++; nm++;
309 int* s = region.
alloc<
int>(nm);
314 for (
int i=c+1; i--; )
315 for (
int j=n_s[i]; j--; )
332 for (; (n12 < nm) && (s[n12] > c/2); n12++)
336 for (n3 = n12; n3 < nm; n3++)
340 for (
int k=0; k<=c/2; k++) {
342 for (; (n1 < nm) && (s[n1] > c-k); n1++)
346 for (; (s[n3-1] < k) && (n3 > n12); n3--)
349 int o = (s3 > f2) ? ((s3 - f2 + c - 1) / c) : 0;
366 for (
int i=0; i<
bs.size(); i++) {
374 while ((n > 0) && (
bs[n-1].
size() == 0))
378 if (
bs.size() == 0) {
380 for (
int i=0; i<
l.size(); i++)
383 }
else if (
l.size() == 0) {
388 for (
int j=0; j<
l.size(); j++) {
392 (void)
new (home)
Pack(home,
l,
bs);
Base-class for both propagators and branchers.
static ModEvent me(const ModEventDelta &med)
Home class for posting propagators
ViewArray< OffsetView > l
Views for load of bins.
static ExecStatus post(Home home, ViewArray< OffsetView > &l, ViewArray< Item > &bs)
Post propagator for loads l and items bs.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ViewArray< Item > bs
Items with bin and size.
Pack(Home home, ViewArray< OffsetView > &l, ViewArray< Item > &bs)
Constructor for posting.
int t
Total size of all items.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
bool nosum(const SizeSet &s, int a, int b, int &ap, int &bp)
Detect non-existence of sums in a .. b.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
virtual void reschedule(Space &home)
Schedule function.
Size sets with one element discarded.
void minus(int s)
Discard size s.
void add(int s)
Add new size s.
int * _nq
Values (sorted) to be pruned from view.
int _n_nq
Number of values to be pruned.
TellCache(Region ®ion, int m)
Initialize cache for at most m values.
ExecStatus tell(Space &home, IntView x)
Perform tell to view x and reset cache.
void eq(int j)
Record that view must be equal to j, return false if not possible.
int _eq
Value to which view should be assigned.
void nq(int j)
Record that view must be different from j.
Integer view for integer variables.
Value iterator for integer views.
Value iterator for array of integers
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
size_t size
The size of the propagator (used during subsumption)
ModEventDelta modeventdelta(void) const
Return the modification event delta.
ModEventDelta med
A set of modification events (used during propagation)
void free(void)
Free allocate memory.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
static ModEvent me(const ModEventDelta &med)
int offset(void) const
Integer-precision integer scale view.
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Gecode toplevel namespace
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl=IPL_DEF)
Post propagator for .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
@ ES_OK
Execution is okay.
@ ES_FAILED
Execution has resulted in failure.
@ ES_NOFIX
Propagation has not computed fixpoint.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
int ModEvent
Type for modification events.