Initial model
| 241 | public: |
| 242 | /// Initial model |
| 243 | CarSequencing(const CarOptions& opt) |
| 244 | : Script(opt), |
| 245 | problem(opt.size()), |
| 246 | ncars(problems[problem][0]), |
| 247 | noptions(problems[problem][1]), |
| 248 | nclasses(problems[problem][2]), |
| 249 | maxstall(opt.maxstall()), |
| 250 | stallval(nclasses), |
| 251 | endval(nclasses+1), |
| 252 | nstall(*this, 0, maxstall), |
| 253 | nend(*this, 0, maxstall), |
| 254 | s(*this, ncars+maxstall, 0, nclasses+1) |
| 255 | { |
| 256 | // Read problem |
| 257 | const int* probit = problems[problem] + 3; |
| 258 | |
| 259 | // Sequence requirements for the options. |
| 260 | IntArgs max(noptions), block(noptions); |
| 261 | for (int i = 0; i < noptions; ++i ) { |
| 262 | max[i] = *probit++; |
| 263 | } |
| 264 | for (int i = 0; i < noptions; ++i ) { |
| 265 | block[i] = *probit++; |
| 266 | } |
| 267 | // Number of cars per class |
| 268 | IntArgs ncc(nclasses); |
| 269 | // What classes require an option |
| 270 | IntSetArgs classes(noptions); |
| 271 | int** cdata = new int*[noptions]; |
| 272 | for (int i = noptions; i--; ) cdata[i] = new int[nclasses]; |
| 273 | int* n = new int[noptions]; |
| 274 | for (int i = noptions; i--; ) n[i] = 0; |
| 275 | // Read data |
| 276 | for (int c = 0; c < nclasses; ++c) { |
| 277 | probit++; |
| 278 | ncc[c] = *probit++; |
| 279 | for (int o = 0; o < noptions; ++o) { |
| 280 | if (*probit++) { |
| 281 | cdata[o][n[o]++] = c; |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | // Transfer specification data to int-sets |
| 286 | for (int o = noptions; o--; ) { |
| 287 | classes[o] = IntSet(cdata[o], n[o]); |
| 288 | delete [] cdata[o]; |
| 289 | } |
| 290 | delete [] cdata; |
| 291 | delete [] n; |
| 292 | |
| 293 | // Count the cars |
| 294 | { |
| 295 | IntSetArgs c(nclasses+2); |
| 296 | for (int i = nclasses; i--; ) { |
| 297 | c[i] = IntSet(ncc[i], ncc[i]); |
| 298 | } |
| 299 | c[stallval] = IntSet(0, maxstall); |
| 300 | c[ endval] = IntSet(0, maxstall); |
nothing calls this directly
no test coverage detected