Go to the documentation of this file.
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>
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;
265 block[
i] = *probit++;
279 for (
int o = 0; o <
noptions; ++o) {
281 cdata[o][
n[o]++] =
c;
287 classes[o] =
IntSet(cdata[o],
n[o]);
314 for (
int i =
s.
size();
i--; ) {
316 dom(*
this,
s[
i], classes[o],
b);
323 switch (
opt.propagation()) {
344 switch (
opt.branching()) {
350 int mid =
s.
size() / 2;
353 for (
int i = 1;
i <= m.size()/2; ++
i) {
359 assert(
pos == m.size());
376 const char* space =
nclasses > 9 ?
" " :
"";
377 os <<
"Stall slots=" <<
nstall
378 <<
", End slots=" <<
nend << std::endl;
385 else os << std::setw(width) <<
v <<
" ";
389 if ((
i+1)%20 == 0) os << std::endl;
423 CarOptions
opt(
"CarSequencing");
433 if (
opt.size() >= n_problems) {
434 std::cerr <<
"Error: size must be between 0 and "
435 << n_problems-1 << std::endl;
439 Script::run<CarSequencing,BAB,CarOptions>(
opt);
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*);
@ BRANCH_MIDDLE
Branch from middle out.
Post propagator for SetVar SetOpType SetVar y
virtual void print(std::ostream &os) const
Print solution.
FloatVal max(const FloatVal &x, const FloatVal &y)
Return maximum of x and y.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
ExecStatus ES_SUBSUMED(Propagator &p)
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
FloatVal min(const FloatVal &x, const FloatVal &y)
Return minimum of x and y.
Passing integer variables.
unsigned int size(I &i)
Size of all ranges of range iterator i.
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
@ BRANCH_INORDER
Branch from left to right.
bool assigned(View x, int v)
Whether x is assigned to value v.
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
const int endval
End number.
CarSequencing(const CarOptions &opt)
Initial model.
Base-class for both propagators and branchers.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Regular expressions over integer values.
bool assigned(void) const
Test whether view is assigned.
int size(void) const
Return size of array (number of elements)
const int problem
Problem number.
void value(unsigned int v)
Set default value to v.
Gecode toplevel namespace
virtual void constrain(const Space &_best)
Return cost.
Base-class for propagators.
const int stallval
Stall number.
IntVarArray s
Sequence of cars produced.
Node * x
Pointer to corresponding Boolean expression node.
const int noptions
Number of options.
Passing Boolean variables.
Parametric base-class for scripts.
IntVar nend
Number of end markers.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Boolean integer variables.
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
int main(int argc, char *argv[])
Main-function.
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
IntVar nstall
Number of stalls (cost to minimize)
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
@ PROP_REGULAR
Use regular constraints.
int pos(int h, int w, int h1, int w1)
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
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.
virtual Space * copy(void)
Copy during cloning.
CarSequencing(CarSequencing &cs)
Constructor for cloning s.
const int maxstall
Maximum number of stalls.
@ ES_FIX
Propagation has computed fixpoint.
Integer view for integer variables.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
int val(void) const
Return assigned value.
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel)
Post propagator for .
void parse(int argc, char *argv[])
Parse commandline arguments.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Gecode::FloatVal c(-8, 8)
const int nclasses
Number of classes.
int n
Number of negative literals for node type.
const int ncars
Number of cars.
Passing integer arguments.
int ModEventDelta
Modification event deltas.
Gecode::IntArgs i({1, 2, 3, 4})
bool pos(const View &x)
Test whether x is postive.
@ ES_OK
Execution is okay.
int p
Number of positive literals for node type.
const FloatNum max
Largest allowed float value.
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Options for scripts with additional size parameter
@ PROP_CUSTOM
Use custom constraint.