40 using namespace Gecode;
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) {
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*);
struct Gecode::@602::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.
Node * x
Pointer to corresponding Boolean expression node.
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)
virtual Space * copy(void)
Copy during cloning.
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.
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.
void value(unsigned int v)
Set default value to v.
FloatVal max(const FloatVal &x, const FloatVal &y)
Return maximum of x and y.
FloatVal min(const FloatVal &x, const FloatVal &y)
Return minimum of x and y.
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.
int pos(int h, int w, int h1, int w1)
void parse(int argc, char *argv[])
Parse commandline arguments.
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
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.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel)
Post propagator for .
Post propagator for SetVar SetOpType SetVar y
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
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 rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
bool pos(const View &x)
Test whether x is postive.
const FloatNum max
Largest allowed float value.
bool assigned(View x, int v)
Whether x is assigned to value v.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
unsigned int size(I &i)
Size of all ranges of range iterator i.
Gecode::FloatVal c(-8, 8)
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
Gecode::IntArgs i({1, 2, 3, 4})