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