Go to the documentation of this file.
45 namespace Gecode {
namespace Set {
namespace Int {
98 while (elements[index]<iter.val()) index++;
99 assert(elements[index]==iter.val());
100 if (
weights[index] > threshold) {
116 I&
i) : threshold(
t),
130 threshold =
t; iter =
i;
131 elements = elements0;
weights = weights0;
165 x.update(home,share,
p.x);
179 int* els_arr =
r.alloc<
int>(elements.
size());
180 for (
int i=elements.
size();
i--;)
181 els_arr[
i] = elements[
i];
208 elements.~SharedArray();
211 return sizeof(*this);
217 return new (home)
Weights(home,share,*
this);
231 while (elements[
i]<
v.val())
i++;
232 assert(elements[
i] ==
v.val());
258 int size = elements.size();
260 int* minWeights =
r.alloc<
int>(
size);
261 int* maxWeights =
r.alloc<
int>(
size);
266 if (!urv() || elements[
i]<urv.
val()) {
267 minWeights[
i] = INT_MAX;
268 maxWeights[
i] = INT_MIN;
270 assert(elements[
i] == urv.
val());
279 Support::quicksort<int>(minWeights,
size, il);
280 Support::quicksort<int>(maxWeights,
size, il);
287 int glbWeight = weightI<GlbRanges<View> >(elements,
weights, glb);
294 int lowWeight = glbWeight;
295 for (
int i=0;
i<delta-1;
i++) {
296 if (minWeights[
i] >= 0)
298 lowWeight+=minWeights[
i];
304 int lowestWeight = lowWeight;
305 if (delta>0 && minWeights[delta-1]<0)
306 lowestWeight+=minWeights[delta-1];
313 minWeights[0] >= 0 ) {
314 int lowestPosWeight = glbWeight;
316 lowestPosWeight += minWeights[
i];
318 lowestWeight =
std::max(lowestWeight, lowestPosWeight);
324 int highestWeight = glbWeight;
325 for (
int i=0;
i<delta;
i++) {
326 if (maxWeights[
size-
i-1]<=0)
328 highestWeight += maxWeights[
size-
i-1];
338 int remainingCapacity =
y.max()-lowWeight;
343 ov(remainingCapacity, elements,
weights, urv2);
346 me =
x.excludeI(home, ovr);
353 weightI<GlbRanges<View> >(elements,
weights, glb);
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
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
SharedArray< int > elements
List of elements in the upper bound.
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.
Gecode::IntArgs i(4, 1, 2, 3, 4)
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.
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.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
Post propagator for SetVar SetOpType SetVar SetRelType r
SharedArray< int > weights
Weights for the elements in the upper bound.
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)
void update(Space &home, bool share, VarImpView< Var > &y)
Update this view to be a clone of view 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.
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.
Weights(Space &home, bool share, Weights &p)
Constructor for cloning p.
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.
@ ES_OK
Execution is okay.
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
int p
Number of positive literals for node type.
const FloatNum max
Largest allowed float value.