Go to the documentation of this file.
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) {
261 const int* probit = problems[
problem] + 3;
269 block[
i] = *probit++;
283 for (
int o = 0; o <
noptions; ++o) {
285 cdata[o][
n[o]++] =
c;
291 classes[o] =
IntSet(cdata[o],
n[o]);
318 for (
int i =
s.
size();
i--; ) {
320 dom(*
this,
s[
i], classes[o],
b);
327 switch (
opt.propagation()) {
348 switch (
opt.branching()) {
354 int mid =
s.
size() / 2;
357 for (
int i = 1;
i <= m.size()/2; ++
i) {
363 assert(
pos == m.size());
380 const char* space =
nclasses > 9 ?
" " :
"";
381 os <<
"Stall slots=" <<
nstall
382 <<
", End slots=" <<
nend << std::endl;
389 else os << std::setw(width) <<
v <<
" ";
393 if ((
i+1)%20 == 0) os << std::endl;
427 CarOptions
opt(
"CarSequencing");
437 if (
opt.size() >= n_problems) {
438 std::cerr <<
"Error: size must be between 0 and "
439 << n_problems-1 << std::endl;
443 Script::run<CarSequencing,BAB,CarOptions>(
opt);
472 1, 10, 1, 1, 1, 0, 0,
476 5, 15, 0, 1, 0, 0, 0,
481 10, 2, 1, 0, 1, 0, 0,
482 11, 1, 1, 1, 1, 0, 1,
483 12, 8, 0, 1, 0, 1, 0,
484 13, 3, 1, 0, 0, 1, 1,
485 14, 10, 1, 0, 0, 0, 0,
486 15, 4, 0, 1, 0, 0, 1,
487 16, 4, 0, 0, 0, 0, 1,
488 17, 2, 1, 0, 0, 0, 1,
489 18, 4, 1, 1, 0, 0, 0,
490 19, 6, 1, 1, 0, 1, 0,
491 20, 1, 1, 0, 1, 0, 1,
492 21, 1, 1, 1, 1, 1, 1,
502 0, 13, 1, 0, 0, 0, 0,
506 4, 12, 0, 0, 1, 0, 0,
511 9, 12, 1, 1, 0, 0, 0,
512 10, 8, 1, 1, 0, 1, 0,
513 11, 2, 1, 0, 0, 1, 1,
514 12, 2, 1, 1, 1, 0, 0,
515 13, 1, 0, 1, 0, 1, 1,
516 14, 4, 1, 0, 1, 0, 0,
517 15, 4, 0, 1, 0, 0, 1,
518 16, 1, 1, 1, 0, 1, 1,
519 17, 2, 1, 0, 1, 1, 0,
520 18, 1, 0, 0, 0, 0, 1,
521 19, 1, 1, 1, 1, 1, 0,
522 20, 1, 1, 1, 0, 0, 1,
523 21, 1, 0, 1, 1, 1, 0,
534 1, 11, 1, 1, 0, 0, 0,
537 4, 15, 0, 1, 0, 0, 0,
543 10, 5, 1, 0, 0, 0, 0,
544 11, 2, 1, 1, 1, 0, 1,
545 12, 6, 0, 1, 1, 0, 0,
546 13, 2, 0, 0, 1, 0, 1,
547 14, 2, 0, 1, 0, 0, 1,
548 15, 4, 1, 1, 1, 1, 0,
549 16, 3, 1, 0, 0, 0, 1,
550 17, 5, 1, 1, 0, 1, 0,
551 18, 2, 1, 1, 1, 0, 0,
552 19, 4, 1, 1, 0, 0, 1,
553 20, 1, 1, 0, 0, 1, 1,
554 21, 1, 1, 1, 0, 1, 1,
555 22, 1, 0, 1, 0, 1, 1,
556 23, 1, 0, 1, 1, 0, 1,
557 24, 2, 0, 0, 0, 0, 1,
567 0, 10, 1, 0, 0, 0, 0,
572 5, 11, 0, 1, 0, 0, 0,
577 10, 4, 1, 0, 1, 0, 0,
578 11, 7, 1, 0, 0, 1, 0,
579 12, 1, 1, 1, 1, 0, 1,
580 13, 3, 0, 1, 1, 1, 0,
581 14, 4, 0, 1, 0, 0, 1,
582 15, 5, 1, 1, 1, 0, 0,
583 16, 2, 1, 1, 0, 0, 1,
584 17, 1, 1, 0, 1, 1, 1,
585 18, 2, 1, 0, 1, 1, 0,
586 19, 3, 1, 0, 0, 0, 1,
587 20, 2, 0, 1, 1, 0, 1,
588 21, 1, 0, 1, 0, 1, 1,
589 22, 3, 1, 1, 0, 1, 0,
590 23, 1, 0, 0, 1, 1, 1,
591 24, 1, 1, 1, 1, 1, 1,
592 25, 1, 1, 1, 1, 1, 0,
610 8, 19, 0, 1, 0, 0, 0,
612 10, 10, 1, 0, 0, 0, 0,
613 11, 1, 0, 0, 1, 1, 0,
614 12, 5, 1, 1, 1, 1, 0,
615 13, 2, 1, 0, 1, 1, 0,
616 14, 6, 1, 1, 0, 0, 0,
617 15, 4, 1, 1, 1, 0, 0,
618 16, 8, 1, 0, 0, 1, 0,
619 17, 1, 1, 0, 0, 0, 1,
620 18, 4, 0, 1, 1, 0, 0,
621 19, 2, 0, 0, 0, 0, 1,
622 20, 4, 0, 1, 0, 0, 1,
623 21, 1, 1, 1, 0, 1, 1,
624 22, 1, 0, 1, 1, 0, 1,
627 const int* problems[] = {
637 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.
const int endval
End number.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Gecode::IntArgs i(4, 1, 2, 3, 4)
CarSequencing(const CarOptions &opt)
Initial model.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
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.
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
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.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
IntVar nend
Number of end markers.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
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.
CarSequencing(bool share, CarSequencing &cs)
Constructor for cloning s.
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 .
const int maxstall
Maximum number of stalls.
@ ES_FIX
Propagation has computed fixpoint.
Integer view for integer variables.
virtual Space * copy(bool share)
Copy during cloning.
int val(void) const
Return assigned value.
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.
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.
GECODE_FLATZINC_EXPORT FlatZincSpace * parse(const std::string &fileName, Printer &p, std::ostream &err=std::cerr, FlatZincSpace *fzs=NULL, FznRnd *rnd=NULL)
Parse FlatZinc file fileName into fzs and return it.
Options for scripts with additional size parameter
@ PROP_CUSTOM
Use custom constraint.