Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
car-sequencing.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Mikael Lagerkvist <lagerkvist@gecode.org>
5  *
6  * Copyright:
7  * Mikael Lagerkvist, 2009
8  *
9  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include <gecode/driver.hh>
39 #include <gecode/int.hh>
40 #include <gecode/minimodel.hh>
41 
42 #include <iomanip>
43 
44 using namespace Gecode;
45 
46 // Problems
47 namespace {
48  // Problem data
49  extern const int* problems[];
50  // Number of problems
51  extern const unsigned int n_problems;
52 }
53 
54 namespace {
60  class CarOptions : public SizeOptions {
61  private:
63  Driver::UnsignedIntOption _maxstall;
64 
65  public:
67  CarOptions(const char* s)
68  : SizeOptions(s),
69  _maxstall("maxstall", "Maximum numbere of stalls", 30)
70  {
71  // Add options
72  add(_maxstall);
73  }
75  void parse(int& argc, char* argv[]) {
76  SizeOptions::parse(argc,argv);
77  }
79  int maxstall(void) const { return _maxstall.value(); }
80  };
81 
82 
100  template <class View>
101  class PushToEnd : public NaryOnePropagator<View,Int::PC_INT_BND> {
102  protected:
105  int val;
106 
108  PushToEnd(Space& home, PushToEnd& p);
110  PushToEnd(Space& home, ViewArray<View>& x0, View y0, int val0);
111  public:
113  PushToEnd(Space& home, Propagator& p,
114  ViewArray<View>& x0, View y0, int val0);
116  virtual Actor* copy(Space& home);
118  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
120  static ExecStatus post(Space& home,
121  ViewArray<View>& x0, View y0, int val0);
122  };
123 
124  template <class View>
125  inline
126  PushToEnd<View>::PushToEnd(Space& home,
127  ViewArray<View>& x0, View y0, int val0)
128  : NaryOnePropagator<View,Int::PC_INT_BND>(home,x0,y0), val(val0) {}
129 
130  template <class View>
131  ExecStatus
133  ViewArray<View>& x0, View y0, int val0) {
134  (void) new (home) PushToEnd<View>(home,x0,y0,val0);
135  return ES_OK;
136  }
137 
138  template <class View>
139  inline
140  PushToEnd<View>::PushToEnd(Space& home, PushToEnd<View>& p)
141  : NaryOnePropagator<View,Int::PC_INT_BND>(home,p), val(p.val) {}
142 
143  template <class View>
144  inline
145  PushToEnd<View>::PushToEnd(Space& home, Propagator& p,
146  ViewArray<View>& x0, View y0, int val0)
147  : NaryOnePropagator<View,Int::PC_INT_BND>(home,p,x0,y0), val(val0) {}
148 
149  template <class View>
150  Actor*
151  PushToEnd<View>::copy(Space& home) {
152  return new (home) PushToEnd<View>(home,*this);
153  }
154 
155  template <class View>
156  ExecStatus
157  PushToEnd<View>::propagate(Space& home, const ModEventDelta&) {
158  // Find number of required positions
159  int min = 0;
160  for (int i = x.size(); i-- && x[i].min() >= val-1; ) {
161  ++min;
162  }
163  // Find number of possible positions
164  int max = 0;
165  {
166  int i = x.size();
167  while (i--) {
168  if (x[i].max() != val) break;
169  ++max;
170  if (max >= y.max()) break;
171  }
172  // No variables later than max can have value val
173  while (i--) {
174  GECODE_ME_CHECK(x[i].le(home, val));
175  }
176  }
177 
178  // Constrain y to be in {min..max}
179  GECODE_ME_CHECK(y.gq(home, min));
180  GECODE_ME_CHECK(y.lq(home, max));
181 
182  // At least the y.min() last values have value val
183  for (int i = 0, pos = x.size()-1; i < y.min(); ++i, --pos) {
184  GECODE_ME_CHECK(x[pos].eq(home, val));
185  }
186 
187  return y.assigned() ? home.ES_SUBSUMED(*this) : ES_FIX;
188  }
189 
192  void pushtoend(Space& home, IntVarArgs x, IntVar y, int val) {
193  ViewArray<Int::IntView> vx(home, x);
194  Int::IntView vy(y);
195  GECODE_ES_FAIL(PushToEnd<Int::IntView>::post(home, vx, vy, val));
196  }
197 
198 }
199 
200 
212 class CarSequencing : public Script {
213 public:
215  enum {
217  BRANCH_MIDDLE
218  };
220  enum {
222  PROP_CUSTOM
223  };
224 protected:
226  const int problem;
228  const int ncars;
230  const int noptions;
232  const int nclasses;
234  const int maxstall;
236  const int stallval;
238  const int endval;
245 public:
247  CarSequencing(const CarOptions& opt)
248  : Script(opt),
249  problem(opt.size()),
250  ncars(problems[problem][0]),
251  noptions(problems[problem][1]),
252  nclasses(problems[problem][2]),
253  maxstall(opt.maxstall()),
254  stallval(nclasses),
255  endval(nclasses+1),
256  nstall(*this, 0, maxstall),
257  nend(*this, 0, maxstall),
258  s(*this, ncars+maxstall, 0, nclasses+1)
259  {
260  // Read problem
261  const int* probit = problems[problem] + 3;
262 
263  // Sequence requirements for the options.
264  IntArgs max(noptions), block(noptions);
265  for (int i = 0; i < noptions; ++i ) {
266  max[i] = *probit++;
267  }
268  for (int i = 0; i < noptions; ++i ) {
269  block[i] = *probit++;
270  }
271  // Number of cars per class
272  IntArgs ncc(nclasses);
273  // What classes require an option
274  IntSetArgs classes(noptions);
275  int** cdata = new int*[noptions];
276  for (int i = noptions; i--; ) cdata[i] = new int[nclasses];
277  int* n = new int[noptions];
278  for (int i = noptions; i--; ) n[i] = 0;
279  // Read data
280  for (int c = 0; c < nclasses; ++c) {
281  probit++;
282  ncc[c] = *probit++;
283  for (int o = 0; o < noptions; ++o) {
284  if (*probit++) {
285  cdata[o][n[o]++] = c;
286  }
287  }
288  }
289  // Transfer specification data to int-sets
290  for (int o = noptions; o--; ) {
291  classes[o] = IntSet(cdata[o], n[o]);
292  delete [] cdata[o];
293  }
294  delete [] cdata;
295  delete [] n;
296 
297  // Count the cars
298  {
299  IntSetArgs c(nclasses+2);
300  for (int i = nclasses; i--; ) {
301  c[i] = IntSet(ncc[i], ncc[i]);
302  }
303  c[stallval] = IntSet(0, maxstall);
304  c[ endval] = IntSet(0, maxstall);
305  count(*this, s, c);
306  }
307 
308  // Count number of end and stalls
309  count(*this, s, stallval, IRT_EQ, nstall);
310  count(*this, s, endval, IRT_EQ, nend);
311  rel(*this, nstall+nend == maxstall);
312 
313  // Make sure nothing is overloaded
314  IntSet one(1, 1);
315  for (int o = noptions; o--; ) {
316  // sb[i] reflects if car s[i] has option o
317  BoolVarArgs sb(s.size());
318  for (int i = s.size(); i--; ) {
319  BoolVar b(*this, 0, 1);
320  dom(*this, s[i], classes[o], b);
321  sb[i] = b;
322  }
323  sequence(*this, sb, one, block[o], 0, max[o]);
324  }
325 
326  // End-markers located at end only
327  switch (opt.propagation()) {
328  case PROP_REGULAR: {
329  IntArgs notend(nclasses), notstallend(nclasses+1);
330  for (int i = nclasses; i--; ) {
331  notend[i] = i;
332  notstallend[i] = i;
333  }
334  notstallend[nclasses] = stallval;
335  REG r = *REG(notend) + REG(notstallend) + *REG(endval);
336  extensional(*this, s, r);
337  for (int pos = s.size()-1, i = 0; i < maxstall; ++i, --pos) {
338  rel(*this, (nend > i) >> (s[pos]==endval));
339  }
340  } break;
341  case PROP_CUSTOM: {
342  pushtoend(*this, s, nend, endval);
343  } break;
344  }
345 
346 
347  // Branching
348  switch (opt.branching()) {
349  case BRANCH_INORDER:
350  branch(*this, s, INT_VAR_NONE(), INT_VAL_MIN());
351  break;
352  case BRANCH_MIDDLE: {
353  IntVarArgs m(s.size());
354  int mid = s.size() / 2;
355  int pos = 0;
356  m[pos++] = s[mid];
357  for (int i = 1; i <= m.size()/2; ++i) {
358  if (mid-i >= 0)
359  m[pos++] = s[mid-i];
360  if (mid+i < s.size())
361  m[pos++] = s[mid+i];
362  }
363  assert(pos == m.size());
364  branch(*this, m, INT_VAR_NONE(), INT_VAL_MIN());
365  break;
366  }
367  }
368  }
369 
371  virtual void constrain(const Space& _best) {
372  const CarSequencing& best = static_cast<const CarSequencing&>(_best);
373  rel(*this, nstall, IRT_LE, best.nstall.val());
374  }
375 
377  virtual void
378  print(std::ostream& os) const {
379  int width = nclasses > 9 ? 2 : 1;
380  const char* space = nclasses > 9 ? " " : "";
381  os << "Stall slots=" << nstall
382  << ", End slots=" << nend << std::endl;
383  int i = 0;
384  for (; i < s.size(); ++i) {
385  if (s[i].assigned()) {
386  int v = s[i].val();
387  if (v == endval) break;
388  if (v == stallval) os << space << "_ ";
389  else os << std::setw(width) << v << " ";
390  } else {
391  os << space << "? ";
392  }
393  if ((i+1)%20 == 0) os << std::endl;
394  }
395  if (i%20)
396  os << std::endl;
397  os << std::endl;
398  }
399 
402  : Script(cs),
403  problem(cs.problem),
404  ncars(cs.ncars),
405  noptions(cs.noptions),
406  nclasses(cs.nclasses),
407  maxstall(cs.maxstall),
408  stallval(cs.stallval),
409  endval(cs.endval)
410  {
411  nstall.update(*this, cs.nstall);
412  nend.update(*this, cs.nend);
413  s.update(*this, cs.s);
414  }
416  virtual Space*
417  copy(void) {
418  return new CarSequencing(*this);
419  }
420 };
421 
425 int
426 main(int argc, char* argv[]) {
427  CarOptions opt("CarSequencing");
428  opt.solutions(0);
429  opt.size(0);
430  opt.branching(CarSequencing::BRANCH_INORDER);
431  opt.branching(CarSequencing::BRANCH_INORDER, "inorder");
432  opt.branching(CarSequencing::BRANCH_MIDDLE, "middle");
433  opt.propagation(CarSequencing::PROP_CUSTOM);
434  opt.propagation(CarSequencing::PROP_REGULAR, "regular");
435  opt.propagation(CarSequencing::PROP_CUSTOM, "custom");
436  opt.parse(argc,argv);
437  if (opt.size() >= n_problems) {
438  std::cerr << "Error: size must be between 0 and "
439  << n_problems-1 << std::endl;
440  return 1;
441  }
442 
443  Script::run<CarSequencing,BAB,CarOptions>(opt);
444  return 0;
445 }
446 
447 
448 namespace {
450 
452  const int p0[] = {
453  10, 5, 6,
454  1, 2, 1, 2, 1,
455  2, 3, 3, 5, 5,
456  0, 1, 1, 0, 1, 1, 0,
457  1, 1, 0, 0, 0, 1, 0,
458  2, 2, 0, 1, 0, 0, 1,
459  3, 2, 0, 1, 0, 1, 0,
460  4, 2, 1, 0, 1, 0, 0,
461  5, 2, 1, 1, 0, 0, 0
462  };
463 
464  // ---------------------------------
465  // Problem 4/72 (Regin & Puget // 1)
466  // ---------------------------------
467  const int p1[] = {
468  100, 5, 22,
469  1, 2, 1, 2, 1,
470  2, 3, 3, 5, 5,
471  0, 6, 1, 0, 0, 1, 0,
472  1, 10, 1, 1, 1, 0, 0,
473  2, 2, 1, 1, 0, 0, 1,
474  3, 2, 0, 1, 1, 0, 0,
475  4, 8, 0, 0, 0, 1, 0,
476  5, 15, 0, 1, 0, 0, 0,
477  6, 1, 0, 1, 1, 1, 0,
478  7, 5, 0, 0, 1, 1, 0,
479  8, 2, 1, 0, 1, 1, 0,
480  9, 3, 0, 0, 1, 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,
493  };
494 
495  // --------------------------------
496  // Problem 6/76, (Regin & Puget // 2)
497  // --------------------------------
498  const int p2[] = {
499  100, 5, 22,
500  1, 2, 1, 2, 1,
501  2, 3, 3, 5, 5,
502  0, 13, 1, 0, 0, 0, 0,
503  1, 8, 0, 0, 0, 1, 0,
504  2, 7, 0, 1, 0, 0, 0,
505  3, 1, 1, 0, 0, 1, 0,
506  4, 12, 0, 0, 1, 0, 0,
507  5, 5, 0, 1, 0, 1, 0,
508  6, 5, 0, 0, 1, 1, 0,
509  7, 6, 0, 1, 1, 0, 0,
510  8, 3, 1, 0, 0, 0, 1,
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,
524  };
525 
526  // ---------------------------------
527  // Problem 10/93, (Regin & Puget // 3)
528  // ---------------------------------
529  const int p3[] = {
530  100, 5, 25,
531  1, 2, 1, 2, 1,
532  2, 3, 3, 5, 5,
533  0, 7, 1, 0, 0, 1, 0,
534  1, 11, 1, 1, 0, 0, 0,
535  2, 1, 0, 1, 1, 1, 1,
536  3, 3, 1, 0, 1, 0, 0,
537  4, 15, 0, 1, 0, 0, 0,
538  5, 2, 1, 0, 1, 1, 0,
539  6, 8, 0, 1, 0, 1, 0,
540  7, 5, 0, 0, 1, 0, 0,
541  8, 3, 0, 0, 0, 1, 0,
542  9, 4, 0, 1, 1, 1, 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,
558  };
559 
560  // --------------
561  // Problem 16/81,
562  // --------------
563  const int p4[] = {
564  100, 5, 26,
565  1, 2, 1, 2, 1,
566  2, 3, 3, 5, 5,
567  0, 10, 1, 0, 0, 0, 0,
568  1, 2, 0, 0, 0, 0, 1,
569  2, 8, 0, 1, 0, 1, 0,
570  3, 8, 0, 0, 0, 1, 0,
571  4, 6, 0, 1, 1, 0, 0,
572  5, 11, 0, 1, 0, 0, 0,
573  6, 3, 0, 0, 1, 0, 0,
574  7, 2, 0, 0, 1, 1, 0,
575  8, 7, 1, 1, 0, 0, 0,
576  9, 2, 1, 0, 0, 1, 1,
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,
593  };
594 
595  // ----------------------------------
596  // Problem 19/71, (Regin & Puget // 4)
597  // ----------------------------------
598  const int p5[] = {
599  100, 5, 23,
600  1, 2, 1, 2, 1,
601  2, 3, 3, 5, 5,
602  0, 2, 0, 0, 0, 1, 1,
603  1, 2, 0, 0, 1, 0, 1,
604  2, 5, 0, 1, 1, 1, 0,
605  3, 4, 0, 0, 0, 1, 0,
606  4, 4, 0, 1, 0, 1, 0,
607  5, 1, 1, 1, 0, 0, 1,
608  6, 3, 1, 1, 1, 0, 1,
609  7, 4, 0, 0, 1, 0, 0,
610  8, 19, 0, 1, 0, 0, 0,
611  9, 7, 1, 1, 0, 1, 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,
625  };
626 
627  const int* problems[] = {
628  &p0[0],
629  &p1[0],
630  &p2[0],
631  &p3[0],
632  &p4[0],
633  &p5[0],
634  };
635 
637  const unsigned int n_problems = sizeof(problems)/sizeof(int*);
638 };
639 
640 // STATISTICS: example-any
641 
Use regular constraints.
Options for scripts with additional size parameter
Definition: driver.hh:679
IntVarBranch INT_VAR_NONE(void)
Select first unassigned variable.
Definition: var.hpp:100
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:242
const int noptions
Number of options.
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel)
Post propagator for .
Definition: sequence.cpp:51
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3433
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:973
const FloatNum max
Largest allowed float value.
Definition: float.hh:848
void count(Home home, const IntVarArgs &x, int n, IntRelType irt, int m, IntPropLevel)
Post propagator for .
Definition: count.cpp:44
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
Definition: linear.cpp:50
void update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Definition: array.hpp:1060
Example: Car sequencing
Regular expressions over integer values.
Definition: minimodel.hh:1522
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Definition: options.cpp:670
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.
static int val(const Space &, IntVar x, int)
Value selection function for branching.
Definition: black-hole.cpp:243
const int nclasses
Number of classes.
bool assigned(void) const
Test if all variables are assigned.
Definition: array.hpp:1073
bool pos(const View &x)
Test whether x is postive.
Definition: mult.hpp:45
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition: dom.cpp:44
Base-class for propagators.
Definition: core.hpp:1016
Integer variable array.
Definition: int.hh:742
IntVarArray x
Card at position.
Definition: black-hole.cpp:106
Propagation has computed fixpoint.
Definition: core.hpp:469
Computation spaces.
Definition: core.hpp:1668
Parametric base-class for scripts.
Definition: driver.hh:733
Base-class for both propagators and branchers.
Definition: core.hpp:620
void value(unsigned int v)
Set default value to v.
Definition: options.hpp:95
Gecode::FloatVal c(-8, 8)
Branch from middle out.
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
const FloatNum min
Smallest allowed float value.
Definition: float.hh:850
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Equality ( )
Definition: int.hh:905
Options opt
The options.
Definition: test.cpp:101
int main(int argc, char *argv[])
Main-function.
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
const int maxstall
Maximum number of stalls.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
void extensional(Home home, const IntVarArgs &x, DFA dfa, IntPropLevel)
Post domain consistent propagator for extensional constraint described by a DFA.
Definition: extensional.cpp:47
int val(void) const
Return assigned value.
Definition: int.hpp:60
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Definition: val.hpp:59
unsigned int size(I &i)
Size of all ranges of range iterator i.
void branch(Home home, const IntVarArgs &x, const BoolVarArgs &y, IntBoolVarBranch vars, IntValBranch vals)
Branch function for integer and Boolean variables.
Definition: branch.cpp:124
Unsigned integer option.
Definition: driver.hh:233
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Definition: var.hpp:128
(n+1)-ary propagator
Definition: pattern.hpp:176
Use custom constraint.
Less ( )
Definition: int.hh:908
Integer sets.
Definition: int.hh:174
View arrays.
Definition: array.hpp:228
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:56
Passing integer variables.
Definition: int.hh:637
const int ncars
Number of cars.
Passing integer arguments.
Definition: int.hh:608
Passing Boolean variables.
Definition: int.hh:691
CarSequencing(CarSequencing &cs)
Constructor for cloning s.
Branch from left to right.
Boolean integer variables.
Definition: int.hh:492
const int v[7]
Definition: distinct.cpp:263
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Integer view for integer variables.
Definition: view.hpp:129
const int endval
End number.
IntVarArray y
Position of card.
Definition: black-hole.cpp:106
IntVarArray s
Sequence of cars produced.
const int stallval
Stall number.
ExecStatus
Definition: core.hpp:464
Integer variables.
Definition: int.hh:351
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
CarSequencing(const CarOptions &opt)
Initial model.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
Execution is okay.
Definition: core.hpp:468
const int problem
Problem number.
virtual Space * copy(void)
Copy during cloning.
Gecode toplevel namespace
virtual void constrain(const Space &_best)
Return cost.
IntVar nstall
Number of stalls (cost to minimize)
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91
virtual void print(std::ostream &os) const
Print solution.
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition: macros.hpp:107
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition: filter.cpp:142
IntVar nend
Number of end markers.