45 extern const int* problems[];
47 extern const unsigned int n_problems;
63 CarOptions(
const char* s)
65 _maxstall(
"maxstall",
"Maximum numbere of stalls", 30)
71 void parse(
int& argc,
char* argv[]) {
75 int maxstall(
void)
const {
return _maxstall.
value(); }
104 PushToEnd(
Space& home, PushToEnd&
p);
120 template <
class View>
122 PushToEnd<View>::PushToEnd(
Space& home,
126 template <
class View>
128 PushToEnd<View>::post(
Space& home,
130 (void)
new (home) PushToEnd<View>(home,x0,y0,val0);
134 template <
class View>
136 PushToEnd<View>::PushToEnd(
Space& home, PushToEnd<View>&
p)
139 template <
class View>
145 template <
class View>
147 PushToEnd<View>::copy(
Space& home) {
148 return new (home) PushToEnd<View>(home,*
this);
151 template <
class View>
156 for (
int i =
x.size(); i-- &&
x[i].min() >= val-1; ) {
164 if (
x[i].
max() != val)
break;
166 if (
max >=
y.max())
break;
179 for (
int i = 0, pos =
x.size()-1; i <
y.min(); ++i, --pos) {
257 const int* probit = problems[
problem] + 3;
261 for (
int i = 0; i <
noptions; ++i ) {
264 for (
int i = 0; i <
noptions; ++i ) {
265 block[i] = *probit++;
276 for (
int c = 0; c <
nclasses; ++c) {
279 for (
int o = 0; o <
noptions; ++o) {
281 cdata[o][
n[o]++] = c;
287 classes[o] =
IntSet(cdata[o],
n[o]);
297 c[i] =
IntSet(ncc[i], ncc[i]);
314 for (
int i =
s.
size(); i--; ) {
316 dom(*
this,
s[i], classes[o],
b);
323 switch (opt.propagation()) {
333 for (
int pos =
s.
size()-1, i = 0; i <
maxstall; ++i, --pos) {
344 switch (opt.branching()) {
350 int mid =
s.
size() / 2;
353 for (
int i = 1; i <= m.
size()/2; ++i) {
356 if (mid+i <
s.
size())
359 assert(pos == m.
size());
376 const char* space =
nclasses > 9 ?
" " :
"";
377 os <<
"Stall slots=" <<
nstall
378 <<
", End slots=" <<
nend << std::endl;
380 for (; i <
s.
size(); ++i) {
381 if (
s[i].assigned()) {
384 if (v ==
stallval) os << space <<
"_ ";
385 else os << std::setw(width) << v <<
" ";
389 if ((i+1)%20 == 0) os << std::endl;
423 CarOptions opt(
"CarSequencing");
432 opt.
parse(argc,argv);
433 if (opt.size() >= n_problems) {
434 std::cerr <<
"Error: size must be between 0 and "
435 << n_problems-1 << std::endl;
468 1, 10, 1, 1, 1, 0, 0,
472 5, 15, 0, 1, 0, 0, 0,
477 10, 2, 1, 0, 1, 0, 0,
478 11, 1, 1, 1, 1, 0, 1,
479 12, 8, 0, 1, 0, 1, 0,
480 13, 3, 1, 0, 0, 1, 1,
481 14, 10, 1, 0, 0, 0, 0,
482 15, 4, 0, 1, 0, 0, 1,
483 16, 4, 0, 0, 0, 0, 1,
484 17, 2, 1, 0, 0, 0, 1,
485 18, 4, 1, 1, 0, 0, 0,
486 19, 6, 1, 1, 0, 1, 0,
487 20, 1, 1, 0, 1, 0, 1,
488 21, 1, 1, 1, 1, 1, 1,
498 0, 13, 1, 0, 0, 0, 0,
502 4, 12, 0, 0, 1, 0, 0,
507 9, 12, 1, 1, 0, 0, 0,
508 10, 8, 1, 1, 0, 1, 0,
509 11, 2, 1, 0, 0, 1, 1,
510 12, 2, 1, 1, 1, 0, 0,
511 13, 1, 0, 1, 0, 1, 1,
512 14, 4, 1, 0, 1, 0, 0,
513 15, 4, 0, 1, 0, 0, 1,
514 16, 1, 1, 1, 0, 1, 1,
515 17, 2, 1, 0, 1, 1, 0,
516 18, 1, 0, 0, 0, 0, 1,
517 19, 1, 1, 1, 1, 1, 0,
518 20, 1, 1, 1, 0, 0, 1,
519 21, 1, 0, 1, 1, 1, 0,
530 1, 11, 1, 1, 0, 0, 0,
533 4, 15, 0, 1, 0, 0, 0,
539 10, 5, 1, 0, 0, 0, 0,
540 11, 2, 1, 1, 1, 0, 1,
541 12, 6, 0, 1, 1, 0, 0,
542 13, 2, 0, 0, 1, 0, 1,
543 14, 2, 0, 1, 0, 0, 1,
544 15, 4, 1, 1, 1, 1, 0,
545 16, 3, 1, 0, 0, 0, 1,
546 17, 5, 1, 1, 0, 1, 0,
547 18, 2, 1, 1, 1, 0, 0,
548 19, 4, 1, 1, 0, 0, 1,
549 20, 1, 1, 0, 0, 1, 1,
550 21, 1, 1, 1, 0, 1, 1,
551 22, 1, 0, 1, 0, 1, 1,
552 23, 1, 0, 1, 1, 0, 1,
553 24, 2, 0, 0, 0, 0, 1,
563 0, 10, 1, 0, 0, 0, 0,
568 5, 11, 0, 1, 0, 0, 0,
573 10, 4, 1, 0, 1, 0, 0,
574 11, 7, 1, 0, 0, 1, 0,
575 12, 1, 1, 1, 1, 0, 1,
576 13, 3, 0, 1, 1, 1, 0,
577 14, 4, 0, 1, 0, 0, 1,
578 15, 5, 1, 1, 1, 0, 0,
579 16, 2, 1, 1, 0, 0, 1,
580 17, 1, 1, 0, 1, 1, 1,
581 18, 2, 1, 0, 1, 1, 0,
582 19, 3, 1, 0, 0, 0, 1,
583 20, 2, 0, 1, 1, 0, 1,
584 21, 1, 0, 1, 0, 1, 1,
585 22, 3, 1, 1, 0, 1, 0,
586 23, 1, 0, 0, 1, 1, 1,
587 24, 1, 1, 1, 1, 1, 1,
588 25, 1, 1, 1, 1, 1, 0,
606 8, 19, 0, 1, 0, 0, 0,
608 10, 10, 1, 0, 0, 0, 0,
609 11, 1, 0, 0, 1, 1, 0,
610 12, 5, 1, 1, 1, 1, 0,
611 13, 2, 1, 0, 1, 1, 0,
612 14, 6, 1, 1, 0, 0, 0,
613 15, 4, 1, 1, 1, 0, 0,
614 16, 8, 1, 0, 0, 1, 0,
615 17, 1, 1, 0, 0, 0, 1,
616 18, 4, 0, 1, 1, 0, 0,
617 19, 2, 0, 0, 0, 0, 1,
618 20, 4, 0, 1, 0, 0, 1,
619 21, 1, 1, 1, 0, 1, 1,
620 22, 1, 0, 1, 1, 0, 1,
623 const int* problems[] = {
633 const unsigned int n_problems =
sizeof(problems)/
sizeof(
int*);
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
int main(int argc, char *argv[])
Main-function.
@ PROP_REGULAR
Use regular constraints.
@ PROP_CUSTOM
Use custom constraint.
const int endval
End number.
@ BRANCH_INORDER
Branch from left to right.
@ BRANCH_MIDDLE
Branch from middle out.
const int nclasses
Number of classes.
const int ncars
Number of cars.
virtual void constrain(const Space &_best)
Return cost.
IntVar nend
Number of end markers.
const int maxstall
Maximum number of stalls.
IntVar nstall
Number of stalls (cost to minimize)
CarSequencing(const CarOptions &opt)
Initial model.
IntVarArray s
Sequence of cars produced.
CarSequencing(CarSequencing &cs)
Constructor for cloning s.
virtual void print(std::ostream &os) const
Print solution.
const int noptions
Number of options.
const int stallval
Stall number.
const int problem
Problem number.
virtual Space * copy(void)
Copy during cloning.
Base-class for both propagators and branchers.
int size(void) const
Return size of array (number of elements)
Passing Boolean variables.
Boolean integer variables.
Parametric base-class for scripts.
static void run(const Options &opt, Script *s=NULL)
void value(unsigned int v)
Set default value to v.
Passing integer arguments.
Passing integer variables.
int val(void) const
Return assigned value.
Integer view for integer variables.
Base-class for propagators.
Regular expressions over integer values.
Options for scripts with additional size parameter
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
int size(void) const
Return size of array (number of elements)
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
bool assigned(void) const
Test whether view is assigned.
void parse(int argc, char *argv[])
Parse commandline arguments.
ExecStatus ES_SUBSUMED(Propagator &p)
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf=nullptr, FloatVarValPrint vvp=nullptr)
Branch over x with variable selection vars and value selection vals.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
void extensional(Home home, const IntVarArgs &x, DFA d, IntPropLevel ipl=IPL_DEF)
Post domain consistent propagator for extensional constraint described by a DFA.
GECODE_FLATZINC_EXPORT FlatZincSpace * parse(const std::string &fileName, Printer &p, std::ostream &err=std::cerr, FlatZincSpace *fzs=NULL, Rnd &rnd=defrnd)
Parse FlatZinc file fileName into fzs and return it.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Gecode toplevel namespace
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Post propagator for SetVar SetOpType SetVar SetRelType r
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel ipl=IPL_DEF)
Post propagator for .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Post propagator for SetVar SetOpType SetVar y
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Post propagator for SetVar x
Gecode::IntArgs i({1, 2, 3, 4})