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