Generated on Sat Feb 7 2015 02:01:13 for Gecode by doxygen 1.8.9.1
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: 2013-07-08 14:22:40 +0200 (Mon, 08 Jul 2013) $ by $Author: schulte $
11  * $Revision: 13820 $
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  capacities(opt.capacities()), ncapacities(opt.ncapacities()),
198  maxcapacity(opt.maxcapacity()), loss(opt.loss()),
199  ncolors(opt.ncolors()), orders(opt.orders()),
200  norders(opt.size()), nslabs(opt.size()),
201  // Initialize problem variables
202  slab(*this, norders, 0,nslabs-1),
203  slabload(*this, nslabs, 0,45),
204  slabcost(*this, nslabs, 0, Int::Limits::max),
205  total_cost(*this, 0, Int::Limits::max)
206  {
207  // Boolean variables for slab[o]==s
208  BoolVarArgs boolslab(norders*nslabs);
209  for (unsigned int i = 0; i < norders; ++i) {
210  BoolVarArgs tmp(nslabs);
211  for (int j = nslabs; j--; ) {
212  boolslab[j + i*nslabs] = tmp[j] = BoolVar(*this, 0, 1);
213  }
214  channel(*this, tmp, slab[i]);
215  }
216 
217  // Packing constraints
218  for (unsigned int s = 0; s < nslabs; ++s) {
219  IntArgs c(norders);
220  BoolVarArgs x(norders);
221  for (int i = norders; i--; ) {
222  c[i] = orders[i][order_weight];
223  x[i] = boolslab[s + i*nslabs];
224  }
225  linear(*this, c, x, IRT_EQ, slabload[s]);
226  }
227  // Redundant packing constraint
228  int totalweight = 0;
229  for (unsigned int i = norders; i-- ; )
230  totalweight += orders[i][order_weight] ;
231  linear(*this, slabload, IRT_EQ, totalweight);
232 
233 
234  // Color constraints
235  IntArgs nofcolor(ncolors);
236  for (int c = ncolors; c--; ) {
237  nofcolor[c] = 0;
238  for (int o = norders; o--; ) {
239  if (orders[o][order_color] == c) nofcolor[c] += 1;
240  }
241  }
242  BoolVar f(*this, 0, 0);
243  for (unsigned int s = 0; s < nslabs; ++s) {
244  BoolVarArgs hascolor(ncolors);
245  for (int c = ncolors; c--; ) {
246  if (nofcolor[c]) {
247  BoolVarArgs hasc(nofcolor[c]);
248  int pos = 0;
249  for (int o = norders; o--; ) {
250  if (orders[o][order_color] == c)
251  hasc[pos++] = boolslab[s + o*nslabs];
252  }
253  assert(pos == nofcolor[c]);
254  hascolor[c] = BoolVar(*this, 0, 1);
255  rel(*this, BOT_OR, hasc, hascolor[c]);
256  } else {
257  hascolor[c] = f;
258  }
259  }
260  linear(*this, hascolor, IRT_LQ, 2);
261  }
262 
263  // Compute slabcost
264  IntArgs l(maxcapacity, loss);
265  for (int s = nslabs; s--; ) {
266  element(*this, l, slabload[s], slabcost[s]);
267  }
268  linear(*this, slabcost, IRT_EQ, total_cost);
269 
270  // Add branching
271  if (opt.symmetry() == SYMMETRY_BRANCHING) {
272  // Symmetry breaking branching
273  SteelMillBranch::post(*this);
274  } else if (opt.symmetry() == SYMMETRY_NONE) {
275  branch(*this, slab, INT_VAR_MAX_MIN(), INT_VAL_MIN());
276  } else { // opt.symmetry() == SYMMETRY_LDSB
277  // There is one symmetry: the values (slabs) are interchangeable.
278  Symmetries syms;
279  syms << ValueSymmetry(IntArgs::create(nslabs,0));
280 
281  // For variable order we mimic the custom brancher. We use
282  // min-size domain, breaking ties by maximum weight (preferring
283  // to label larger weights earlier). To do this, we first sort
284  // (stably) by maximum weight, then use min-size domain.
285  SortByWeight sbw(orders);
286  IntArgs indices(norders);
287  for (unsigned int i = 0 ; i < norders ; i++)
288  indices[i] = i;
289  Support::quicksort(&indices[0],norders,sbw);
290  IntVarArgs sorted_orders(norders);
291  for (unsigned int i = 0 ; i < norders ; i++) {
292  sorted_orders[i] = slab[indices[i]];
293  }
294  branch(*this, sorted_orders, INT_VAR_SIZE_MIN(), INT_VAL_MIN(), syms);
295  }
296  }
297 
299  virtual void
300  print(std::ostream& os) const {
301  os << "What slab=" << slab << std::endl;
302  os << "Slab load=" << slabload << std::endl;
303  os << "Slab cost=" << slabcost << std::endl;
304  os << "Total cost=" << total_cost << std::endl;
305  int nslabsused = 0;
306  int nslabscost = 0;
307  bool unassigned = false;
308  for (int i = nslabs; i--; ) {
309  if (!slabload[i].assigned() || !slabcost[i].assigned()) {
310  unassigned = true;
311  break;
312  }
313  if (slabload[i].min()>0) ++nslabsused;
314  if (slabcost[i].min()>0) ++nslabscost;
315  }
316  if (!unassigned)
317  os << "Number of slabs used=" << nslabsused
318  << ", slabs with cost=" << nslabscost
319  << std::endl;
320  os << std::endl;
321  }
322 
324  SteelMill(bool share, SteelMill& s)
325  : IntMinimizeScript(share,s),
326  capacities(s.capacities), ncapacities(s.ncapacities),
327  maxcapacity(s.maxcapacity), loss(s.loss),
328  ncolors(s.ncolors), orders(s.orders),
329  norders(s.norders), nslabs(s.nslabs) {
330  slab.update(*this, share, s.slab);
331  slabload.update(*this, share, s.slabload);
332  slabcost.update(*this, share, s.slabcost);
333  total_cost.update(*this, share, s.total_cost);
334  }
336  virtual Space*
337  copy(bool share) {
338  return new SteelMill(share,*this);
339  }
341  virtual IntVar cost(void) const {
342  return total_cost;
343  }
344 
345 
355  protected:
357  mutable int start;
359  class Choice : public Gecode::Choice {
360  public:
362  int pos;
364  int val;
368  Choice(const Brancher& b, unsigned int a, int pos0, int val0)
369  : Gecode::Choice(b,a), pos(pos0), val(val0) {}
371  virtual size_t size(void) const {
372  return sizeof(Choice);
373  }
375  virtual void archive(Archive& e) const {
377  e << alternatives() << pos << val;
378  }
379  };
380 
383  : Brancher(home), start(0) {}
385  SteelMillBranch(Space& home, bool share, SteelMillBranch& b)
386  : Brancher(home, share, b), start(b.start) {
387  }
388 
389  public:
391  virtual bool status(const Space& home) const {
392  const SteelMill& sm = static_cast<const SteelMill&>(home);
393  for (unsigned int i = start; i < sm.norders; ++i)
394  if (!sm.slab[i].assigned()) {
395  start = i;
396  return true;
397  }
398  // No non-assigned orders left
399  return false;
400  }
402  virtual Gecode::Choice* choice(Space& home) {
403  SteelMill& sm = static_cast<SteelMill&>(home);
404  assert(!sm.slab[start].assigned());
405  // Find order with a) minimum size, b) largest weight
406  unsigned int size = sm.norders;
407  int weight = 0;
408  unsigned int pos = start;
409  for (unsigned int i = start; i<sm.norders; ++i) {
410  if (!sm.slab[i].assigned()) {
411  if (sm.slab[i].size() == size &&
412  sm.orders[i][order_weight] > weight) {
413  weight = sm.orders[i][order_weight];
414  pos = i;
415  } else if (sm.slab[i].size() < size) {
416  size = sm.slab[i].size();
417  weight = sm.orders[i][order_weight];
418  pos = i;
419  }
420  }
421  }
422  unsigned int val = sm.slab[pos].min();
423  // Find first still empty slab (all such slabs are symmetric)
424  unsigned int firstzero = 0;
425  while (firstzero < sm.nslabs && sm.slabload[firstzero].min() > 0)
426  ++firstzero;
427  assert(pos < sm.nslabs &&
428  val < sm.norders);
429  return new Choice(*this, (val<firstzero) ? 2 : 1, pos, val);
430  }
431  virtual Choice* choice(const Space&, Archive& e) {
432  unsigned int alt; int pos, val;
433  e >> alt >> pos >> val;
434  return new Choice(*this, alt, pos, val);
435  }
437  virtual ExecStatus commit(Space& home, const Gecode::Choice& _c,
438  unsigned int a) {
439  SteelMill& sm = static_cast<SteelMill&>(home);
440  const Choice& c = static_cast<const Choice&>(_c);
441  if (a)
442  return me_failed(Int::IntView(sm.slab[c.pos]).nq(home, c.val))
443  ? ES_FAILED : ES_OK;
444  else
445  return me_failed(Int::IntView(sm.slab[c.pos]).eq(home, c.val))
446  ? ES_FAILED : ES_OK;
447  }
449  virtual void print(const Space&, const Gecode::Choice& _c,
450  unsigned int a,
451  std::ostream& o) const {
452  const Choice& c = static_cast<const Choice&>(_c);
453  o << "slab[" << c.pos << "] "
454  << ((a == 0) ? "=" : "!=")
455  << " " << c.val;
456  }
458  virtual Actor* copy(Space& home, bool share) {
459  return new (home) SteelMillBranch(home, share, *this);
460  }
462  static BrancherHandle post(Home home) {
463  return *new (home) SteelMillBranch(home);
464  }
466  virtual size_t dispose(Space&) {
467  return sizeof(*this);
468  }
469  };
470 };
471 
475 int
476 main(int argc, char* argv[]) {
477  SteelMillOptions opt("Steel Mill Slab design");
480  opt.symmetry(SteelMill::SYMMETRY_BRANCHING,"branching");
482  opt.solutions(0);
483  if (!opt.parse(argc,argv))
484  return 1;
485  Script::run<SteelMill,BAB,SteelMillOptions>(opt);
486  return 0;
487 }
488 
489 
490 void
492  Options::help();
493  std::cerr << "\t(string), optional" << std::endl
494  << "\t\tBenchmark to load." << std::endl
495  << "\t\tIf none is given, the standard CSPLib instance is used."
496  << std::endl;
497  std::cerr << "\t(unsigned int), optional" << std::endl
498  << "\t\tNumber of orders to use, in the interval [0..norders]."
499  << std::endl
500  << "\t\tIf none is given, all orders are used." << std::endl;
501 }
502 
503 bool
504 SteelMillOptions::parse(int& argc, char* argv[]) {
505  Options::parse(argc,argv);
506  // Check number of arguments
507  if (argc >= 4) {
508  std::cerr << "Too many arguments given, max two allowed (given={";
509  for (int i = 1; i < argc; ++i) {
510  std::cerr << "\"" << argv[i] << "\"";
511  if (i < argc-1) std::cerr << ",";
512  }
513  std::cerr << "})." << std::endl;
514  return false;
515  }
516  // Parse options
517  while (argc >= 2) {
518  bool issize = true;
519  for (int i = strlen(argv[argc-1]); i-- && issize; )
520  issize &= (isdigit(argv[argc-1][i]) != 0);
521  if (issize) {
522  _size = atoi(argv[argc-1]);
523  } else {
524  std::ifstream instance(argv[argc-1]);
525  if (instance.fail()) {
526  std::cerr << "Argument \"" << argv[argc-1]
527  << "\" is neither an integer nor a readable file"
528  << std::endl;
529  return false;
530  }
531  // Read file instance
532  instance >> _ncapacities;
533  _capacities = new int[_ncapacities];
534  _maxcapacity = -1;
535  for (int i = 0; i < _ncapacities; ++i) {
536  instance >> _capacities[i];
537  _maxcapacity = std::max(_maxcapacity, _capacities[i]);
538  }
539  instance >> _ncolors >> _norders;
540  _orders = new int[_norders][2];
541  for (unsigned int i = 0; i < _norders; ++i) {
542  instance >> _orders[i][order_weight] >> _orders[i][order_color];
543  }
544  }
545 
546  --argc;
547  }
548  // Compute loss
549  {
550  _loss = new int[_maxcapacity+1];
551  _loss[0] = 0;
552  int currcap = 0;
553  for (int c = 1; c < _maxcapacity; ++c) {
554  if (c > _capacities[currcap]) ++currcap;
555  _loss[c] = _capacities[currcap] - c;
556  }
557  }
558  // Set size, if none given
559  if (_size == 0) {
560  _size = _norders;
561  }
562  // Check size reasonability
563  if (_size == 0 || _size > _norders) {
564  std::cerr << "Size must be between 1 and " << _norders << std::endl;
565  return false;
566  }
567  return true;
568 }
569 
570 // Positions in order array
571 const int order_weight = 0;
572 const int order_color = 1;
573 
574 // CSPLib instance
576  {12, 14, 17, 18, 19,
577  20, 23, 24, 25, 26,
578  27, 28, 29, 30, 32,
579  35, 39, 42, 43, 44};
580 unsigned int csplib_ncapacities = 20;
581 unsigned int csplib_maxcapacity = 44;
582 int csplib_loss[45];
583 unsigned int csplib_ncolors = 89;
584 unsigned int csplib_norders = 111;
585 int csplib_orders[][2] = {
586  {4, 1},
587  {22, 2},
588  {9, 3},
589  {5, 4},
590  {8, 5},
591  {3, 6},
592  {3, 4},
593  {4, 7},
594  {7, 4},
595  {7, 8},
596  {3, 6},
597  {2, 6},
598  {2, 4},
599  {8, 9},
600  {5, 10},
601  {7, 11},
602  {4, 7},
603  {7, 11},
604  {5, 10},
605  {7, 11},
606  {8, 9},
607  {3, 1},
608  {25, 12},
609  {14, 13},
610  {3, 6},
611  {22, 14},
612  {19, 15},
613  {19, 15},
614  {22, 16},
615  {22, 17},
616  {22, 18},
617  {20, 19},
618  {22, 20},
619  {5, 21},
620  {4, 22},
621  {10, 23},
622  {26, 24},
623  {17, 25},
624  {20, 26},
625  {16, 27},
626  {10, 28},
627  {19, 29},
628  {10, 30},
629  {10, 31},
630  {23, 32},
631  {22, 33},
632  {26, 34},
633  {27, 35},
634  {22, 36},
635  {27, 37},
636  {22, 38},
637  {22, 39},
638  {13, 40},
639  {14, 41},
640  {16, 27},
641  {26, 34},
642  {26, 42},
643  {27, 35},
644  {22, 36},
645  {20, 43},
646  {26, 24},
647  {22, 44},
648  {13, 45},
649  {19, 46},
650  {20, 47},
651  {16, 48},
652  {15, 49},
653  {17, 50},
654  {10, 28},
655  {20, 51},
656  {5, 52},
657  {26, 24},
658  {19, 53},
659  {15, 54},
660  {10, 55},
661  {10, 56},
662  {13, 57},
663  {13, 58},
664  {13, 59},
665  {12, 60},
666  {12, 61},
667  {18, 62},
668  {10, 63},
669  {18, 64},
670  {16, 65},
671  {20, 66},
672  {12, 67},
673  {6, 68},
674  {6, 68},
675  {15, 69},
676  {15, 70},
677  {15, 70},
678  {21, 71},
679  {30, 72},
680  {30, 73},
681  {30, 74},
682  {30, 75},
683  {23, 76},
684  {15, 77},
685  {15, 78},
686  {27, 79},
687  {27, 80},
688  {27, 81},
689  {27, 82},
690  {27, 83},
691  {27, 84},
692  {27, 79},
693  {27, 85},
694  {27, 86},
695  {10, 87},
696  {3, 88}
697 };
698 
699 // STATISTICS: example-any
int ncapacities
Number of capacities.
Definition: steel-mill.cpp:168
SteelMillBranch(Home home)
Construct brancher.
Definition: steel-mill.cpp:382
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:364
order_t orders
The orders.
Definition: steel-mill.cpp:122
unsigned int csplib_maxcapacity
Maximum capacity.
Definition: steel-mill.cpp:581
int * loss
Loss for all sizes.
Definition: steel-mill.cpp:170
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
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Definition: var.hpp:128
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:491
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
virtual bool status(const Space &home) const
Check status of brancher, return true if alternatives left.
Definition: steel-mill.cpp:391
SortByWeight(order_t _orders)
Initialize orders.
Definition: steel-mill.cpp:124
int start
Cache of first unassigned value.
Definition: steel-mill.cpp:357
Integer variable array.
Definition: int.hh:741
virtual Actor * copy(Space &home, bool share)
Copy brancher.
Definition: steel-mill.cpp:458
const int order_weight
Weight-position in order-array elements.
Definition: steel-mill.cpp:571
unsigned int csplib_norders
Number of orders.
Definition: steel-mill.cpp:584
IntVarArray slabcost
Cost of slab j.
Definition: steel-mill.cpp:180
virtual Space * copy(bool share)
Copy during cloning.
Definition: steel-mill.cpp:337
Computation spaces.
Definition: core.hpp:1362
Parametric base-class for scripts.
Definition: driver.hh:622
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:300
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
Definition: array.hpp:1072
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:449
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:462
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:385
int csplib_orders[][2]
Orders.
Definition: steel-mill.cpp:585
virtual ExecStatus commit(Space &home, const Gecode::Choice &_c, unsigned int a)
Perform commit for choice _c and alternative a.
Definition: steel-mill.cpp:437
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:431
int pos
Position of variable.
Definition: steel-mill.cpp:362
int csplib_capacities[]
Constants for CSPLib instance of the Steel Mill Slab Design Problem.
Definition: steel-mill.cpp:575
const int order_color
Color-position in order-array elements.
Definition: steel-mill.cpp:572
virtual Gecode::Choice * choice(Space &home)
Return choice.
Definition: steel-mill.cpp:402
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:582
int ncapacities(void) const
Return number of capacities.
Definition: steel-mill.cpp:105
Use LDSB for symmetry breaking.
Definition: steel-mill.cpp:191
Boolean integer variables.
Definition: int.hh:491
Choice(const Brancher &b, unsigned int a, int pos0, int val0)
Definition: steel-mill.cpp:368
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:324
bool parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
Definition: steel-mill.cpp:504
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
virtual IntVar cost(void) const
Return solution cost.
Definition: steel-mill.cpp:341
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:466
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:243
Execution is okay.
Definition: core.hpp:527
virtual void archive(Archive &e) const
Archive into e.
Definition: steel-mill.cpp:375
int * capacities(void) const
Return capacities.
Definition: steel-mill.cpp:103
int * loss(void) const
Return loss values.
Definition: steel-mill.cpp:109
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
IntVarBranch INT_VAR_MAX_MIN(BranchTbl tbl)
Select variable with smallest max.
Definition: var.hpp:202
Breaking symmetries with symmetry.
Definition: steel-mill.cpp:190
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:371
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:583
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:580
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
Example: Steel-mill slab design problem
Definition: steel-mill.cpp:162
int main(int argc, char *argv[])
Main-function.
Definition: steel-mill.cpp:476
bool me_failed(ModEvent me)
Check whether modification event me is failed.
Definition: modevent.hpp:58
Simple symmetry.
Definition: steel-mill.cpp:189
Multi _c(Gecode::IntArgs(3, 1, 2, 3))
Custom brancher for steel mill slab design.
Definition: steel-mill.cpp:354
virtual void help(void)
Print help text.
Definition: options.cpp:284