#include <gecode/int.hh>
#include <gecode/minimodel.hh>
#include <gecode/scheduling.hh>
#include <gecode/gist.hh>

using namespace Gecode;

/*
 * Roberto Castañeda Lozano -- rcas@sics.se 
 * From "Global Constraints in Scheduling"
 * Figure 2.4., pg. 26.
 */
class UnaryExample : public Space {
  
protected:
  
  static const int n = 4;
  static const int m = 26;

  IntVarArray s;

public:

  UnaryExample() : s(*this,n,0,m) {

    IntVar C(s[0]),
      F(s[1]),
      E(s[2]),
      D(s[3]);

    rel(*this, C >= 4 && C <= 26);
    rel(*this, F >= 5 && F <= 10);
    rel(*this, E >= 5 && E <= 10);
    rel(*this, D >= 13 && D <= 13);

    IntArgs p(n,4,3,3,5);
    
    unary(*this, s, p);

    branch(*this, s, INT_VAR_MIN_MIN, INT_VAL_MIN);

  }

  UnaryExample(bool share, UnaryExample& cs) : Space(share,cs) {
    s.update(*this, share, cs.s);
  }
  
  virtual Space* copy(bool share) {
    return new UnaryExample(share,*this);
  }
  
  virtual void print(std::ostream& os) const {
    os << s << std::endl;
  }
  
};

int main(int argc, char* argv[]) {
  
  UnaryExample* m = new UnaryExample;
  Gist::Print<UnaryExample> p("Print solution");
  Gist::Options o;
  o.inspect.click(&p);
  Gist::dfs(m,o);
  delete m;
  return 0;

}



