MCPcopy Create free account
hub / github.com/Gecode/gecode / run

Method run

test/int/bin-packing.cpp:266–309  ·  view source on GitHub ↗

Run the actual test

Source from the content-addressed store, hash-verified

264 : Base("Int::MultiBinPacking::Clique::"+Test::str(c)), clique(c) {}
265 /// Run the actual test
266 virtual bool run(void) {
267 using namespace Gecode;
268 TestSpace* home = new TestSpace;
269 /*
270 * Set up a multi-dimensional bin packing problems of dimension 2
271 * where the item sizes in one dimension are all one but for some
272 * random items and two in the other dimension if the item is
273 * included in the clique and where the capacity in both dimensions
274 * is 3.
275 */
276 // Number of items
277 int n_items = clique[clique.size()-1] + 1;
278 // Capacity
279 IntArgs c({3,3});
280 // Item sizes
281 IntArgs s(2*n_items);
282 for (int i=2*n_items; i--; )
283 s[i]=1;
284 // Create some random conflicts
285 for (int i=clique.size()-1; i--; )
286 s[_rand(n_items)*2+0]=2;
287 // Create conflicts corresponding to the clique
288 for (int i=clique.size(); i--; )
289 s[clique[i]*2+1]=2;
290 // Load and bin variables
291 IntVarArgs b(*home, n_items, 0, n_items-1);
292 IntVarArgs l(*home, 2*n_items, 0, 3);
293 IntSet mc = binpacking(*home, 2, l, b, s, c);
294 if (home->status() == SS_FAILED) {
295 delete home;
296 return false;
297 }
298 if (static_cast<unsigned int>(clique.size()) != mc.size()) {
299 delete home;
300 return false;
301 }
302 for (int i=clique.size(); i--; )
303 if (!mc.in(clique[i])) {
304 delete home;
305 return false;
306 }
307 delete home;
308 return true;
309 }
310 };
311
312 /// Help class to create and register tests

Callers

nothing calls this directly

Calls 4

binpackingFunction · 0.85
sizeMethod · 0.45
statusMethod · 0.45
inMethod · 0.45

Tested by

no test coverage detected