Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
steel-mill.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, 2008
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 <fstream>
43 
44 using namespace Gecode;
45 
52 typedef int (*order_t)[2];
53 extern const int order_weight;
54 extern const int order_color;
55 
56 
62 extern int csplib_capacities[];
63 extern unsigned int csplib_ncapacities;
64 extern unsigned int csplib_maxcapacity;
65 extern int csplib_loss[];
66 extern int csplib_orders[][2];
67 extern unsigned int csplib_ncolors;
68 extern unsigned int csplib_norders;
69 
70 
71 
77 class SteelMillOptions : public Options {
78 private:
79  unsigned int _size;
80  int* _capacities;
81  int _ncapacities;
82  int _maxcapacity;
83  int* _loss;
84  order_t _orders;
85  int _ncolors;
86  unsigned int _norders;
87 public:
89  SteelMillOptions(const char* n)
90  : Options(n), _size(csplib_norders),
91  _capacities(csplib_capacities), _ncapacities(csplib_ncapacities),
92  _maxcapacity(csplib_maxcapacity),
93  _loss(csplib_loss), _orders(&(csplib_orders[0])), _ncolors(csplib_ncolors),
94  _norders(csplib_norders) {}
96  virtual void help(void);
98  bool parse(int& argc, char* argv[]);
99 
101  unsigned int size(void) const { return _size; }
103  int* capacities(void) const { return _capacities; }
105  int ncapacities(void) const { return _ncapacities; }
107  int maxcapacity(void) const { return _maxcapacity; }
109  int* loss(void) const { return _loss; }
111  order_t orders(void) const { return _orders; }
113  int ncolors(void) const { return _ncolors; }
115  int norders(void) const { return _norders; }
116 };
117 
120 public:
124  SortByWeight(order_t _orders) : orders(_orders) {}
126  bool operator() (int i, int j) {
127  // Order i comes before order j if the weight of i is larger than
128  // the weight of j.
129  return (orders[i][order_weight] > orders[j][order_weight]) ||
130  (orders[i][order_weight] == orders[j][order_weight] && i<j);
131  }
132 };
133 
162 class SteelMill : public IntMinimizeScript {
163 protected:
167  int* capacities;
170  int* loss;
171  int ncolors;
173  unsigned int norders;
174  unsigned int nslabs;
175 
176 
180  IntVarArray slab,
181  slabload,
182  slabcost;
184 
185 
186 public:
188  enum {
191  SYMMETRY_LDSB
192  };
193 
196  : // Initialize instance data
197  IntMinimizeScript(opt),
198  capacities(opt.capacities()), ncapacities(opt.ncapacities()),
199  maxcapacity(opt.maxcapacity()), loss(opt.loss()),
200  ncolors(opt.ncolors()), orders(opt.orders()),
201  norders(opt.size()), nslabs(opt.size()),
202  // Initialize problem variables
203  slab(*this, norders, 0,nslabs-1),
204  slabload(*this, nslabs, 0,45),
205  slabcost(*this, nslabs, 0, Int::Limits::max),
206  total_cost(*this, 0, Int::Limits::max)
207  {
208  // Boolean variables for slab[o]==s
209  BoolVarArgs boolslab(norders*nslabs);
210  for (unsigned int i = 0; i < norders; ++i) {
211  BoolVarArgs tmp(nslabs);
212  for (int j = nslabs; j--; ) {
213  boolslab[j + i*nslabs] = tmp[j] = BoolVar(*this, 0, 1);
214  }
215  channel(*this, tmp, slab[i]);
216  }
217 
218  // Packing constraints
219  for (unsigned int s = 0; s < nslabs; ++s) {
220  IntArgs c(norders);
221  BoolVarArgs x(norders);
222  for (int i = norders; i--; ) {
223  c[i] = orders[i][order_weight];
224  x[i] = boolslab[s + i*nslabs];
225  }
226  linear(*this, c, x, IRT_EQ, slabload[s]);
227  }
228  // Redundant packing constraint
229  int totalweight = 0;
230  for (unsigned int i = norders; i-- ; )
231  totalweight += orders[i][order_weight] ;
232  linear(*this, slabload, IRT_EQ, totalweight);
233 
234 
235  // Color constraints
236  IntArgs nofcolor(ncolors);
237  for (int c = ncolors; c--; ) {
238  nofcolor[c] = 0;
239  for (int o = norders; o--; ) {
240  if (orders[o][order_color] == c) nofcolor[c] += 1;
241  }
242  }
243  BoolVar f(*this, 0, 0);
244  for (unsigned int s = 0; s < nslabs; ++s) {
245  BoolVarArgs hascolor(ncolors);
246  for (int c = ncolors; c--; ) {
247  if (nofcolor[c]) {
248  BoolVarArgs hasc(nofcolor[c]);
249  int pos = 0;
250  for (int o = norders; o--; ) {
251  if (orders[o][order_color] == c)
252  hasc[pos++] = boolslab[s + o*nslabs];
253  }
254  assert(pos == nofcolor[c]);
255  hascolor[c] = BoolVar(*this, 0, 1);
256  rel(*this, BOT_OR, hasc, hascolor[c]);
257  } else {
258  hascolor[c] = f;
259  }
260  }
261  linear(*this, hascolor, IRT_LQ, 2);
262  }
263 
264  // Compute slabcost
265  IntArgs l(maxcapacity, loss);
266  for (int s = nslabs; s--; ) {
267  element(*this, l, slabload[s], slabcost[s]);
268  }
269  linear(*this, slabcost, IRT_EQ, total_cost);
270 
271  // Add branching
272  if (opt.symmetry() == SYMMETRY_BRANCHING) {
273  // Symmetry breaking branching
274  SteelMillBranch::post(*this);
275  } else if (opt.symmetry() == SYMMETRY_NONE) {
276  branch(*this, slab, INT_VAR_MAX_MIN(), INT_VAL_MIN());
277  } else { // opt.symmetry() == SYMMETRY_LDSB
278  // There is one symmetry: the values (slabs) are interchangeable.
279  Symmetries syms;
280  syms << ValueSymmetry(IntArgs::create(nslabs,0));
281 
282  // For variable order we mimic the custom brancher. We use
283  // min-size domain, breaking ties by maximum weight (preferring
284  // to label larger weights earlier). To do this, we first sort
285  // (stably) by maximum weight, then use min-size domain.
286  SortByWeight sbw(orders);
287  IntArgs indices(norders);
288  for (unsigned int i = 0 ; i < norders ; i++)
289  indices[i] = i;
290  Support::quicksort(&indices[0],norders,sbw);
291  IntVarArgs sorted_orders(norders);
292  for (unsigned int i = 0 ; i < norders ; i++) {
293  sorted_orders[i] = slab[indices[i]];
294  }
295  branch(*this, sorted_orders, INT_VAR_SIZE_MIN(), INT_VAL_MIN(), syms);
296  }
297  }
298 
300  virtual void
301  print(std::ostream& os) const {
302  os << "What slab=" << slab << std::endl;
303  os << "Slab load=" << slabload << std::endl;
304  os << "Slab cost=" << slabcost << std::endl;
305  os << "Total cost=" << total_cost << std::endl;
306  int nslabsused = 0;
307  int nslabscost = 0;
308  bool unassigned = false;
309  for (int i = nslabs; i--; ) {
310  if (!slabload[i].assigned() || !slabcost[i].assigned()) {
311  unassigned = true;
312  break;
313  }
314  if (slabload[i].min()>0) ++nslabsused;
315  if (slabcost[i].min()>0) ++nslabscost;
316  }
317  if (!unassigned)
318  os << "Number of slabs used=" << nslabsused
319  << ", slabs with cost=" << nslabscost
320  << std::endl;
321  os << std::endl;
322  }
323 
326  : IntMinimizeScript(s),
327  capacities(s.capacities), ncapacities(s.ncapacities),
328  maxcapacity(s.maxcapacity), loss(s.loss),
329  ncolors(s.ncolors), orders(s.orders),
330  norders(s.norders), nslabs(s.nslabs) {
331  slab.update(*this, s.slab);
332  slabload.update(*this, s.slabload);
333  slabcost.update(*this, s.slabcost);
334  total_cost.update(*this, s.total_cost);
335  }
337  virtual Space*
338  copy(void) {
339  return new SteelMill(*this);
340  }
342  virtual IntVar cost(void) const {
343  return total_cost;
344  }
345 
346 
356  protected:
358  mutable int start;
360  class Choice : public Gecode::Choice {
361  public:
363  int pos;
365  int val;
369  Choice(const Brancher& b, unsigned int a, int pos0, int val0)
370  : Gecode::Choice(b,a), pos(pos0), val(val0) {}
372  virtual void archive(Archive& e) const {
374  e << alternatives() << pos << val;
375  }
376  };
377 
380  : Brancher(home), start(0) {}
383  : Brancher(home, b), start(b.start) {
384  }
385 
386  public:
388  virtual bool status(const Space& home) const {
389  const SteelMill& sm = static_cast<const SteelMill&>(home);
390  for (unsigned int i = start; i < sm.norders; ++i)
391  if (!sm.slab[i].assigned()) {
392  start = i;
393  return true;
394  }
395  // No non-assigned orders left
396  return false;
397  }
399  virtual Gecode::Choice* choice(Space& home) {
400  SteelMill& sm = static_cast<SteelMill&>(home);
401  assert(!sm.slab[start].assigned());
402  // Find order with a) minimum size, b) largest weight
403  unsigned int size = sm.norders;
404  int weight = 0;
405  unsigned int pos = start;
406  for (unsigned int i = start; i<sm.norders; ++i) {
407  if (!sm.slab[i].assigned()) {
408  if (sm.slab[i].size() == size &&
409  sm.orders[i][order_weight] > weight) {
410  weight = sm.orders[i][order_weight];
411  pos = i;
412  } else if (sm.slab[i].size() < size) {
413  size = sm.slab[i].size();
414  weight = sm.orders[i][order_weight];
415  pos = i;
416  }
417  }
418  }
419  unsigned int val = sm.slab[pos].min();
420  // Find first still empty slab (all such slabs are symmetric)
421  unsigned int firstzero = 0;
422  while (firstzero < sm.nslabs && sm.slabload[firstzero].min() > 0)
423  ++firstzero;
424  assert(pos < sm.nslabs &&
425  val < sm.norders);
426  return new Choice(*this, (val<firstzero) ? 2 : 1, pos, val);
427  }
428  virtual Choice* choice(const Space&, Archive& e) {
429  unsigned int alt; int pos, val;
430  e >> alt >> pos >> val;
431  return new Choice(*this, alt, pos, val);
432  }
434  virtual ExecStatus commit(Space& home, const Gecode::Choice& _c,
435  unsigned int a) {
436  SteelMill& sm = static_cast<SteelMill&>(home);
437  const Choice& c = static_cast<const Choice&>(_c);
438  if (a)
439  return me_failed(Int::IntView(sm.slab[c.pos]).nq(home, c.val))
440  ? ES_FAILED : ES_OK;
441  else
442  return me_failed(Int::IntView(sm.slab[c.pos]).eq(home, c.val))
443  ? ES_FAILED : ES_OK;
444  }
446  virtual void print(const Space&, const Gecode::Choice& _c,
447  unsigned int a,
448  std::ostream& o) const {
449  const Choice& c = static_cast<const Choice&>(_c);
450  o << "slab[" << c.pos << "] "
451  << ((a == 0) ? "=" : "!=")
452  << " " << c.val;
453  }
455  virtual Actor* copy(Space& home) {
456  return new (home) SteelMillBranch(home, *this);
457  }
459  static void post(Home home) {
460  (void) new (home) SteelMillBranch(home);
461  }
463  virtual size_t dispose(Space&) {
464  return sizeof(*this);
465  }
466  };
467 };
468 
472 int
473 main(int argc, char* argv[]) {
474  SteelMillOptions opt("Steel Mill Slab design");
477  opt.symmetry(SteelMill::SYMMETRY_BRANCHING,"branching");
479  opt.solutions(0);
480  if (!opt.parse(argc,argv))
481  return 1;
482  Script::run<SteelMill,BAB,SteelMillOptions>(opt);
483  return 0;
484 }
485 
486 
487 void
489  Options::help();
490  std::cerr << "\t(string), optional" << std::endl
491  << "\t\tBenchmark to load." << std::endl
492  << "\t\tIf none is given, the standard CSPLib instance is used."
493  << std::endl;
494  std::cerr << "\t(unsigned int), optional" << std::endl
495  << "\t\tNumber of orders to use, in the interval [0..norders]."
496  << std::endl
497  << "\t\tIf none is given, all orders are used." << std::endl;
498 }
499 
500 bool
501 SteelMillOptions::parse(int& argc, char* argv[]) {
502  Options::parse(argc,argv);
503  // Check number of arguments
504  if (argc >= 4) {
505  std::cerr << "Too many arguments given, max two allowed (given={";
506  for (int i = 1; i < argc; ++i) {
507  std::cerr << "\"" << argv[i] << "\"";
508  if (i < argc-1) std::cerr << ",";
509  }
510  std::cerr << "})." << std::endl;
511  return false;
512  }
513  // Parse options
514  while (argc >= 2) {
515  bool issize = true;
516  for (int i = strlen(argv[argc-1]); i-- && issize; )
517  issize &= (isdigit(argv[argc-1][i]) != 0);
518  if (issize) {
519  _size = atoi(argv[argc-1]);
520  } else {
521  std::ifstream instance(argv[argc-1]);
522  if (instance.fail()) {
523  std::cerr << "Argument \"" << argv[argc-1]
524  << "\" is neither an integer nor a readable file"
525  << std::endl;
526  return false;
527  }
528  // Read file instance
529  instance >> _ncapacities;
530  _capacities = new int[_ncapacities];
531  _maxcapacity = -1;
532  for (int i = 0; i < _ncapacities; ++i) {
533  instance >> _capacities[i];
534  _maxcapacity = std::max(_maxcapacity, _capacities[i]);
535  }
536  instance >> _ncolors >> _norders;
537  _orders = new int[_norders][2];
538  for (unsigned int i = 0; i < _norders; ++i) {
539  instance >> _orders[i][order_weight] >> _orders[i][order_color];
540  }
541  }
542 
543  --argc;
544  }
545  // Compute loss
546  {
547  _loss = new int[_maxcapacity+1];
548  _loss[0] = 0;
549  int currcap = 0;
550  for (int c = 1; c < _maxcapacity; ++c) {
551  if (c > _capacities[currcap]) ++currcap;
552  _loss[c] = _capacities[currcap] - c;
553  }
554  }
555  // Set size, if none given
556  if (_size == 0) {
557  _size = _norders;
558  }
559  // Check size reasonability
560  if (_size == 0 || _size > _norders) {
561  std::cerr << "Size must be between 1 and " << _norders << std::endl;
562  return false;
563  }
564  return true;
565 }
566 
567 // Positions in order array
568 const int order_weight = 0;
569 const int order_color = 1;
570 
571 // CSPLib instance
573  {12, 14, 17, 18, 19,
574  20, 23, 24, 25, 26,
575  27, 28, 29, 30, 32,
576  35, 39, 42, 43, 44};
577 unsigned int csplib_ncapacities = 20;
578 unsigned int csplib_maxcapacity = 44;
579 int csplib_loss[45];
580 unsigned int csplib_ncolors = 89;
581 unsigned int csplib_norders = 111;
582 int csplib_orders[][2] = {
583  {4, 1},
584  {22, 2},
585  {9, 3},
586  {5, 4},
587  {8, 5},
588  {3, 6},
589  {3, 4},
590  {4, 7},
591  {7, 4},
592  {7, 8},
593  {3, 6},
594  {2, 6},
595  {2, 4},
596  {8, 9},
597  {5, 10},
598  {7, 11},
599  {4, 7},
600  {7, 11},
601  {5, 10},
602  {7, 11},
603  {8, 9},
604  {3, 1},
605  {25, 12},
606  {14, 13},
607  {3, 6},
608  {22, 14},
609  {19, 15},
610  {19, 15},
611  {22, 16},
612  {22, 17},
613  {22, 18},
614  {20, 19},
615  {22, 20},
616  {5, 21},
617  {4, 22},
618  {10, 23},
619  {26, 24},
620  {17, 25},
621  {20, 26},
622  {16, 27},
623  {10, 28},
624  {19, 29},
625  {10, 30},
626  {10, 31},
627  {23, 32},
628  {22, 33},
629  {26, 34},
630  {27, 35},
631  {22, 36},
632  {27, 37},
633  {22, 38},
634  {22, 39},
635  {13, 40},
636  {14, 41},
637  {16, 27},
638  {26, 34},
639  {26, 42},
640  {27, 35},
641  {22, 36},
642  {20, 43},
643  {26, 24},
644  {22, 44},
645  {13, 45},
646  {19, 46},
647  {20, 47},
648  {16, 48},
649  {15, 49},
650  {17, 50},
651  {10, 28},
652  {20, 51},
653  {5, 52},
654  {26, 24},
655  {19, 53},
656  {15, 54},
657  {10, 55},
658  {10, 56},
659  {13, 57},
660  {13, 58},
661  {13, 59},
662  {12, 60},
663  {12, 61},
664  {18, 62},
665  {10, 63},
666  {18, 64},
667  {16, 65},
668  {20, 66},
669  {12, 67},
670  {6, 68},
671  {6, 68},
672  {15, 69},
673  {15, 70},
674  {15, 70},
675  {21, 71},
676  {30, 72},
677  {30, 73},
678  {30, 74},
679  {30, 75},
680  {23, 76},
681  {15, 77},
682  {15, 78},
683  {27, 79},
684  {27, 80},
685  {27, 81},
686  {27, 82},
687  {27, 83},
688  {27, 84},
689  {27, 79},
690  {27, 85},
691  {27, 86},
692  {10, 87},
693  {3, 88}
694 };
695 
696 // STATISTICS: example-any
int ncapacities
Number of capacities.
Definition: steel-mill.cpp:168
SteelMillBranch(Home home)
Construct brancher.
Definition: steel-mill.cpp:379
ModEvent nq(Space &home, int n)
Restrict domain values to be different from n.
Definition: int.hpp:151
static IntArgs create(int n, int start, int inc=1)
Allocate array with n elements such that for all .
Definition: array.hpp:72
IntVarArray slab
Slab assigned to order i.
Definition: steel-mill.cpp:180
int val
Value of variable.
Definition: steel-mill.cpp:365
order_t orders
The orders.
Definition: steel-mill.cpp:122
unsigned int csplib_maxcapacity
Maximum capacity.
Definition: steel-mill.cpp:578
int * loss
Loss for all sizes.
Definition: steel-mill.cpp:170
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
int * capacities
Capacities.
Definition: steel-mill.cpp:167
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:242
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.
Definition: branch.cpp:43
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition: channel.cpp:45
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 update(Space &home, VarArray< Var > &a)
Update array to be a clone of array a.
Definition: array.hpp:1060
virtual bool status(const Space &home) const
Check status of brancher, return true if alternatives left.
Definition: steel-mill.cpp:388
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: int.hpp:160
unsigned int norders
Number of orders.
Definition: steel-mill.cpp:173
order_t orders(void) const
Return orders.
Definition: steel-mill.cpp:111
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
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.
Less or equal ( )
Definition: int.hh:907
int ncolors
Number of colors.
Definition: steel-mill.cpp:171
int ncapacities(void) const
Return number of capacities.
Definition: steel-mill.cpp:105
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
virtual void help(void)
Print help text.
Definition: steel-mill.cpp:488
int maxcapacity
Maximum capacity.
Definition: steel-mill.cpp:169
Collection of symmetries.
Definition: int.hh:5022
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
Definition: linear.cpp:45
Breaking symmetries with symmetry.
Definition: steel-mill.cpp:190
Simple symmetry.
Definition: steel-mill.cpp:189
SortByWeight(order_t _orders)
Initialize orders.
Definition: steel-mill.cpp:124
int start
Cache of first unassigned value.
Definition: steel-mill.cpp:358
Integer variable array.
Definition: int.hh:742
Multi _c(Gecode::IntArgs(3, 1, 2, 3))
const int order_weight
Weight-position in order-array elements.
Definition: steel-mill.cpp:568
unsigned int csplib_norders
Number of orders.
Definition: steel-mill.cpp:581
IntVarArray slabcost
Cost of slab j.
Definition: steel-mill.cpp:180
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
SteelMillOptions(const char *n)
Initialize options for example with name n.
Definition: steel-mill.cpp:89
virtual void print(std::ostream &os) const
Print solution.
Definition: steel-mill.cpp:301
virtual IntVar cost(void) const
Return solution cost.
Definition: steel-mill.cpp:342
Gecode::FloatVal c(-8, 8)
virtual Space * copy(void)
Copy during cloning.
Definition: steel-mill.cpp:338
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1368
int maxcapacity(void) const
Return maximum of capacities.
Definition: steel-mill.cpp:107
void quicksort(Type *l, Type *r, Less &less)
Standard quick sort.
Definition: sort.hpp:134
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
Sort orders by weight.
Definition: steel-mill.cpp:119
static void post(Home home)
Post brancher.
Definition: steel-mill.cpp:459
Execution has resulted in failure.
Definition: core.hpp:466
int csplib_orders[][2]
Orders.
Definition: steel-mill.cpp:582
virtual void archive(Archive &e) const
Archive into e.
Definition: steel-mill.cpp:372
virtual ExecStatus commit(Space &home, const Gecode::Choice &_c, unsigned int a)
Perform commit for choice _c and alternative a.
Definition: steel-mill.cpp:434
order_t orders
Orders.
Definition: steel-mill.cpp:172
virtual Actor * copy(Space &home)
Copy brancher.
Definition: steel-mill.cpp:455
int norders(void) const
Return number of orders.
Definition: steel-mill.cpp:115
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.
SymmetryHandle ValueSymmetry(const IntArgs &vs)
Values in v are interchangeable.
Definition: ldsb.cpp:85
IntVar total_cost
Total cost.
Definition: steel-mill.cpp:183
int * loss(void) const
Return loss values.
Definition: steel-mill.cpp:109
virtual Choice * choice(const Space &, Archive &e)
Return choice from e.
Definition: steel-mill.cpp:428
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Definition: var.hpp:128
int pos
Position of variable.
Definition: steel-mill.cpp:363
int csplib_capacities[]
Constants for CSPLib instance of the Steel Mill Slab Design Problem.
Definition: steel-mill.cpp:572
const int order_color
Color-position in order-array elements.
Definition: steel-mill.cpp:569
virtual Gecode::Choice * choice(Space &home)
Return choice.
Definition: steel-mill.cpp:399
int(* order_t)[2]
Order-specifications.
Definition: steel-mill.cpp:52
unsigned int nslabs
Number of slabs.
Definition: steel-mill.cpp:174
Disjunction.
Definition: int.hh:931
Passing integer variables.
Definition: int.hh:637
Passing integer arguments.
Definition: int.hh:608
Passing Boolean variables.
Definition: int.hh:691
int csplib_loss[]
Loss for all sizes.
Definition: steel-mill.cpp:579
Boolean integer variables.
Definition: int.hh:492
Choice(const Brancher &b, unsigned int a, int pos0, int val0)
Definition: steel-mill.cpp:369
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Definition: options.cpp:544
bool parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Definition: steel-mill.cpp:501
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:71
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
Definition: var.hpp:210
Post propagator for f(x \diamond_{\mathit{op}} y) \sim_r z \f$ void rel(Home home
Integer view for integer variables.
Definition: view.hpp:129
SteelMill(const SteelMillOptions &opt)
Actual model.
Definition: steel-mill.cpp:195
virtual void archive(Archive &e) const
Archive into e.
Definition: core.cpp:857
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Choice for performing commit
Definition: core.hpp:1338
virtual size_t dispose(Space &)
Delete brancher and return its size.
Definition: steel-mill.cpp:463
SteelMillOptions for examples with size option and an additional optional file name parameter...
Definition: steel-mill.cpp:77
Archive representation
Definition: archive.hpp:46
ExecStatus
Definition: core.hpp:464
Integer variables.
Definition: int.hh:351
Use LDSB for symmetry breaking.
Definition: steel-mill.cpp:191
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
void symmetry(int v)
Set default symmetry value.
Definition: options.hpp:194
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
IntVarBranch INT_VAR_MAX_MIN(BranchTbl tbl)
Select variable with smallest max.
Definition: var.hpp:200
unsigned int size(void) const
Return size.
Definition: steel-mill.cpp:101
void solutions(unsigned int n)
Set default number of solutions to search for.
Definition: options.hpp:287
Post propagator for SetVar x
Definition: set.hh:769
Execution is okay.
Definition: core.hpp:468
int ncolors(void) const
Return number of colors.
Definition: steel-mill.cpp:113
int * capacities(void) const
Return capacities.
Definition: steel-mill.cpp:103
Gecode toplevel namespace
SteelMillBranch(Space &home, SteelMillBranch &b)
Copy constructor.
Definition: steel-mill.cpp:382
Home class for posting propagators
Definition: core.hpp:846
unsigned int csplib_ncolors
Number of colors.
Definition: steel-mill.cpp:580
IntVarArray slabload
Load of slab j.
Definition: steel-mill.cpp:180
Options for scripts
Definition: driver.hh:370
unsigned int csplib_ncapacities
Number of capacities.
Definition: steel-mill.cpp:577
Example: Steel-mill slab design problem
Definition: steel-mill.cpp:162
int main(int argc, char *argv[])
Main-function.
Definition: steel-mill.cpp:473
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition: modevent.hpp:58
SteelMill(SteelMill &s)
Constructor for cloning s.
Definition: steel-mill.cpp:325
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .
Definition: element.cpp:43
virtual void print(const Space &, const Gecode::Choice &_c, unsigned int a, std::ostream &o) const
Print explanation.
Definition: steel-mill.cpp:446
Custom brancher for steel mill slab design.
Definition: steel-mill.cpp:355
virtual void help(void)
Print help text.
Definition: options.cpp:490