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