41 namespace Gecode {
namespace Set {
namespace Int {
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());
174 for (
int i=elements.
size();
i--;)
175 els_arr[
i] = elements[
i];
202 elements.~SharedArray();
205 return sizeof(*this);
211 return new (home)
Weights(home,*
this);
225 while (elements[
i]<
v.val())
i++;
226 assert(elements[
i] ==
v.val());
252 int size = elements.size();
254 int* minWeights =
r.alloc<
int>(
size);
255 int* maxWeights =
r.alloc<
int>(
size);
260 if (!urv() || elements[
i]<urv.
val()) {
261 minWeights[
i] = INT_MAX;
262 maxWeights[
i] = INT_MIN;
264 assert(elements[
i] == urv.
val());
273 Support::quicksort<int>(minWeights,
size, il);
274 Support::quicksort<int>(maxWeights,
size, il);
277 int delta =
static_cast<int>(
std::min(
x.unknownSize(),
x.cardMax() -
x.glbSize()));
281 int glbWeight = weightI<GlbRanges<View> >(elements,
weights, glb);
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;
337 ov(remainingCapacity, elements,
weights, urv2);
340 me =
x.excludeI(home, ovr);
347 weightI<GlbRanges<View> >(elements,
weights, glb);
int p
Number of positive literals for node type.
Node * x
Pointer to corresponding Boolean expression node.
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.
Base-class for propagators.
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.
Propagator for weight of a set
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.
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 .
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.
int size(void) const
Return number of elements.
void update(Space &home, VarImpView< Var > &y)
Update this view to be a clone of view y.
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to view.
@ ES_OK
Execution is okay.
@ ES_NOFIX
Propagation has not computed fixpoint.
int ModEvent
Type for modification events.
LinFloatExpr sum(const FloatVarArgs &x)
Construct linear float expression as sum of float variables.
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Post propagator for SetVar SetOpType SetVar y
ExecStatus ES_SUBSUMED(Propagator &p)
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 FloatNum max
Largest allowed float value.
const FloatNum min
Smallest allowed float value.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
unsigned int size(I &i)
Size of all ranges of range iterator i.
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.
Gecode::IntArgs i({1, 2, 3, 4})