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

Method next

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

Move to next assignment

Source from the content-addressed store, hash-verified

80 }
81 /// Move to next assignment
82 virtual void next(Gecode::Support::RandomGenerator&) {
83 // Try to generate next bin assignment
84 {
85 int i = n_items-1;
86 while (i >= 0) {
87 ++dsv[n_bins+i];
88 if (dsv[n_bins+i]())
89 return;
90 dsv[n_bins+(i--)].init(d_bin);
91 }
92 }
93 // Try to generate next load assignment
94 {
95 retry:
96 int i = n_bins-1;
97 while (true) {
98 ++dsv[i];
99 if (dsv[i]() || (i == 0)) {
100 if (dsv[i]() && (load >= 0)) {
101 int l = 0;
102 for (int k=0;k<n_bins; k++)
103 l += dsv[k].val();
104 if (load != l)
105 goto retry;
106 }
107 return;
108 }
109 dsv[i--].init(d_load);
110 }
111 }
112 }
113 /// Return value for variable \a i
114 virtual int operator[](int i) const {
115 assert((i>=0) && (i<n_bins+n_items));

Callers 5

TupleSetLargeMethod · 0.45
TupleSetBoolMethod · 0.45
TupleSetTestSizeMethod · 0.45
randomTupleSetFunction · 0.45
CreateMethod · 0.45

Calls 2

initMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected