Actual model
| 128 | }; |
| 129 | /// Actual model |
| 130 | MultiBinPacking(const InstanceOptions& opt) |
| 131 | : Script(opt), spec(opt.instance()), |
| 132 | bin(*this, spec.items(), 0, spec.bins()-1), |
| 133 | load(*this, spec.bins()*spec.dimension(), 0, Int::Limits::max) |
| 134 | { |
| 135 | |
| 136 | switch (opt.model()) { |
| 137 | case MODEL_SINGLE: |
| 138 | { |
| 139 | // Constrain load variables in every dimension |
| 140 | for (int k=0; k<spec.dimension(); k++) |
| 141 | for (int j=0; j<spec.bins(); j++) |
| 142 | rel(*this, load[j*spec.dimension()+k] <= spec.capacity(k)); |
| 143 | |
| 144 | // Post bin-packing constraint for each dimension |
| 145 | for (int k=0; k<spec.dimension(); k++) { |
| 146 | IntVarArgs l(spec.bins()); |
| 147 | for (int j=0; j<spec.bins(); j++) |
| 148 | l[j]=load[j*spec.dimension()+k]; |
| 149 | IntArgs s(spec.items()); |
| 150 | for (int i=0; i<spec.items(); i++) |
| 151 | s[i]=spec.size(i,k); |
| 152 | |
| 153 | binpacking(*this, l, bin, s); |
| 154 | } |
| 155 | } |
| 156 | break; |
| 157 | case MODEL_MULTI: |
| 158 | { |
| 159 | // Every bin has the same capacity for a given dimension |
| 160 | IntArgs c(spec.dimension()); |
| 161 | for (int k=0; k<spec.dimension(); k++) |
| 162 | c[k] = spec.capacity(k); |
| 163 | |
| 164 | // Item size for each dimension |
| 165 | IntArgs s(spec.items()*spec.dimension()); |
| 166 | for (int i=0; i<spec.items(); i++) |
| 167 | for (int k=0; k<spec.dimension(); k++) |
| 168 | s[i*spec.dimension()+k] = spec.size(i,k); |
| 169 | |
| 170 | // Post multidimensional binpacking constraint |
| 171 | IntSet mc = binpacking(*this, spec.dimension(), load, bin, s, c); |
| 172 | |
| 173 | // Symmetry breaking |
| 174 | if (opt.symmetry() == SYMMETRY_MAX_CONFLICT) { |
| 175 | // Use a maximal conflict set by assigning items to fixed bins |
| 176 | IntVarArgs bc(mc.size()); |
| 177 | int j=0; |
| 178 | for (IntSetValues i(mc); i(); ++i) |
| 179 | bc[j++] = bin[i.val()]; |
| 180 | assign(*this, bc, INT_ASSIGN_MIN()); |
| 181 | } |
| 182 | } |
| 183 | break; |
| 184 | } |
| 185 | |
| 186 | // Branching strategy |
| 187 | switch (opt.branching()) { |
nothing calls this directly
no test coverage detected