return


SUBMITTED BY: kamranhadiyev

DATE: Dec. 6, 2015, 1:19 a.m.

FORMAT: Text only

SIZE: 2.0 kB

HITS: 4457

  1. // Compile:
  2. // gcc -Wall -std=c++11 -o a a.cpp -lgecodedriver -lgecodegist -lgecodeint
  3. // -lgecodekernel -lgecodesearch -lgecodeset -lgecodesupport -lstdc++
  4. #include <gecode/set.hh>
  5. #include <gecode/driver.hh>
  6. using namespace Gecode;
  7. using namespace Gecode::Driver;
  8. class SceneAlloc: public Script {
  9. private:
  10. IntSetArgs x;
  11. SetVar y;
  12. SetVar z;
  13. public:
  14. SceneAlloc(const SizeOptions &opt): Script(opt) {
  15. int a[] = {0};
  16. int b[] = {0, 1};
  17. IntSet glb(a, sizeof(a)/sizeof(int));
  18. IntSet lub(b, sizeof(b)/sizeof(int));
  19. y = SetVar(*this, glb, lub, 1, 2);
  20. int c0[] = {0, 4};
  21. int c1[] = {1, 7, 8};
  22. IntSet s0(c0, sizeof(c0)/sizeof(int));
  23. IntSet s1(c1, sizeof(c1)/sizeof(int));
  24. if (opt.size() == 0) {
  25. x << s0;
  26. x << s1;
  27. } else {
  28. x << s1;
  29. x << s0;
  30. }
  31. std::cout << "x: " << x << std::endl;
  32. z = SetVar(*this, IntSet::empty, IntSet(0, 10));
  33. element(*this, SOT_UNION, x, y, z);
  34. branch(*this, y, SET_VAL_MIN_INC());
  35. }
  36. SceneAlloc(bool share, SceneAlloc &s): Script(share, s) {
  37. y.update(*this, share, s.y);
  38. z.update(*this, share, s.z);
  39. }
  40. virtual Space * copy(bool share) {
  41. return new SceneAlloc(share, *this);
  42. }
  43. virtual void print(std::ostream &os) const {
  44. os << "y: " << y << std::endl;
  45. os << "z: " << z << std::endl;
  46. }
  47. };
  48. int main(int argc, char **argv) {
  49. SizeOptions opt("element union");
  50. opt.parse(argc, argv);
  51. Script::run<SceneAlloc, DFS, SizeOptions>(opt);
  52. return 0;

comments powered by Disqus