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;
150 :
Propagator(home), elements(elements0), weights(weights0),
170 if (elements.
size() != weights.
size())
173 int* els_arr = r.
alloc<
int>(elements.
size());
174 for (
int i=elements.
size();
i--;)
175 els_arr[
i] = elements[
i];
179 (void)
new (home)
Weights(home,elements,weights,x,y);
205 return sizeof(*this);
211 return new (home)
Weights(home,*
this);
225 while (elements[i]<v.
val()) i++;
226 assert(elements[i] == v.
val());
237 bool operator ()(
int x,
int y);
261 minWeights[
i] = INT_MAX;
262 maxWeights[
i] = INT_MIN;
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()));
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);
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc to view.
void update(Space &home, VarImpView< Var > &y)
Update this view to be a clone of view y.
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.
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
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)
virtual Actor * copy(Space &home)
Copy propagator during cloning.
int ModEvent
Type for modification events.
Base-class for propagators.
unsigned int size(void) const
Return size (cardinality) of domain.
void reschedule(Space &home, Propagator &p, PropCond pc)
Re-schedule propagator p with propagation condition pc.
Weights(Space &home, Weights &p)
Constructor for cloning p.
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.
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.
virtual void reschedule(Space &home)
Schedule function.
Gecode::IntArgs i({1, 2, 3, 4})
int weightI(SharedArray< int > &elements, SharedArray< int > &weights, I &iter)
Compute the weight of the elements in the iterator I.
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
int size(void) const
Return number of elements.
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.
static ExecStatus post(Home home, const SharedArray< int > &elements, const SharedArray< int > &weights, View x, Gecode::Int::IntView y)
Post propagator for .
size_t size
The size of the propagator (used during subsumption)
const Gecode::ModEvent ME_SET_NONE
Domain operation has not changed domain.
Gecode::Int::IntView y
The integer view.
#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.
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.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Post propagator for SetVar x
Propagation has not computed fixpoint.
Propagator for weight of a set
Gecode toplevel namespace
SharedArray< int > elements
List of elements in the upper bound.
int max(void) const
Return maximum of domain.
LinFloatExpr sum(const FloatVarArgs &x)
Construct linear float expression as sum of float variables.
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