Go to the documentation of this file.
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);
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];
307 minWeights[0] >= 0 ) {
308 int lowestPosWeight = glbWeight;
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);
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
LinFloatExpr sum(const FloatVarArgs &x)
Construct linear float expression as sum of float variables.
Post propagator for SetVar x
Exception: Arguments are of different size
Post propagator for SetVar SetOpType SetVar y
Propagator for weight of a set
virtual void reschedule(Space &home)
Schedule function.
ExecStatus ES_SUBSUMED(Propagator &p)
unsigned int size(I &i)
Size of all ranges of range iterator i.
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to view.
unsigned int cardMin(void) const
Return cardinality minimum.
const FloatNum min
Smallest allowed float value.
Range iterator for the unknown set.
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
void update(Space &home, VarImpView< Var > &y)
Update this view to be a clone of view y.
Base-class for both propagators and branchers.
bool assigned(void) const
Test whether view is assigned.
int val(void) const
Return current value.
Range iterator for integer sets.
void operator++(void)
Move iterator to next value (if possible)
int val(void) const
Return current value.
Gecode toplevel namespace
Base-class for propagators.
bool operator()(void) const
Test whether iterator is still at a value or done.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_LINEAR_LO)
Home class for posting propagators
Range iterator from value iterator.
Value iterator from range iterator.
@ AP_DISPOSE
Actor must always be disposed.
Post propagator for SetVar SetOpType SetVar SetRelType r
unsigned int cardMax(void) const
Return cardinality maximum.
unsigned int unknownSize(void) const
Return number of unknown elements (elements in lub but not in glb)
const Gecode::ModEvent ME_SET_NONE
Domain operation has not changed domain.
Gecode::Int::IntView y
The integer view.
bool operator()(int x, int y)
Value Iterator for values above a certain weight.
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
int ModEvent
Type for modification events.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
OverweightValues(void)
Default constructor.
Weights(Space &home, Weights &p)
Constructor for cloning p.
static ExecStatus post(Home home, const SharedArray< int > &elements, const SharedArray< int > &weights, View x, Gecode::Int::IntView y)
Post propagator for .
unsigned int glbSize(void) const
Return number of elements in the greatest lower bound.
Integer view for integer variables.
void init(int t, SharedArray< int > &elements0, SharedArray< int > &weights0, I &i)
Initialize with elements/weights pairs, threshold t and iterator i.
const Gecode::PropCond PC_SET_ANY
Propagate when any bound or the cardinality of a view changes.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
int size(void) const
Return number of elements.
virtual size_t dispose(Space &home)
Delete actor and return its size.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int weightI(SharedArray< int > &elements, SharedArray< int > &weights, I &iter)
Compute the weight of the elements in the iterator I.
int ModEventDelta
Modification event deltas.
@ ES_NOFIX
Propagation has not computed fixpoint.
Gecode::IntArgs i({1, 2, 3, 4})
@ ES_OK
Execution is okay.
int p
Number of positive literals for node type.
const FloatNum max
Largest allowed float value.