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);
176 if (elements.
size() != weights.
size())
179 int* els_arr = r.
alloc<
int>(elements.
size());
180 for (
int i=elements.
size();
i--;)
181 els_arr[
i] = elements[
i];
185 (void)
new (home)
Weights(home,elements,weights,x,y);
201 elements.~SharedArray();
204 return sizeof(*this);
210 return new (home)
Weights(home,share,*
this);
224 while (elements[i]<v.
val()) i++;
225 assert(elements[i] == v.
val());
252 int size = elements.size();
254 int* currentWeights = r.
alloc<
int>(
size);
259 if (!urv() || elements[
i]<urv.
val()) {
260 currentWeights[
i] = 0;
262 assert(elements[
i] == urv.
val());
270 Support::quicksort<int>(currentWeights,
size, il);
273 int delta =
static_cast<int>(
std::min(
x.unknownSize(),
x.cardMax() -
x.glbSize()));
277 int glbWeight = weightI<GlbRanges<View> >(elements,
weights, glb);
284 int lowWeight = glbWeight;
285 for (
int i=0;
i<delta-1;
i++) {
286 if (currentWeights[
i] >= 0)
288 lowWeight+=currentWeights[
i];
294 int lowestWeight = lowWeight;
295 if (delta>0 && currentWeights[delta-1]<0)
296 lowestWeight+=currentWeights[delta-1];
301 if ( (
x.cardMin() -
x.glbSize() > 0 &&
302 currentWeights[
x.cardMin() -
x.glbSize() - 1] >= 0) ||
303 currentWeights[0] >= 0 ) {
304 int lowestPosWeight = glbWeight;
305 for (
unsigned int i=0;
i<
x.cardMin() -
x.glbSize();
i++) {
306 lowestPosWeight += currentWeights[
i];
308 lowestWeight =
std::max(lowestWeight, lowestPosWeight);
314 int highestWeight = glbWeight;
315 for (
int i=0;
i<delta;
i++) {
316 if (currentWeights[size-
i-1]<=0)
318 highestWeight += currentWeights[size-
i-1];
328 int remainingCapacity = y.max()-lowWeight;
333 ov(remainingCapacity, elements, weights, urv2);
336 me =
x.excludeI(home, ovr);
343 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.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
void operator++(void)
Move iterator to next value (if possible)
int ModEvent
Type for modification events.
Base-class for propagators.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Propagation has computed fixpoint.
Base-class for both propagators and branchers.
virtual Actor * copy(Space &home, bool)
Copy propagator during cloning.
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)
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.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
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 .
bool operator()(void) const
Test whether iterator is still at a value or done.
int size(void) const
Return number of elements.
int val(void) const
Return current value.
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.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as PC_LINEAR_LO)
#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.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
Integer view for integer variables.
Node * x
Pointer to corresponding Boolean expression node.
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.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Post propagator for .
Propagation has not computed fixpoint.
int val(void) const
Return current value.
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.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
Exception: Arguments are of different size