43 namespace Test {
namespace Int {
75 dsv(new Gecode::IntSetValues[static_cast<unsigned int>(m+n)]) {
103 if (
dsv[i]() || (i == 0)) {
106 for (
int k=0;k<
n_bins; k++)
144 for (
int i=s.
size();
i--; )
151 :
Test(
"BinPacking::"+
str(m0)+
"::"+
str(s0)+
"::"+(
v ?
"+" :
"-"),
152 m0+s0.
size(), 0, 100),
185 using namespace Gecode;
208 mutable int il[4][8];
213 :
Test(
"MultiBinPacking::"+
str(d0)+
"::"+
str(m0)+
"::"+
214 str(s0)+
"::"+
str(c0), s0.
size() / d0, 0, m0-1),
215 d(d0),
m(m0),
s(s0),
c(c0) {
226 for (
int i=x.
size();
i--; )
236 using namespace Gecode;
238 for (
int j=m*
d; j--; )
264 :
Base(
"Int::MultiBinPacking::Clique::"+
Test::
str(c)), clique(c) {}
267 using namespace Gecode;
277 int n_items = clique[clique.size()-1] + 1;
282 for (
int i=2*n_items;
i--; )
285 for (
int i=clique.
size()-1;
i--; )
286 s[
rand(n_items)*2+0]=2;
288 for (
int i=clique.
size();
i--; )
298 if (clique.size() != mc.size()) {
302 for (
int i=clique.
size();
i--; )
303 if (!mc.in(clique[
i])) {
317 using namespace Gecode;
330 for (
int m=1;
m<4;
m++) {
331 (void)
new BPT(
m, s1);
332 (void)
new BPT(
m, s2);
333 (void)
new BPT(
m, s3);
334 (void)
new BPT(
m, s4);
335 (void)
new BPT(
m, s5);
336 (void)
new BPT(
m, s6);
337 (void)
new BPT(
m, s7);
338 (void)
new BPT(
m, s8);
339 (void)
new BPT(
m, s9);
340 (void)
new BPT(
m, s1,
false);
345 IntArgs s1(2*4, 1,2, 2,1, 1,2, 2,1);
347 (void)
new MBPT(2, 4, s1, c1);
348 (void)
new MBPT(2, 6, s1, c1);
349 IntArgs s2(2*3, 1,1, 1,1, 1,1);
352 (void)
new MBPT(2, 6, s2, c21);
353 (void)
new MBPT(2, 6, s2, c22);
354 IntArgs s3(3*4, 1,2,3, 3,2,1, 2,1,3, 1,3,2);
358 (void)
new MBPT(3, 4, s3, c31);
359 (void)
new MBPT(3, 4, s3, c32);
360 (void)
new MBPT(3, 4, s3, c33);
361 (void)
new MBPT(3, 5, s3, c31);
362 (void)
new MBPT(3, 5, s3, c32);
363 (void)
new MBPT(3, 5, s3, c33);
368 IntArgs c2(8, 1,2,3,4,5,6,7,8);
369 IntArgs c3(8, 1,3,7,10,15,22,27,97);
370 IntArgs c41(8, 1,2,3,4,5,6,7,14);
371 IntArgs c42(8, 1,2,3,4,5,6,7,15);
372 IntArgs c43(8, 1,2,3,4,5,6,7,16);
373 IntArgs c44(8, 1,2,3,4,5,6,7,30);
374 IntArgs c45(8, 1,2,3,4,5,6,7,31);
375 IntArgs c46(8, 1,2,3,4,5,6,7,32);
376 IntArgs c47(8, 1,2,3,4,5,6,7,62);
377 IntArgs c48(8, 1,2,3,4,5,6,7,63);
378 IntArgs c49(8, 1,2,3,4,5,6,7,64);
virtual int operator[](int i) const
Return value for variable i.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
int n_items
Number of items.
virtual bool solution(const Assignment &x) const
Test whether x is solution
int size(void) const
Return size of array (number of elements)
static Gecode::Support::RandomGenerator rand
Random number generator.
Create(void)
Perform creation and registration.
void init(const IntSet &s)
Initialize with values for s.
int n_items
Number of items.
Gecode::IntArgs s
Item sizes.
Gecode::IntArgs c
Bin capacities.
bool valid
Whether to generate only valid loads.
virtual bool operator()(void) const
Test whether all assignments have been iterated.
virtual ~LoadBinAssignment(void)
Destructor.
MBPT(int d0, int m0, const Gecode::IntArgs &s0, const Gecode::IntArgs &c0)
Create and register test for d0 dimensions, m0 bins, item sizes s0, and capacities c0...
Gecode::IntSet d_bin
Domain for bin variables.
const int max
Largest allowed integer value.
virtual bool solution(const Assignment &x) const
Test whether x is solution
static int total(const Gecode::IntArgs &s)
Compute total size.
virtual void operator++(void)
Move to next assignment.
int n
Number of variables.
int n_bins
Number of bins.
static std::string str(Gecode::ExtensionalPropKind epk)
Map extensional propagation kind to string.
Test with different bin loads and items
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::IntArgs clique
Expected clique.
Help class to create and register tests.
Gecode::IntSetValues * dsv
Iterator for each variable.
Base class for tests with integer constraints
unsigned int size(I &i)
Size of all ranges of range iterator i.
Base class for all tests to be run
struct Gecode::@519::NNF::@60::@62 a
For atomic nodes.
CliqueMBPT(const Gecode::IntArgs &c)
Test for number of items n expected clique c.
Passing integer variables.
Passing integer arguments.
Generate load and bin assignments.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
bool testfix
Whether to perform fixpoint test.
struct Gecode::@519::NNF::@60::@61 b
For binary nodes (and, or, eqv)
Node * x
Pointer to corresponding Boolean expression node.
Test with different bin loads and items
Gecode::IntSet d_load
Domain for load variables.
bool testsearch
Whether to perform search test.
Base class for assignments
virtual Assignment * assignment(void) const
Create assignment.
Value iterator for integer sets.
Test for testing the max-clique finding for multi bin-packing.
int il[8]
Array of sufficient size for computing item loads.
int val(void) const
Return current value.
virtual Gecode::Space * copy(bool share)
Copying member function.
void binpacking(Home home, const IntVarArgs &l, const IntVarArgs &b, const IntArgs &s, IntConLevel)
Post propagator for bin packing.
BPT(int m0, const Gecode::IntArgs &s0, bool v=true)
Create and register test for m bins and item sizes s.
virtual bool run(void)
Run the actual test.
Gecode::IntArgs s
Item sizes.
int size(void) const
Return number of variables.
LoadBinAssignment(int m, const Gecode::IntSet &d_m, int n, const Gecode::IntSet &d_n, int l)
Initialize assignments for load and bin variables.
int load
Load to generate (unless -1)