71 dsv(new
Gecode::IntSetValues[static_cast<unsigned int>(m+
n)]) {
99 if (
dsv[i]() || (i == 0)) {
102 for (
int k=0;k<
n_bins; k++)
140 for (
int i=
s.size(); i--; )
147 :
Test(
"BinPacking::"+
str(m0)+
"::"+
str(s0)+
"::"+(v ?
"+" :
"-"),
148 m0+s0.size(), 0, 100),
171 if ((x[
m+j] < 0) || (x[
m+j] >=
m))
176 for (
int i=
s.size(); i--; )
190 for (
int i=
s.size(); i--; )
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--; )
227 il[k][x[i]] +=
s[i*
d+k];
238 for (
int j=
m*
d; j--; )
285 for (
int i=
clique.size()-1; i--; )
288 for (
int i=
clique.size(); i--; )
298 if (
static_cast<unsigned int>(
clique.size()) != mc.
size()) {
302 for (
int i=
clique.size(); i--; )
328 :
Base(
"Int::BinPacking::DFFLowerBound") {}
356 const bool expected_failed[4])
const {
360 for (
unsigned int i = 0; i < 4; i += 1) {
367 if (failed != expected_failed[i])
375 :
Base(
"Int::BinPacking::PropagationLevels") {}
379 bool const advanced_failed[] = {
false,
true,
true,
true};
380 bool const full_failed[] = {
false,
false,
false,
true};
384 IntArgs({32,30,24,21,19,11,10,9,8,5,3}),
405 :
Base(
"Int::BinPacking::DFFLargeWeights") {}
436 IntArgs s({1000000000,1000000000});
464 for (
int m=1; m<4; m++) {
465 (void)
new BPT(m, s0);
466 (void)
new BPT(m, s1);
467 (void)
new BPT(m, s2);
468 (void)
new BPT(m, s3);
469 (void)
new BPT(m, s4);
470 (void)
new BPT(m, s5);
471 (void)
new BPT(m, s6);
472 (void)
new BPT(m, s7);
473 (void)
new BPT(m, s8);
474 (void)
new BPT(m, s9);
475 (void)
new BPT(m, s1,
false);
480 IntArgs s1({1,2, 2,1, 1,2, 2,1});
482 (void)
new MBPT(2, 4, s1, c1);
483 (void)
new MBPT(2, 6, s1, c1);
487 (void)
new MBPT(2, 6, s2, c21);
488 (void)
new MBPT(2, 6, s2, c22);
489 IntArgs s3({1,2,3, 3,2,1, 2,1,3, 1,3,2});
493 (void)
new MBPT(3, 4, s3, c31);
494 (void)
new MBPT(3, 4, s3, c32);
495 (void)
new MBPT(3, 4, s3, c33);
496 (void)
new MBPT(3, 5, s3, c31);
497 (void)
new MBPT(3, 5, s3, c32);
498 (void)
new MBPT(3, 5, s3, c33);
504 IntArgs c3({1,3,7,10,15,22,27,97});
505 IntArgs c41({1,2,3,4,5,6,7,14});
506 IntArgs c42({1,2,3,4,5,6,7,15});
507 IntArgs c43({1,2,3,4,5,6,7,16});
508 IntArgs c44({1,2,3,4,5,6,7,30});
509 IntArgs c45({1,2,3,4,5,6,7,31});
510 IntArgs c46({1,2,3,4,5,6,7,32});
511 IntArgs c47({1,2,3,4,5,6,7,62});
512 IntArgs c48({1,2,3,4,5,6,7,63});
513 IntArgs c49({1,2,3,4,5,6,7,64});
int size(void) const
Return size of array (number of elements).
Passing integer arguments.
Value iterator for integer sets.
bool in(int n) const
Return whether n is included in the set.
unsigned int size(void) const
Return size (cardinality) of set.
Passing integer variables.
Gecode::Support::RandomGenerator _rand
Random number generator.
Base(std::string s)
Create and register test with name s.
static std::string str(bool b)
Map bool to string.
Base class for assignments
int n
Number of variables.
Assignment(int n0, const Gecode::IntSet &d0)
Initialize assignments for n0 variables and values d0.
int size(void) const
Return number of variables.
Test with different bin loads and items
static int total(const Gecode::IntArgs &s)
Compute total size.
virtual Assignment * assignment(void) const
Create assignment.
virtual bool solution(const Assignment &x) const
Test whether x is solution
BPT(int m0, const Gecode::IntArgs &s0, bool v=true)
Create and register test for m bins and item sizes s.
Gecode::IntArgs s
Item sizes.
int il[8]
Array of sufficient size for computing item loads.
bool valid
Whether to generate only valid loads.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
virtual Gecode::Space * copy(void)
Copying member function.
Test for testing the max-clique finding for multi bin-packing.
int n_items
Number of items.
CliqueMBPT(const Gecode::IntArgs &c)
Test for number of items n expected clique c.
Gecode::IntArgs clique
Expected clique.
virtual bool run(void)
Run the actual test.
Help class to create and register tests.
Create(void)
Perform creation and registration.
TestSpace(void)
Constructor.
virtual Gecode::Space * copy(void)
Copy function.
Test DFF arithmetic at the largest supported integer value.
virtual bool run(void)
Run the actual test.
DFFLargeWeights(void)
Constructor.
virtual Gecode::Space * copy(void)
Copy function.
TestSpace(void)
Constructor.
Test that DFF lower bounds detect infeasible packing.
virtual bool run(void)
Run the actual test.
DFFLowerBound(void)
Constructor.
Generate load and bin assignments.
virtual ~LoadBinAssignment(void)
Destructor.
Gecode::IntSet d_bin
Domain for bin variables.
Gecode::IntSetValues * dsv
Iterator for each variable.
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).
int n_bins
Number of bins.
virtual bool has_more(void) const
Test whether all assignments have been iterated.
Gecode::IntSet d_load
Domain for load variables.
int n_items
Number of items.
virtual int operator[](int i) const
Return value for variable i.
virtual void next(Gecode::Support::RandomGenerator &)
Move to next assignment.
Test with different bin loads and items
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.
virtual bool solution(const Assignment &x) const
Test whether x is solution
Gecode::IntArgs c
Bin capacities.
virtual void post(Gecode::Space &home, Gecode::IntVarArray &x)
Post constraint on x.
Gecode::IntArgs s
Item sizes.
int il[4][8]
Array of sufficient size for computing item loads.
virtual Gecode::Space * copy(void)
Copying member function.
Test the bin-packing propagation levels.
bool check_case(int n_bins, int capacity, const Gecode::IntArgs &sizes, const bool expected_failed[4]) const
Check one propagation-level test case.
PropagationLevels(void)
Constructor.
virtual bool run(void)
Run the actual test.
bool testsearch
Whether to perform search test.
static std::string str(bool b)
Map bool to string.
bool testfix
Whether to perform fixpoint test.
const int capacity[n_warehouses]
Capacity of a single warehouse.
LinearCongruentialGenerator< 2147483647, 48271, 44488, 3399 > RandomGenerator
Default values for linear congruential generator.
void binpacking(Home home, const IntVarArgs &l, const IntVarArgs &b, const IntArgs &s, IntPropLevel ipl=IPL_DEF)
Post propagator for bin packing.
IntPropLevel
Propagation levels for integer propagators.
@ IPL_BASIC
Use basic propagation algorithm.
@ IPL_FULL
Use full propagation.
@ IPL_ADVANCED
Use advanced propagation algorithm.
@ IPL_DEF
Simple propagation levels.
SpaceStatus status(StatusStatistics &stat)
Query space status.
@ SS_FAILED
Space is failed
const int max
Largest allowed integer value.
Gecode toplevel namespace
Tests for bin-packing constraint
Testing finite domain integers.