92 OverweightValues<I>::next(
void) {
94 while (elements[index]<iter.val()) index++;
95 assert(elements[index]==iter.val());
96 if (
weights[index] > threshold) {
112 I& i) : threshold(t),
126 threshold = t; iter = i;
127 elements = elements0; weights = weights0;
173 int* els_arr =
r.alloc<
int>(
elements.size());
205 return sizeof(*this);
211 return new (home)
Weights(home,*
this);
225 while (elements[i]<v.val()) i++;
226 assert(elements[i] == v.val());
254 int* minWeights =
r.alloc<
int>(
size);
255 int* maxWeights =
r.alloc<
int>(
size);
259 for (
int i=0; i<
size; i++) {
261 minWeights[i] = INT_MAX;
262 maxWeights[i] = INT_MIN;
277 int delta =
static_cast<int>(std::min(
x.unknownSize(),
x.cardMax() -
x.glbSize()));
288 int lowWeight = glbWeight;
289 for (
int i=0; i<delta-1; i++) {
290 if (minWeights[i] >= 0)
292 lowWeight+=minWeights[i];
298 int lowestWeight = lowWeight;
299 if (delta>0 && minWeights[delta-1]<0)
300 lowestWeight+=minWeights[delta-1];
305 if ( (
x.cardMin() -
x.glbSize() > 0 &&
306 minWeights[
x.cardMin() -
x.glbSize() - 1] >= 0) ||
307 minWeights[0] >= 0 ) {
308 int lowestPosWeight = glbWeight;
309 for (
unsigned int i=0; i<
x.cardMin() -
x.glbSize(); i++) {
310 lowestPosWeight += minWeights[i];
312 lowestWeight = std::max(lowestWeight, lowestPosWeight);
318 int highestWeight = glbWeight;
319 for (
int i=0; i<delta; i++) {
320 if (maxWeights[
size-i-1]<=0)
322 highestWeight += maxWeights[
size-i-1];
332 int remainingCapacity =
y.max()-lowWeight;
340 me =
x.excludeI(home, ovr);
Base-class for both propagators and branchers.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Home class for posting propagators
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Range iterator for integer sets.
Exception: Arguments are of different size
Integer view for integer variables.
Value iterator from range iterator.
int val(void) const
Return current value.
Range iterator from value iterator.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
size_t size
The size of the propagator (used during subsumption)
Propagator(Home home)
Constructor for posting.
Range iterator for the greatest lower bound.
bool operator()(int x, int y)
Value Iterator for values above a certain weight.
void operator++(void)
Move iterator to next value (if possible)
void init(int t, SharedArray< int > &elements0, SharedArray< int > &weights0, I &i)
Initialize with elements/weights pairs, threshold t and iterator i.
bool operator()(void) const
Test whether iterator is still at a value or done.
int val(void) const
Return current value.
OverweightValues(void)
Default constructor.
Gecode::Int::IntView y
The integer view.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
SharedArray< int > weights
Weights for the elements in the upper bound.
Weights(Space &home, Weights &p)
Constructor for cloning p.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_LINEAR_LO)
static ExecStatus post(Home home, const SharedArray< int > &elements, const SharedArray< int > &weights, View x, Gecode::Int::IntView y)
Post propagator for .
SharedArray< int > elements
List of elements in the upper bound.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
virtual void reschedule(Space &home)
Schedule function.
Range iterator for the unknown set.
Shared array with arbitrary number of elements.
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
@ AP_DISPOSE
Actor must always be disposed.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Propagators connecting set and int variables.
int weightI(SharedArray< int > &elements, SharedArray< int > &weights, I &iter)
Compute the weight of the elements in the iterator I.
const Gecode::ModEvent ME_SET_NONE
Domain operation has not changed domain.
const Gecode::PropCond PC_SET_ANY
Propagate when any bound or the cardinality of a view changes.
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Gecode toplevel namespace
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Post propagator for SetVar SetOpType SetVar SetRelType r
Post propagator for SetVar SetOpType SetVar y
LinIntExpr sum(const IntVarArgs &x)
Construct linear expression as sum of integer variables.
@ ES_OK
Execution is okay.
@ ES_NOFIX
Propagation has not computed fixpoint.
Post propagator for SetVar x
int ModEvent
Type for modification events.