Generated on Tue Jun 9 2015 04:02:52 for Gecode by doxygen 1.8.6
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: 2015-03-17 16:09:39 +0100 (Tue, 17 Mar 2015) $ by $Author: schulte $
11  * $Revision: 14447 $
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 
325  SteelMill(bool share, SteelMill& s)
326  : IntMinimizeScript(share,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, share, s.slab);
332  slabload.update(*this, share, s.slabload);
333  slabcost.update(*this, share, s.slabcost);
334  total_cost.update(*this, share, s.total_cost);
335  }
337  virtual Space*
338  copy(bool share) {
339  return new SteelMill(share,*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 size_t size(void) const {
373  return sizeof(Choice);
374  }
376  virtual void archive(Archive& e) const {
378  e << alternatives() << pos << val;
379  }
380  };
381 
384  : Brancher(home), start(0) {}
386  SteelMillBranch(Space& home, bool share, SteelMillBranch& b)
387  : Brancher(home, share, b), start(b.start) {
388  }
389 
390  public:
392  virtual bool status(const Space& home) const {
393  const SteelMill& sm = static_cast<const SteelMill&>(home);
394  for (unsigned int i = start; i < sm.norders; ++i)
395  if (!sm.slab[i].assigned()) {
396  start = i;
397  return true;
398  }
399  // No non-assigned orders left
400  return false;
401  }
403  virtual Gecode::Choice* choice(Space& home) {
404  SteelMill& sm = static_cast<SteelMill&>(home);
405  assert(!sm.slab[start].assigned());
406  // Find order with a) minimum size, b) largest weight
407  unsigned int size = sm.norders;
408  int weight = 0;
409  unsigned int pos = start;
410  for (unsigned int i = start; i<sm.norders; ++i) {
411  if (!sm.slab[i].assigned()) {
412  if (sm.slab[i].size() == size &&
413  sm.orders[i][order_weight] > weight) {
414  weight = sm.orders[i][order_weight];
415  pos = i;
416  } else if (sm.slab[i].size() < size) {
417  size = sm.slab[i].size();
418  weight = sm.orders[i][order_weight];
419  pos = i;
420  }
421  }
422  }
423  unsigned int val = sm.slab[pos].min();
424  // Find first still empty slab (all such slabs are symmetric)
425  unsigned int firstzero = 0;
426  while (firstzero < sm.nslabs && sm.slabload[firstzero].min() > 0)
427  ++firstzero;
428  assert(pos < sm.nslabs &&
429  val < sm.norders);
430  return new Choice(*this, (val<firstzero) ? 2 : 1, pos, val);
431  }
432  virtual Choice* choice(const Space&, Archive& e) {
433  unsigned int alt; int pos, val;
434  e >> alt >> pos >> val;
435  return new Choice(*this, alt, pos, val);
436  }
438  virtual ExecStatus commit(Space& home, const Gecode::Choice& _c,
439  unsigned int a) {
440  SteelMill& sm = static_cast<SteelMill&>(home);
441  const Choice& c = static_cast<const Choice&>(_c);
442  if (a)
443  return me_failed(Int::IntView(sm.slab[c.pos]).nq(home, c.val))
444  ? ES_FAILED : ES_OK;
445  else
446  return me_failed(Int::IntView(sm.slab[c.pos]).eq(home, c.val))
447  ? ES_FAILED : ES_OK;
448  }
450  virtual void print(const Space&, const Gecode::Choice& _c,
451  unsigned int a,
452  std::ostream& o) const {
453  const Choice& c = static_cast<const Choice&>(_c);
454  o << "slab[" << c.pos << "] "
455  << ((a == 0) ? "=" : "!=")
456  << " " << c.val;
457  }
459  virtual Actor* copy(Space& home, bool share) {
460  return new (home) SteelMillBranch(home, share, *this);
461  }
463  static BrancherHandle post(Home home) {
464  return *new (home) SteelMillBranch(home);
465  }
467  virtual size_t dispose(Space&) {
468  return sizeof(*this);
469  }
470  };
471 };
472 
476 int
477 main(int argc, char* argv[]) {
478  SteelMillOptions opt("Steel Mill Slab design");
481  opt.symmetry(SteelMill::SYMMETRY_BRANCHING,"branching");
483  opt.solutions(0);
484  if (!opt.parse(argc,argv))
485  return 1;
486  Script::run<SteelMill,BAB,SteelMillOptions>(opt);
487  return 0;
488 }
489 
490 
491 void
493  Options::help();
494  std::cerr << "\t(string), optional" << std::endl
495  << "\t\tBenchmark to load." << std::endl
496  << "\t\tIf none is given, the standard CSPLib instance is used."
497  << std::endl;
498  std::cerr << "\t(unsigned int), optional" << std::endl
499  << "\t\tNumber of orders to use, in the interval [0..norders]."
500  << std::endl
501  << "\t\tIf none is given, all orders are used." << std::endl;
502 }
503 
504 bool
505 SteelMillOptions::parse(int& argc, char* argv[]) {
506  Options::parse(argc,argv);
507  // Check number of arguments
508  if (argc >= 4) {
509  std::cerr << "Too many arguments given, max two allowed (given={";
510  for (int i = 1; i < argc; ++i) {
511  std::cerr << "\"" << argv[i] << "\"";
512  if (i < argc-1) std::cerr << ",";
513  }
514  std::cerr << "})." << std::endl;
515  return false;
516  }
517  // Parse options
518  while (argc >= 2) {
519  bool issize = true;
520  for (int i = strlen(argv[argc-1]); i-- && issize; )
521  issize &= (isdigit(argv[argc-1][i]) != 0);
522  if (issize) {
523  _size = atoi(argv[argc-1]);
524  } else {
525  std::ifstream instance(argv[argc-1]);
526  if (instance.fail()) {
527  std::cerr << "Argument \"" << argv[argc-1]
528  << "\" is neither an integer nor a readable file"
529  << std::endl;
530  return false;
531  }
532  // Read file instance
533  instance >> _ncapacities;
534  _capacities = new int[_ncapacities];
535  _maxcapacity = -1;
536  for (int i = 0; i < _ncapacities; ++i) {
537  instance >> _capacities[i];
538  _maxcapacity = std::max(_maxcapacity, _capacities[i]);
539  }
540  instance >> _ncolors >> _norders;
541  _orders = new int[_norders][2];
542  for (unsigned int i = 0; i < _norders; ++i) {
543  instance >> _orders[i][order_weight] >> _orders[i][order_color];
544  }
545  }
546 
547  --argc;
548  }
549  // Compute loss
550  {
551  _loss = new int[_maxcapacity+1];
552  _loss[0] = 0;
553  int currcap = 0;
554  for (int c = 1; c < _maxcapacity; ++c) {
555  if (c > _capacities[currcap]) ++currcap;
556  _loss[c] = _capacities[currcap] - c;
557  }
558  }
559  // Set size, if none given
560  if (_size == 0) {
561  _size = _norders;
562  }
563  // Check size reasonability
564  if (_size == 0 || _size > _norders) {
565  std::cerr << "Size must be between 1 and " << _norders << std::endl;
566  return false;
567  }
568  return true;
569 }
570 
571 // Positions in order array
572 const int order_weight = 0;
573 const int order_color = 1;
574 
575 // CSPLib instance
577  {12, 14, 17, 18, 19,
578  20, 23, 24, 25, 26,
579  27, 28, 29, 30, 32,
580  35, 39, 42, 43, 44};
581 unsigned int csplib_ncapacities = 20;
582 unsigned int csplib_maxcapacity = 44;
583 int csplib_loss[45];
584 unsigned int csplib_ncolors = 89;
585 unsigned int csplib_norders = 111;
586 int csplib_orders[][2] = {
587  {4, 1},
588  {22, 2},
589  {9, 3},
590  {5, 4},
591  {8, 5},
592  {3, 6},
593  {3, 4},
594  {4, 7},
595  {7, 4},
596  {7, 8},
597  {3, 6},
598  {2, 6},
599  {2, 4},
600  {8, 9},
601  {5, 10},
602  {7, 11},
603  {4, 7},
604  {7, 11},
605  {5, 10},
606  {7, 11},
607  {8, 9},
608  {3, 1},
609  {25, 12},
610  {14, 13},
611  {3, 6},
612  {22, 14},
613  {19, 15},
614  {19, 15},
615  {22, 16},
616  {22, 17},
617  {22, 18},
618  {20, 19},
619  {22, 20},
620  {5, 21},
621  {4, 22},
622  {10, 23},
623  {26, 24},
624  {17, 25},
625  {20, 26},
626  {16, 27},
627  {10, 28},
628  {19, 29},
629  {10, 30},
630  {10, 31},
631  {23, 32},
632  {22, 33},
633  {26, 34},
634  {27, 35},
635  {22, 36},
636  {27, 37},
637  {22, 38},
638  {22, 39},
639  {13, 40},
640  {14, 41},
641  {16, 27},
642  {26, 34},
643  {26, 42},
644  {27, 35},
645  {22, 36},
646  {20, 43},
647  {26, 24},
648  {22, 44},
649  {13, 45},
650  {19, 46},
651  {20, 47},
652  {16, 48},
653  {15, 49},
654  {17, 50},
655  {10, 28},
656  {20, 51},
657  {5, 52},
658  {26, 24},
659  {19, 53},
660  {15, 54},
661  {10, 55},
662  {10, 56},
663  {13, 57},
664  {13, 58},
665  {13, 59},
666  {12, 60},
667  {12, 61},
668  {18, 62},
669  {10, 63},
670  {18, 64},
671  {16, 65},
672  {20, 66},
673  {12, 67},
674  {6, 68},
675  {6, 68},
676  {15, 69},
677  {15, 70},
678  {15, 70},
679  {21, 71},
680  {30, 72},
681  {30, 73},
682  {30, 74},
683  {30, 75},
684  {23, 76},
685  {15, 77},
686  {15, 78},
687  {27, 79},
688  {27, 80},
689  {27, 81},
690  {27, 82},
691  {27, 83},
692  {27, 84},
693  {27, 79},
694  {27, 85},
695  {27, 86},
696  {10, 87},
697  {3, 88}
698 };
699 
700 // STATISTICS: example-any
int ncapacities
Number of capacities.
Definition: steel-mill.cpp:168
SteelMillBranch(Home home)
Construct brancher.
Definition: steel-mill.cpp:383
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:582
int * loss
Loss for all sizes.
Definition: steel-mill.cpp:170
Breaking symmetries with symmetry.
Definition: steel-mill.cpp:190
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
Definition: linear.cpp:45
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:228
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
Definition: arithmetic.cpp:218
const FloatNum max
Largest allowed float value.
Definition: float.hh:831
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
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
Handle for brancher.
Definition: core.hpp:1157
Less or equal ( )
Definition: int.hh:906
int ncolors
Number of colors.
Definition: steel-mill.cpp:171
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:492
int maxcapacity
Maximum capacity.
Definition: steel-mill.cpp:169
Collection of symmetries.
Definition: int.hh:4300
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
Definition: var.hpp:212
Use LDSB for symmetry breaking.
Definition: steel-mill.cpp:191
virtual bool status(const Space &home) const
Check status of brancher, return true if alternatives left.
Definition: steel-mill.cpp:392
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:741
virtual Actor * copy(Space &home, bool share)
Copy brancher.
Definition: steel-mill.cpp:459
const int order_weight
Weight-position in order-array elements.
Definition: steel-mill.cpp:572
unsigned int csplib_norders
Number of orders.
Definition: steel-mill.cpp:585
IntVarArray slabcost
Cost of slab j.
Definition: steel-mill.cpp:180
virtual Space * copy(bool share)
Copy during cloning.
Definition: steel-mill.cpp:338
Computation spaces.
Definition: core.hpp:1362
Parametric base-class for scripts.
Definition: driver.hh:633
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.
Base-class for both propagators and branchers.
Definition: core.hpp:666
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
Gecode::FloatVal c(-8, 8)
order_t orders(void) const
Return orders.
Definition: steel-mill.cpp:111
Gecode::IntArgs i(4, 1, 2, 3, 4)
Base-class for branchers.
Definition: core.hpp:1071
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:904
virtual void print(const Space &, const Gecode::Choice &_c, unsigned int a, std::ostream &o) const
Print explanation.
Definition: steel-mill.cpp:450
Options opt
The options.
Definition: test.cpp:101
Sort orders by weight.
Definition: steel-mill.cpp:119
Execution has resulted in failure.
Definition: core.hpp:525
static BrancherHandle post(Home home)
Post brancher.
Definition: steel-mill.cpp:463
int maxcapacity(void) const
Return maximum of capacities.
Definition: steel-mill.cpp:107
SteelMillBranch(Space &home, bool share, SteelMillBranch &b)
Copy constructor.
Definition: steel-mill.cpp:386
int csplib_orders[][2]
Orders.
Definition: steel-mill.cpp:586
virtual ExecStatus commit(Space &home, const Gecode::Choice &_c, unsigned int a)
Perform commit for choice _c and alternative a.
Definition: steel-mill.cpp:438
order_t orders
Orders.
Definition: steel-mill.cpp:172
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Definition: val.hpp:68
virtual void archive(Archive &e) const
Archive into e.
Definition: core.cpp:670
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
virtual Choice * choice(const Space &, Archive &e)
Return choice from e.
Definition: steel-mill.cpp:432
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:576
struct Gecode::@519::NNF::@60::@62 a
For atomic nodes.
const int order_color
Color-position in order-array elements.
Definition: steel-mill.cpp:573
virtual Gecode::Choice * choice(Space &home)
Return choice.
Definition: steel-mill.cpp:403
int norders(void) const
Return number of orders.
Definition: steel-mill.cpp:115
int(* order_t)[2]
Order-specifications.
Definition: steel-mill.cpp:52
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntConLevel)
Post domain consistent propagator for .
Definition: element.cpp:43
unsigned int nslabs
Number of slabs.
Definition: steel-mill.cpp:174
Disjunction.
Definition: int.hh:918
Passing integer variables.
Definition: int.hh:636
Passing integer arguments.
Definition: int.hh:607
Passing Boolean variables.
Definition: int.hh:690
int csplib_loss[]
Loss for all sizes.
Definition: steel-mill.cpp:583
int ncapacities(void) const
Return number of capacities.
Definition: steel-mill.cpp:105
Boolean integer variables.
Definition: int.hh:491
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:331
SteelMill(bool share, SteelMill &s)
Constructor for cloning s.
Definition: steel-mill.cpp:325
bool parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Definition: steel-mill.cpp:505
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
Integer view for integer variables.
Definition: view.hpp:129
struct Gecode::@519::NNF::@60::@61 b
For binary nodes (and, or, eqv)
virtual IntVar cost(void) const
Return solution cost.
Definition: steel-mill.cpp:342
SteelMill(const SteelMillOptions &opt)
Actual model.
Definition: steel-mill.cpp:195
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Choice for performing commit
Definition: core.hpp:1036
virtual size_t dispose(Space &)
Delete brancher and return its size.
Definition: steel-mill.cpp:467
SteelMillOptions for examples with size option and an additional optional file name parameter...
Definition: steel-mill.cpp:77
Archive representation
Definition: archive.hpp:45
ExecStatus
Definition: core.hpp:523
unsigned int size(void) const
Return size.
Definition: steel-mill.cpp:101
Integer variables.
Definition: int.hh:350
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:168
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
void solutions(unsigned int n)
Set default number of solutions to search for.
Definition: options.hpp:261
Execution is okay.
Definition: core.hpp:527
virtual void archive(Archive &e) const
Archive into e.
Definition: steel-mill.cpp:376
int * capacities(void) const
Return capacities.
Definition: steel-mill.cpp:103
int * loss(void) const
Return loss values.
Definition: steel-mill.cpp:109
Simple symmetry.
Definition: steel-mill.cpp:189
IntVarBranch INT_VAR_MAX_MIN(BranchTbl tbl)
Select variable with smallest max.
Definition: var.hpp:202
bool assigned(void) const
Test if all variables are assigned.
Definition: array.hpp:1085
BrancherHandle 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
virtual size_t size(void) const
Report size occupied.
Definition: steel-mill.cpp:372
int ncolors(void) const
Return number of colors.
Definition: steel-mill.cpp:113
Home class for posting propagators
Definition: core.hpp:717
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:985
unsigned int csplib_ncolors
Number of colors.
Definition: steel-mill.cpp:584
IntVarArray slabload
Load of slab j.
Definition: steel-mill.cpp:180
Options for scripts
Definition: driver.hh:326
unsigned int csplib_ncapacities
Number of capacities.
Definition: steel-mill.cpp:581
Example: Steel-mill slab design problem
Definition: steel-mill.cpp:162
int main(int argc, char *argv[])
Main-function.
Definition: steel-mill.cpp:477
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition: modevent.hpp:58
Multi _c(Gecode::IntArgs(3, 1, 2, 3))
Custom brancher for steel mill slab design.
Definition: steel-mill.cpp:355
virtual void help(void)
Print help text.
Definition: options.cpp:284