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

Method CarSequencing

examples/car-sequencing.cpp:243–364  ·  view source on GitHub ↗

Initial model

Source from the content-addressed store, hash-verified

241public:
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);

Callers

nothing calls this directly

Calls 15

IntSetClass · 0.85
pushtoendFunction · 0.85
INT_VAR_NONEFunction · 0.85
INT_VAL_MINFunction · 0.85
maxstallMethod · 0.80
propagationMethod · 0.80
branchingMethod · 0.80
countFunction · 0.50
relFunction · 0.50
domFunction · 0.50
sequenceFunction · 0.50
extensionalFunction · 0.50

Tested by

no test coverage detected