44 using namespace Gecode;
49 extern const int* problems[];
51 extern const unsigned int n_problems;
67 CarOptions(
const char* s)
69 _maxstall(
"-maxstall",
"Maximum numbere of stalls", 30)
75 void parse(
int& argc,
char* argv[]) {
79 int maxstall(
void)
const {
return _maxstall.value(); }
100 template <
class View>
108 PushToEnd(
Space& home,
bool share, PushToEnd&
p);
124 template <
class View>
126 PushToEnd<View>::PushToEnd(
Space& home,
130 template <
class View>
134 (void)
new (home) PushToEnd<View>(home,x0,y0,val0);
138 template <
class View>
140 PushToEnd<View>::PushToEnd(
Space& home,
bool share, PushToEnd<View>&
p)
143 template <
class View>
149 template <
class View>
151 PushToEnd<View>::copy(
Space& home,
bool share) {
152 return new (home) PushToEnd<View>(home,share,*
this);
155 template <
class View>
160 for (
int i =
x.size();
i-- &&
x[
i].min() >= val-1; ) {
168 if (
x[i].
max() != val)
break;
170 if (max >= y.max())
break;
183 for (
int i = 0,
pos =
x.size()-1; i < y.min(); ++
i, --
pos) {
260 const int* probit = problems[
problem] + 3;
268 block[
i] = *probit++;
275 for (
int i = noptions; i--; ) cdata[i] =
new int[
nclasses];
277 for (
int i = noptions; i--; ) n[i] = 0;
282 for (
int o = 0; o <
noptions; ++o) {
284 cdata[o][n[o]++] =
c;
289 for (
int o = noptions; o--; ) {
290 classes[o] =
IntSet(cdata[o], n[o]);
299 for (
int i = nclasses; i--; ) {
314 for (
int o = noptions; o--; ) {
317 for (
int i =
s.
size(); i--; ) {
319 dom(*
this,
s[i], classes[o], b);
322 sequence(*
this, sb, one, block[o], 0, max[o]);
326 switch (opt.propagation()) {
328 IntArgs notend(nclasses), notstallend(nclasses+1);
329 for (
int i = nclasses; i--; ) {
347 switch (opt.branching()) {
353 int mid =
s.
size() / 2;
356 for (
int i = 1; i <= m.size()/2; ++
i) {
359 if (mid+i <
s.
size())
362 assert(pos == m.size());
379 const char* space =
nclasses > 9 ?
" " :
"";
380 os <<
"Stall slots=" <<
nstall
381 <<
", End slots=" <<
nend << std::endl;
383 for (; i <
s.
size(); ++
i) {
387 if (v ==
stallval) os << space <<
"_ ";
388 else os << std::setw(width) << v <<
" ";
392 if ((i+1)%20 == 0) os << std::endl;
426 CarOptions
opt(
"CarSequencing");
435 opt.parse(argc,argv);
436 if (opt.size() >= n_problems) {
437 std::cerr <<
"Error: size must be between 0 and "
438 << n_problems-1 << std::endl;
442 Script::run<CarSequencing,BAB,CarOptions>(
opt);
471 1, 10, 1, 1, 1, 0, 0,
475 5, 15, 0, 1, 0, 0, 0,
480 10, 2, 1, 0, 1, 0, 0,
481 11, 1, 1, 1, 1, 0, 1,
482 12, 8, 0, 1, 0, 1, 0,
483 13, 3, 1, 0, 0, 1, 1,
484 14, 10, 1, 0, 0, 0, 0,
485 15, 4, 0, 1, 0, 0, 1,
486 16, 4, 0, 0, 0, 0, 1,
487 17, 2, 1, 0, 0, 0, 1,
488 18, 4, 1, 1, 0, 0, 0,
489 19, 6, 1, 1, 0, 1, 0,
490 20, 1, 1, 0, 1, 0, 1,
491 21, 1, 1, 1, 1, 1, 1,
501 0, 13, 1, 0, 0, 0, 0,
505 4, 12, 0, 0, 1, 0, 0,
510 9, 12, 1, 1, 0, 0, 0,
511 10, 8, 1, 1, 0, 1, 0,
512 11, 2, 1, 0, 0, 1, 1,
513 12, 2, 1, 1, 1, 0, 0,
514 13, 1, 0, 1, 0, 1, 1,
515 14, 4, 1, 0, 1, 0, 0,
516 15, 4, 0, 1, 0, 0, 1,
517 16, 1, 1, 1, 0, 1, 1,
518 17, 2, 1, 0, 1, 1, 0,
519 18, 1, 0, 0, 0, 0, 1,
520 19, 1, 1, 1, 1, 1, 0,
521 20, 1, 1, 1, 0, 0, 1,
522 21, 1, 0, 1, 1, 1, 0,
533 1, 11, 1, 1, 0, 0, 0,
536 4, 15, 0, 1, 0, 0, 0,
542 10, 5, 1, 0, 0, 0, 0,
543 11, 2, 1, 1, 1, 0, 1,
544 12, 6, 0, 1, 1, 0, 0,
545 13, 2, 0, 0, 1, 0, 1,
546 14, 2, 0, 1, 0, 0, 1,
547 15, 4, 1, 1, 1, 1, 0,
548 16, 3, 1, 0, 0, 0, 1,
549 17, 5, 1, 1, 0, 1, 0,
550 18, 2, 1, 1, 1, 0, 0,
551 19, 4, 1, 1, 0, 0, 1,
552 20, 1, 1, 0, 0, 1, 1,
553 21, 1, 1, 1, 0, 1, 1,
554 22, 1, 0, 1, 0, 1, 1,
555 23, 1, 0, 1, 1, 0, 1,
556 24, 2, 0, 0, 0, 0, 1,
566 0, 10, 1, 0, 0, 0, 0,
571 5, 11, 0, 1, 0, 0, 0,
576 10, 4, 1, 0, 1, 0, 0,
577 11, 7, 1, 0, 0, 1, 0,
578 12, 1, 1, 1, 1, 0, 1,
579 13, 3, 0, 1, 1, 1, 0,
580 14, 4, 0, 1, 0, 0, 1,
581 15, 5, 1, 1, 1, 0, 0,
582 16, 2, 1, 1, 0, 0, 1,
583 17, 1, 1, 0, 1, 1, 1,
584 18, 2, 1, 0, 1, 1, 0,
585 19, 3, 1, 0, 0, 0, 1,
586 20, 2, 0, 1, 1, 0, 1,
587 21, 1, 0, 1, 0, 1, 1,
588 22, 3, 1, 1, 0, 1, 0,
589 23, 1, 0, 0, 1, 1, 1,
590 24, 1, 1, 1, 1, 1, 1,
591 25, 1, 1, 1, 1, 1, 0,
609 8, 19, 0, 1, 0, 0, 0,
611 10, 10, 1, 0, 0, 0, 0,
612 11, 1, 0, 0, 1, 1, 0,
613 12, 5, 1, 1, 1, 1, 0,
614 13, 2, 1, 0, 1, 1, 0,
615 14, 6, 1, 1, 0, 0, 0,
616 15, 4, 1, 1, 1, 0, 0,
617 16, 8, 1, 0, 0, 1, 0,
618 17, 1, 1, 0, 0, 0, 1,
619 18, 4, 0, 1, 1, 0, 0,
620 19, 2, 0, 0, 0, 0, 1,
621 20, 4, 0, 1, 0, 0, 1,
622 21, 1, 1, 1, 0, 1, 1,
623 22, 1, 0, 1, 1, 0, 1,
626 const int* problems[] = {
636 const unsigned int n_problems =
sizeof(problems)/
sizeof(
int*);