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) {
265 const int* probit = problems[
problem] + 3;
273 block[
i] = *probit++;
280 for (
int i = noptions; i--; ) cdata[i] =
new int[
nclasses];
282 for (
int i = noptions; i--; ) n[i] = 0;
287 for (
int o = 0; o <
noptions; ++o) {
289 cdata[o][n[o]++] =
c;
294 for (
int o = noptions; o--; ) {
295 classes[o] =
IntSet(cdata[o], n[o]);
304 for (
int i = nclasses; i--; ) {
319 for (
int o = noptions; o--; ) {
322 for (
int i =
s.
size(); i--; ) {
324 dom(*
this,
s[i], classes[o], b);
327 sequence(*
this, sb, one, block[o], 0, max[o]);
331 switch (opt.propagation()) {
333 IntArgs notend(nclasses), notstallend(nclasses+1);
334 for (
int i = nclasses; i--; ) {
352 switch (opt.branching()) {
358 int mid =
s.
size() / 2;
361 for (
int i = 1; i <=
m.size()/2; ++
i) {
364 if (mid+i <
s.
size())
367 assert(pos ==
m.size());
384 const char* space =
nclasses > 9 ?
" " :
"";
385 os <<
"Stall slots=" <<
nstall
386 <<
", End slots=" <<
nend << std::endl;
388 for (; i <
s.
size(); ++
i) {
392 if (v ==
stallval) os << space <<
"_ ";
393 else os << std::setw(width) << v <<
" ";
397 if ((i+1)%20 == 0) os << std::endl;
431 CarOptions
opt(
"CarSequencing");
443 opt.parse(argc,argv);
444 if (opt.size() >= n_problems) {
445 std::cerr <<
"Error: size must be between 0 and "
446 << n_problems-1 << std::endl;
450 switch (opt.search()) {
452 Script::run<CarSequencing,BAB,CarOptions>(
opt);
break;
454 Script::run<CarSequencing,Restart,CarOptions>(
opt);
break;
484 1, 10, 1, 1, 1, 0, 0,
488 5, 15, 0, 1, 0, 0, 0,
493 10, 2, 1, 0, 1, 0, 0,
494 11, 1, 1, 1, 1, 0, 1,
495 12, 8, 0, 1, 0, 1, 0,
496 13, 3, 1, 0, 0, 1, 1,
497 14, 10, 1, 0, 0, 0, 0,
498 15, 4, 0, 1, 0, 0, 1,
499 16, 4, 0, 0, 0, 0, 1,
500 17, 2, 1, 0, 0, 0, 1,
501 18, 4, 1, 1, 0, 0, 0,
502 19, 6, 1, 1, 0, 1, 0,
503 20, 1, 1, 0, 1, 0, 1,
504 21, 1, 1, 1, 1, 1, 1,
514 0, 13, 1, 0, 0, 0, 0,
518 4, 12, 0, 0, 1, 0, 0,
523 9, 12, 1, 1, 0, 0, 0,
524 10, 8, 1, 1, 0, 1, 0,
525 11, 2, 1, 0, 0, 1, 1,
526 12, 2, 1, 1, 1, 0, 0,
527 13, 1, 0, 1, 0, 1, 1,
528 14, 4, 1, 0, 1, 0, 0,
529 15, 4, 0, 1, 0, 0, 1,
530 16, 1, 1, 1, 0, 1, 1,
531 17, 2, 1, 0, 1, 1, 0,
532 18, 1, 0, 0, 0, 0, 1,
533 19, 1, 1, 1, 1, 1, 0,
534 20, 1, 1, 1, 0, 0, 1,
535 21, 1, 0, 1, 1, 1, 0,
546 1, 11, 1, 1, 0, 0, 0,
549 4, 15, 0, 1, 0, 0, 0,
555 10, 5, 1, 0, 0, 0, 0,
556 11, 2, 1, 1, 1, 0, 1,
557 12, 6, 0, 1, 1, 0, 0,
558 13, 2, 0, 0, 1, 0, 1,
559 14, 2, 0, 1, 0, 0, 1,
560 15, 4, 1, 1, 1, 1, 0,
561 16, 3, 1, 0, 0, 0, 1,
562 17, 5, 1, 1, 0, 1, 0,
563 18, 2, 1, 1, 1, 0, 0,
564 19, 4, 1, 1, 0, 0, 1,
565 20, 1, 1, 0, 0, 1, 1,
566 21, 1, 1, 1, 0, 1, 1,
567 22, 1, 0, 1, 0, 1, 1,
568 23, 1, 0, 1, 1, 0, 1,
569 24, 2, 0, 0, 0, 0, 1,
579 0, 10, 1, 0, 0, 0, 0,
584 5, 11, 0, 1, 0, 0, 0,
589 10, 4, 1, 0, 1, 0, 0,
590 11, 7, 1, 0, 0, 1, 0,
591 12, 1, 1, 1, 1, 0, 1,
592 13, 3, 0, 1, 1, 1, 0,
593 14, 4, 0, 1, 0, 0, 1,
594 15, 5, 1, 1, 1, 0, 0,
595 16, 2, 1, 1, 0, 0, 1,
596 17, 1, 1, 0, 1, 1, 1,
597 18, 2, 1, 0, 1, 1, 0,
598 19, 3, 1, 0, 0, 0, 1,
599 20, 2, 0, 1, 1, 0, 1,
600 21, 1, 0, 1, 0, 1, 1,
601 22, 3, 1, 1, 0, 1, 0,
602 23, 1, 0, 0, 1, 1, 1,
603 24, 1, 1, 1, 1, 1, 1,
604 25, 1, 1, 1, 1, 1, 0,
622 8, 19, 0, 1, 0, 0, 0,
624 10, 10, 1, 0, 0, 0, 0,
625 11, 1, 0, 0, 1, 1, 0,
626 12, 5, 1, 1, 1, 1, 0,
627 13, 2, 1, 0, 1, 1, 0,
628 14, 6, 1, 1, 0, 0, 0,
629 15, 4, 1, 1, 1, 0, 0,
630 16, 8, 1, 0, 0, 1, 0,
631 17, 1, 1, 0, 0, 0, 1,
632 18, 4, 0, 1, 1, 0, 0,
633 19, 2, 0, 0, 0, 0, 1,
634 20, 4, 0, 1, 0, 0, 1,
635 21, 1, 1, 1, 0, 1, 1,
636 22, 1, 0, 1, 1, 0, 1,
639 const int* problems[] = {
649 const unsigned int n_problems =
sizeof(problems)/
sizeof(
int*);