60 return new (home)
Pack(home,share,*
this);
85 : _nq(region.alloc<int>(m)), _n_nq(0), _eq(-1) {}
102 }
else if (
_eq >= 0) {
127 int* s = region.
alloc<
int>(m);
136 for (
int i=0;
i<
n;
i++)
138 int j = bs[
i].bin().val();
139 l[j].offset(
l[j].offset() - bs[
i].
size());
143 s[j.val()] += bs[
i].size();
148 for (
int i=n;
i--; ) {
151 s[j.val()] += bs[
i].size();
157 for (
int j=m; j--; ) {
160 min -=
l[j].max(); max -=
l[j].min();
164 for (
bool mod =
true;
mod; ) {
166 for (
int j=m; j--; ) {
167 int lj_min =
l[j].min();
168 me =
l[j].gq(home, min +
l[j].
max());
172 max += lj_min -
l[j].min();
mod =
true;
174 int lj_max =
l[j].max();
175 me =
l[j].lq(home, max +
l[j].
min());
179 min += lj_max -
l[j].max();
mod =
true;
185 assert(
l.assigned());
194 for (
int i=0;
i<
n;
i++) {
196 if (bs[
i].
size() >
l[j.val()].max())
198 if (s[j.val()] - bs[
i].size() <
l[j.val()].min())
204 int j = bs[
i].bin().val();
205 l[j].offset(
l[j].offset() - bs[
i].
size());
232 for (
int i=0;
i<
n;
i++) {
238 for (
int j=m; j--; ) {
240 if (nosum(static_cast<SizeSet&>(s[j]),
l[j].
min(),
l[j].
max()))
244 if (nosum(static_cast<SizeSet&>(s[j]),
l[j].
min(),
l[j].
min(),
248 if (nosum(static_cast<SizeSet&>(s[j]),
l[j].
max(),
l[j].
max(),
256 for (
int i=0;
i<
n;
i++) {
262 if (nosum(s[j.val()],
263 l[j.val()].min() - bs[
i].size(),
264 l[j.val()].max() - bs[
i].size()))
267 if (nosum(s[j.val()],
l[j.val()].min(),
l[j.val()].max()))
272 int j = bs[
i].bin().val();
273 l[j].offset(
l[j].offset() - bs[
i].
size());
288 int c = bs[0].
size();
293 int* n_s = region.
alloc<
int>(c+1);
295 for (
int i=c+1;
i--; )
307 if (
l[j].
max() < 0) {
309 }
else if (c >
l[j].
max()) {
310 n_s[c -
l[j].max()]++; nm++;
314 int* s = region.
alloc<
int>(nm);
319 for (
int i=c+1;
i--; )
320 for (
int j=n_s[
i]; j--; )
337 for (; (n12 < nm) && (s[n12] > c/2); n12++)
341 for (n3 = n12; n3 < nm; n3++)
345 for (
int k=0; k<=c/2; k++) {
347 for (; (n1 < nm) && (s[n1] > c-k); n1++)
351 for (; (s[n3-1] < k) && (n3 > n12); n3--)
354 int o = (s3 > f2) ? ((s3 - f2 + c - 1) /
c) : 0;
370 for (
int i=bs.
size();
i--; ) {
378 while ((n > 0) && (bs[n-1].
size() == 0))
382 if (bs.
size() == 0) {
384 for (
int i=l.
size();
i--; )
387 }
else if (l.
size() == 0) {
392 for (
int j=l.
size(); j--; ) {
396 (void)
new (home)
Pack(home,l,bs);
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
static PropCost quadratic(PropCost::Mod m, unsigned int n)
Quadratic complexity for modifier m and size measure n.
TellCache(Region ®ion, int m)
Initialize cache for at most m values.
ExecStatus ES_SUBSUMED(Propagator &p)
const FloatNum max
Largest allowed float value.
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
ViewArray< Item > bs
Items with bin and size.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
Value iterator for array of integers
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
int ModEvent
Type for modification events.
Pack(Home home, ViewArray< OffsetView > &l, ViewArray< Item > &bs)
Constructor for posting.
ViewArray< OffsetView > l
Views for load of bins.
void nq(int j)
Record that view must be different from j.
static ExecStatus post(Home home, ViewArray< OffsetView > &l, ViewArray< Item > &bs)
Post propagator for loads l and items bs.
Base-class for both propagators and branchers.
ModEvent minus_v(Space &home, I &i, bool depends=true)
Remove from domain the values described by i.
int _n_nq
Number of values to be pruned.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Gecode::FloatVal c(-8, 8)
Gecode::IntArgs i(4, 1, 2, 3, 4)
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
int n
Number of negative literals for node type.
Execution has resulted in failure.
ExecStatus tell(Space &home, IntView x)
Perform tell to view x and reset cache.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
unsigned int size(I &i)
Size of all ranges of range iterator i.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
void add(int s)
Add new size s.
void eq(int j)
Record that view must be equal to j, return false if not possible.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
int _eq
Value to which view should be assigned.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Integer view for integer variables.
Node * x
Pointer to corresponding Boolean expression node.
bool assigned(View x, int v)
Whether x is assigned to value v.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
Size sets with one element discarded.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
void minus(int s)
Discard size s.
Propagation has not computed fixpoint.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Gecode toplevel namespace
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
int size(void) const
Return size of array (number of elements)
int ModEventDelta
Modification event deltas.
Home class for posting propagators
virtual void reschedule(Space &home)
Schedule function.
const Gecode::ModEvent ME_INT_NONE
Domain operation has not changed domain.
int * _nq
Values (sorted) to be pruned from view.
bool me_failed(ModEvent me)
Check whether modification event me is failed.