54 return new (home)
Pack(home,share,*
this);
79 : _nq(region.alloc<int>(m)), _n_nq(0), _eq(-1) {}
96 }
else if (
_eq >= 0) {
121 int* s = region.
alloc<
int>(m);
130 for (
int i=0;
i<
n;
i++)
132 int j =
bs[
i].bin().val();
133 l[j].offset(
l[j].offset() -
bs[
i].
size());
137 s[j.val()] +=
bs[
i].size();
142 for (
int i=n;
i--; ) {
145 s[j.val()] +=
bs[
i].size();
151 for (
int j=m; j--; ) {
154 min -=
l[j].max(); max -=
l[j].min();
158 for (
bool mod =
true;
mod; ) {
160 for (
int j=m; j--; ) {
161 int lj_min =
l[j].min();
162 me =
l[j].gq(home, min +
l[j].
max());
166 max += lj_min -
l[j].min();
mod =
true;
168 int lj_max =
l[j].max();
169 me =
l[j].lq(home, max +
l[j].
min());
173 min += lj_max -
l[j].max();
mod =
true;
179 assert(
l.assigned());
188 for (
int i=0;
i<
n;
i++) {
190 if (
bs[
i].
size() >
l[j.val()].max())
192 if (s[j.val()] -
bs[
i].size() <
l[j.val()].min())
198 int j =
bs[
i].bin().val();
199 l[j].offset(
l[j].offset() -
bs[
i].
size());
226 for (
int i=0;
i<
n;
i++) {
232 for (
int j=m; j--; ) {
234 if (
nosum(static_cast<SizeSet&>(s[j]),
l[j].
min(),
l[j].
max()))
238 if (
nosum(static_cast<SizeSet&>(s[j]),
l[j].
min(),
l[j].
min(),
242 if (
nosum(static_cast<SizeSet&>(s[j]),
l[j].
max(),
l[j].
max(),
250 for (
int i=0;
i<
n;
i++) {
256 if (
nosum(s[j.val()],
257 l[j.val()].min() -
bs[
i].size(),
258 l[j.val()].max() -
bs[
i].size()))
261 if (
nosum(s[j.val()],
l[j.val()].min(),
l[j.val()].max()))
266 int j =
bs[
i].bin().val();
267 l[j].offset(
l[j].offset() -
bs[
i].
size());
282 int c =
bs[0].size();
287 int* n_s = region.
alloc<
int>(c+1);
289 for (
int i=c+1;
i--; )
301 if (
l[j].
max() < 0) {
303 }
else if (c >
l[j].
max()) {
304 n_s[c -
l[j].max()]++; nm++;
308 int* s = region.
alloc<
int>(nm);
313 for (
int i=c+1;
i--; )
314 for (
int n=n_s[
i]; n--; )
331 for (; (n12 < nm) && (s[n12] > c/2); n12++)
335 for (n3 = n12; n3 < nm; n3++)
339 for (
int k=0; k<=c/2; k++) {
341 for (; (n1 < nm) && (s[n1] > c-k); n1++)
345 for (; (s[n3-1] < k) && (n3 > n12); n3--)
348 int o = (s3 > f2) ? ((s3 - f2 + c - 1) /
c) : 0;
364 while (bs[n-1].
size() == 0)
368 if (bs.
size() == 0) {
370 for (
int i=l.
size();
i--; )
373 }
else if (l.
size() == 0) {
379 for (
int i=bs.
size();
i--; ) {
385 for (
int j=l.
size(); j--; ) {
389 (void)
new (home)
Pack(home,l,bs);
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.
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntConLevel icl)
Post propagator for .
ExecStatus ES_SUBSUMED(Propagator &p)
const FloatNum max
Largest allowed float value.
bool nosum(const SizeSet &s, int a, int b, int &ap, int &bp)
Detect non-existence of sums in a .. b.
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
int t
Total size of all items.
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::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
size_t size
The size of the propagator (used during subsumption)
void add(int s)
Add new size s.
ModEventDelta modeventdelta(void) const
Return the modification event delta.
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.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
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.
int size(void) const
Return size of array (number of elements)
Gecode toplevel namespace
int ModEventDelta
Modification event deltas.
Home class for posting propagators
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.