void distinct(Home home, const IntArgs& c, const IntVarArgs& x, IntPropLevel ipl) { using namespace Int; if (x.same(home)) throw ArgumentSame("Int::distinct"); if (c.size() != x.size()) throw ArgumentSizeMismatch("Int::distinct"); GECODE_POST; ViewArray<OffsetView> cx(home,x.size()); for (int i = c.size(); i--; ) { long long int cx_min = (static_cast<long long int>(c[i]) + static_cast<long long int>(x[i].min())); long long int cx_max = (static_cast<long long int>(c[i]) + static_cast<long long int>(x[i].max())); Limits::check(c[i],"Int::distinct"); Limits::check(cx_min,"Int::distinct"); Limits::check(cx_max,"Int::distinct"); cx[i] = OffsetView(x[i],c[i]); } switch (vbd(ipl)) { case IPL_BND: GECODE_ES_FAIL(Distinct::Bnd<OffsetView>::post(home,cx)); break; case IPL_DOM: GECODE_ES_FAIL(Distinct::Dom<OffsetView>::post(home,cx)); break; default: GECODE_ES_FAIL(Distinct::Val<OffsetView>::post(home,cx)); } }
void rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y) { if (home.failed()) return; Set::Limits::check(z, "Set::rel"); ViewArray<SingletonView> xa(home,x.size()); for (int i=x.size(); i--;) { Int::IntView iv(x[i]); SingletonView sv(iv); xa[i] = sv; } switch (op) { case SOT_UNION: GECODE_ES_FAIL((RelOp::UnionN<SingletonView,SetView> ::post(home, xa, z, y))); break; case SOT_DUNION: GECODE_ES_FAIL((RelOp::PartitionN<SingletonView,SetView> ::post(home, xa, z, y))); break; case SOT_INTER: GECODE_ES_FAIL( (RelOp::IntersectionN<SingletonView,SetView> ::post(home, xa, z, y))); break; case SOT_MINUS: throw IllegalOperation("set::rel"); break; default: throw UnknownOperation("Set::rel"); } }
void argmin(Home home, const IntVarArgs& x, IntVar y, bool tiebreak, IntConLevel) { using namespace Int; if (x.size() == 0) throw TooFewArguments("Int::argmin"); if (x.same(home,y)) throw ArgumentSame("Int::argmin"); if (home.failed()) return; // Constrain y properly IntView yv(y); GECODE_ME_FAIL(yv.gq(home,0)); GECODE_ME_FAIL(yv.le(home,x.size())); // Construct index view array IdxViewArray<MinusView> ix(home,x.size()); for (int i=x.size(); i--; ) { ix[i].idx=i; ix[i].view=MinusView(x[i]); } if (tiebreak) GECODE_ES_FAIL((Arithmetic::ArgMax<MinusView,IntView,true> ::post(home,ix,yv))); else GECODE_ES_FAIL((Arithmetic::ArgMax<MinusView,IntView,false> ::post(home,ix,yv))); }
void extensional(Home home, const IntVarArgs& x, const TupleSet& t, IntPropLevel ipl) { using namespace Int; if (!t.finalized()) throw NotYetFinalized("Int::extensional"); if (t.arity() != x.size()) throw ArgumentSizeMismatch("Int::extensional"); GECODE_POST; if (t.tuples()==0) { if (x.size()!=0) { home.fail(); } return; } // Construct view array ViewArray<IntView> xv(home,x); if (ipl & IPL_MEMORY) { if (x.same(home)) { GECODE_ES_FAIL((Extensional::Basic<IntView,true> ::post(home,xv,t))); } else { GECODE_ES_FAIL((Extensional::Basic<IntView,false> ::post(home,xv,t))); } } else { GECODE_ES_FAIL((Extensional::Incremental<IntView> ::post(home,xv,t))); } }
void binpacking(Home home, const IntVarArgs& l, const IntVarArgs& b, const IntArgs& s, IntConLevel) { using namespace Int; if (l.same(home,b)) throw ArgumentSame("Int::binpacking"); if (b.size() != s.size()) throw ArgumentSizeMismatch("Int::binpacking"); for (int i=s.size(); i--; ) Limits::positive(s[i],"Int::binpacking"); if (home.failed()) return; ViewArray<OffsetView> lv(home,l.size()); for (int i=l.size(); i--; ) lv[i] = OffsetView(l[i],0); ViewArray<BinPacking::Item> bs(home,b.size()); for (int i=bs.size(); i--; ) bs[i] = BinPacking::Item(b[i],s[i]); Support::quicksort(&bs[0], bs.size()); GECODE_ES_FAIL(Int::BinPacking::Pack::post(home,lv,bs)); }
void unary(Home home, const IntVarArgs& s, const IntArgs& p, const BoolVarArgs& m, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Unary; if (s.same(home)) throw Int::ArgumentSame("Int::unary"); if ((s.size() != p.size()) || (s.size() != m.size())) throw Int::ArgumentSizeMismatch("Int::unary"); for (int i=p.size(); i--; ) { Int::Limits::nonnegative(p[i],"Int::unary"); Int::Limits::check(static_cast<double>(s[i].max()) + p[i], "Int::unary"); } bool allMandatory = true; for (int i=m.size(); i--;) { if (!m[i].one()) { allMandatory = false; break; } } if (allMandatory) { unary(home,s,p,icl); } else { if (home.failed()) return; TaskArray<OptFixPTask> t(home,s.size()); for (int i=s.size(); i--; ) t[i].init(s[i],p[i],m[i]); GECODE_ES_FAIL(OptProp<OptFixPTask>::post(home,t)); } }
void linear(Home home, const IntVarArgs& x, IntRelType r, IntVar y, IntConLevel icl) { if (home.failed()) return; Region re(home); Linear::Term<IntView>* t = re.alloc<Linear::Term<IntView> >(x.size()+1); for (int i = x.size(); i--; ) { t[i].a=1; t[i].x=x[i]; } int min, max; estimate(t,x.size(),0,min,max); IntView v(y); switch (r) { case IRT_EQ: GECODE_ME_FAIL(v.gq(home,min)); GECODE_ME_FAIL(v.lq(home,max)); break; case IRT_GQ: GECODE_ME_FAIL(v.lq(home,max)); break; case IRT_LQ: GECODE_ME_FAIL(v.gq(home,min)); break; default: ; } if (home.failed()) return; t[x.size()].a=-1; t[x.size()].x=y; Linear::post(home,t,x.size()+1,r,0,icl); }
void unary(Home home, const TaskTypeArgs& t, const IntVarArgs& flex, const IntArgs& fix, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Unary; if ((flex.size() != fix.size()) || (flex.size() != t.size())) throw Int::ArgumentSizeMismatch("Int::unary"); for (int i=fix.size(); i--; ) { if (t[i] == TT_FIXP) Int::Limits::nonnegative(fix[i],"Int::unary"); else Int::Limits::check(fix[i],"Int::unary"); Int::Limits::check(static_cast<double>(flex[i].max()) + fix[i], "Int::unary"); } if (home.failed()) return; bool fixp = true; for (int i=t.size(); i--;) if (t[i] != TT_FIXP) { fixp = false; break; } if (fixp) { unary(home, flex, fix, icl); } else { TaskArray<ManFixPSETask> tasks(home,flex.size()); for (int i=flex.size(); i--;) tasks[i].init(t[i],flex[i],fix[i]); GECODE_ES_FAIL(ManProp<ManFixPSETask>::post(home,tasks)); } }
// domain is 0..|cards|- 1 void count(Home home, const IntVarArgs& x, const IntVarArgs& c, IntConLevel icl) { IntArgs values(c.size()); for (int i = c.size(); i--; ) values[i] = i; count(home, x, c, values, icl); }
void cumulative(Home home, Cap c, const TaskTypeArgs& t, const IntVarArgs& s, const IntArgs& p, const IntArgs& u, const BoolVarArgs& m, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Cumulative; if ((s.size() != p.size()) || (s.size() != u.size()) || (s.size() != t.size()) || (s.size() != m.size())) throw Int::ArgumentSizeMismatch("Int::cumulative"); long long int w = 0; for (int i=p.size(); i--; ) { Limits::nonnegative(p[i],"Int::cumulative"); Limits::nonnegative(u[i],"Int::cumulative"); Limits::check(static_cast<long long int>(s[i].max()) + p[i], "Int::cumulative"); mul_check(p[i],u[i]); w += s[i].width(); } mul_check(c.max(),w,s.size()); if (home.failed()) return; bool allMandatory = true; for (int i=m.size(); i--;) { if (!m[i].one()) { allMandatory = false; break; } } if (allMandatory) { cumulative(home,c,t,s,p,u,icl); } else { bool fixp = true; for (int i=t.size(); i--;) if (t[i] != TT_FIXP) { fixp = false; break; } int nonOptionals = 0; for (unsigned int i=u.size(); i--;) if (u[i]>0) nonOptionals++; if (fixp) { TaskArray<OptFixPTask> tasks(home,nonOptionals); int cur = 0; for (int i=0; i<s.size(); i++) if (u[i]>0) tasks[cur++].init(s[i],p[i],u[i],m[i]); GECODE_ES_FAIL((OptProp<OptFixPTask,Cap>::post(home,c,tasks))); } else { TaskArray<OptFixPSETask> tasks(home,nonOptionals); int cur = 0; for (int i=s.size(); i--;) if (u[i]>0) tasks[cur++].init(t[i],s[i],p[i],u[i],m[i]); GECODE_ES_FAIL((OptProp<OptFixPSETask,Cap>::post(home,c,tasks))); } } }
void distinct(Home home, const BoolVarArgs& b, const IntVarArgs& x, IntPropLevel ipl) { using namespace Int; if (x.same(home)) throw ArgumentSame("Int::distinct"); if (b.size() != x.size()) throw ArgumentSizeMismatch("Int::distinct"); GECODE_POST; int n = x.size(); int min = Limits::max; int max = Limits::min; int m = 0; for (int i=n; i--; ) if (!b[i].zero()) { min = std::min(min,x[i].min()); max = std::max(max,x[i].max()); m++; } if (m < 2) return; int start; if (max < Limits::max-m) start = max+1; else if (min > Limits::min+m) start = min-(m+1); else throw OutOfLimits("Int::distinct"); ViewArray<IntView> y(home,m); int j = 0; for (int i=n; i--; ) if (b[i].one()) { y[j] = x[i]; j++; } else if (b[i].none()) { y[j] = IntVar(home, Limits::min, Limits::max); GECODE_ES_FAIL((Bool::IteDom<IntView,ConstIntView,IntView>::post (home, b[i], x[i], start+j, y[j]))); j++; } assert(j == m); switch (vbd(ipl)) { case IPL_BND: GECODE_ES_FAIL(Distinct::Bnd<IntView>::post(home,y)); break; case IPL_DOM: GECODE_ES_FAIL(Distinct::Dom<IntView>::post(home,y)); break; default: GECODE_ES_FAIL(Distinct::Val<IntView>::post(home,y)); } }
void unary(Home home, const IntVarArgs& s, const IntVarArgs& p, const IntVarArgs& e, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Unary; if ((s.size() != p.size()) || (s.size() != e.size())) throw Int::ArgumentSizeMismatch("Int::unary"); if (home.failed()) return; for (int i=p.size(); i--; ) { rel(home, p[i], IRT_GQ, 0); } bool fixP = true; for (int i=p.size(); i--;) { if (!p[i].assigned()) { fixP = false; break; } } if (fixP) { IntArgs pp(p.size()); for (int i=p.size(); i--;) pp[i] = p[i].val(); unary(home,s,pp,icl); } else { TaskArray<ManFlexTask> t(home,s.size()); for (int i=s.size(); i--; ) t[i].init(s[i],p[i],e[i]); GECODE_ES_FAIL(ManProp<ManFlexTask>::post(home,t)); } }
void rel(Home home, const IntVarArgs& x, IntRelType irt, const IntVarArgs& y, IntConLevel icl) { if (home.failed()) return; switch (irt) { case IRT_GR: { ViewArray<IntView> xv(home,x), yv(home,y); GECODE_ES_FAIL(Rel::LexLqLe<IntView>::post(home,yv,xv,true)); } break; case IRT_LE: { ViewArray<IntView> xv(home,x), yv(home,y); GECODE_ES_FAIL(Rel::LexLqLe<IntView>::post(home,xv,yv,true)); } break; case IRT_GQ: { ViewArray<IntView> xv(home,x), yv(home,y); GECODE_ES_FAIL(Rel::LexLqLe<IntView>::post(home,yv,xv,false)); } break; case IRT_LQ: { ViewArray<IntView> xv(home,x), yv(home,y); GECODE_ES_FAIL(Rel::LexLqLe<IntView>::post(home,xv,yv,false)); } break; case IRT_EQ: if (x.size() != y.size()) { home.fail(); } else if ((icl == ICL_DOM) || (icl == ICL_DEF)) for (int i=x.size(); i--; ) { GECODE_ES_FAIL((Rel::EqDom<IntView,IntView> ::post(home,x[i],y[i]))); } else for (int i=x.size(); i--; ) { GECODE_ES_FAIL((Rel::EqBnd<IntView,IntView> ::post(home,x[i],y[i]))); } break; case IRT_NQ: { ViewArray<IntView> xv(home,x), yv(home,y); GECODE_ES_FAIL(Rel::LexNq<IntView>::post(home,xv,yv)); } break; default: throw UnknownRelation("Int::rel"); } }
void channel(Home home, const IntVarArgs& x, const SetVarArgs& y) { if (home.failed()) return; ViewArray<Int::CachedView<Int::IntView> > xa(home,x.size()); for (int i=x.size(); i--;) new (&xa[i]) Int::CachedView<Int::IntView>(x[i]); ViewArray<Set::CachedView<Set::SetView> > ya(home,y.size()); for (int i=y.size(); i--;) new (&ya[i]) Set::CachedView<Set::SetView>(y[i]); GECODE_ES_FAIL((Set::Int::ChannelInt<Set::SetView>::post(home,xa,ya))); }
void linear(Home home, const IntVarArgs& x, IntRelType r, int c, BoolVar b, IntConLevel) { if (home.failed()) return; Region re(home); Linear::Term<IntView>* t = re.alloc<Linear::Term<IntView> >(x.size()); for (int i = x.size(); i--; ) { t[i].a=1; t[i].x=x[i]; } Linear::post(home,t,x.size(),r,c,b); }
void linear(Home home, const IntArgs& a, const IntVarArgs& x, IntRelType r, int c, BoolVar b, IntConLevel) { if (a.size() != x.size()) throw ArgumentSizeMismatch("Int::linear"); if (home.failed()) return; Region re(home); Linear::Term<IntView>* t = re.alloc<Linear::Term<IntView> >(x.size()); for (int i = x.size(); i--; ) { t[i].a=a[i]; t[i].x=x[i]; } Linear::post(home,t,x.size(),r,c,b); }
void dom(Home home, const IntVarArgs& x, const IntVarArgs& d, IntConLevel) { using namespace Int; if (x.size() != d.size()) throw ArgumentSizeMismatch("Int::dom"); for (int i=x.size(); i--; ) { if (home.failed()) return; IntView xv(x[i]), dv(d[i]); if (!same(xv,dv)) { ViewRanges<IntView> r(dv); GECODE_ME_FAIL(xv.inter_r(home,r,false)); } } }
LinExpr::LinExpr(const IntVarArgs& x) : n(new Node) { n->n_int = x.size(); n->n_bool = 0; n->t = NT_SUM_INT; n->l = n->r = NULL; if (x.size() > 0) { n->sum.ti = heap.alloc<Int::Linear::Term<Int::IntView> >(x.size()); for (int i=x.size(); i--; ) { n->sum.ti[i].x = x[i]; n->sum.ti[i].a = 1; } } }
void extensional(Home home, const IntVarArgs& x, const TupleSet& t, ExtensionalPropKind epk, IntConLevel) { using namespace Int; if (!t.finalized()) throw NotYetFinalized("Int::extensional"); if (t.arity() != x.size()) throw ArgumentSizeMismatch("Int::extensional"); if (home.failed()) return; // Construct view array ViewArray<IntView> xv(home,x); switch (epk) { case EPK_SPEED: GECODE_ES_FAIL((Extensional::Incremental<IntView> ::post(home,xv,t))); break; default: if (x.same(home)) { GECODE_ES_FAIL((Extensional::Basic<IntView,true> ::post(home,xv,t))); } else { GECODE_ES_FAIL((Extensional::Basic<IntView,false> ::post(home,xv,t))); } break; } }
void min(Home home, const IntVarArgs& x, IntVar y, IntConLevel icl) { if (x.size() == 0) throw TooFewArguments("Int::min"); if (home.failed()) return; ViewArray<MinusView> m(home,x.size()); for (int i=x.size(); i--; ) m[i] = MinusView(x[i]); MinusView my(y); if (icl == ICL_DOM) { GECODE_ES_FAIL(Arithmetic::NaryMaxDom<MinusView>::post(home,m,my)); } else { GECODE_ES_FAIL(Arithmetic::NaryMaxBnd<MinusView>::post(home,m,my)); } }
void nonlinearity(Home home, const int n, const int m, const int threshold, const IntVarArgs& x) { if(DEBUG) { std::cerr << "P"; } // argument validation if(x.size() != pow(2,n)) { throw ArgumentSizeMismatch("setnonlinearity,x"); } else if(threshold > pow(2,n)) { throw ArgumentSizeMismatch("setnonlinearity,threshold,high"); } else if(!(n > 0)) { throw ArgumentSizeMismatch("setnonlinearity,n"); } else if(!(m > 0)) { throw ArgumentSizeMismatch("setnonlinearity,m"); } else if(!(threshold >= 0)) { throw ArgumentSizeMismatch("setnonlinearity,threshold,low"); } // if space is already failed, don't post the propagator if(home.failed()) { return; } // create views ViewArray<IntView> vx(home,x); // size of the a,b array, for convenience int size = numscores(n,m); // create storage for scoring int* scores = static_cast<Space&>(home).alloc<int>(size); // create storage for allocated list bool* assigned = static_cast<Space&>(home).alloc<bool>((int)pow(2,n)); // not strictly sure this is ncessary, but... for(int i=0; i<pow(2,n); i++) { assigned[i] = false; } // if posting failed, fail the space if(NonLinearity::post(home,vx,scores,assigned,n,m,threshold,size) != ES_OK) { home.fail(); } }
LinExpr::LinExpr(const IntArgs& a, const IntVarArgs& x) : n(new Node) { if (a.size() != x.size()) throw Int::ArgumentSizeMismatch("MiniModel::LinExpr"); n->n_int = x.size(); n->n_bool = 0; n->t = NT_SUM_INT; n->l = n->r = NULL; if (x.size() > 0) { n->sum.ti = heap.alloc<Int::Linear::Term<Int::IntView> >(x.size()); for (int i=x.size(); i--; ) { n->sum.ti[i].x = x[i]; n->sum.ti[i].a = a[i]; } } }
void cumulative(Home home, Cap c, const IntVarArgs& s, const IntVarArgs& p, const IntVarArgs& e, const IntArgs& u, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Cumulative; if ((s.size() != p.size()) || (s.size() != e.size()) || (s.size() != u.size())) throw Int::ArgumentSizeMismatch("Int::cumulative"); long long int w = 0; for (int i=p.size(); i--; ) { rel(home, p[i], IRT_GQ, 0); } for (int i=p.size(); i--; ) { Limits::nonnegative(u[i],"Int::cumulative"); Limits::check(static_cast<long long int>(s[i].max()) + p[i].max(), "Int::cumulative"); mul_check(p[i].max(),u[i]); w += s[i].width(); } mul_check(c.max(),w,s.size()); if (home.failed()) return; bool fixP = true; for (int i=p.size(); i--;) { if (!p[i].assigned()) { fixP = false; break; } } if (fixP) { IntArgs pp(p.size()); for (int i=p.size(); i--;) pp[i] = p[i].val(); cumulative(home,c,s,pp,u,icl); } else { int nonOptionals = 0; for (unsigned int i=u.size(); i--;) if (u[i]>0) nonOptionals++; TaskArray<ManFlexTask> t(home,nonOptionals); int cur = 0; for (int i=0; i<s.size(); i++) if (u[i]>0) t[cur++].init(s[i],p[i],e[i],u[i]); GECODE_ES_FAIL((ManProp<ManFlexTask,Cap>::post(home,c,t))); } }
void cumulative(Home home, Cap c, const IntVarArgs& s, const IntArgs& p, const IntArgs& u, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Cumulative; if ((s.size() != p.size()) || (s.size() != u.size())) throw Int::ArgumentSizeMismatch("Int::cumulative"); long long int w = 0; for (int i=p.size(); i--; ) { Limits::nonnegative(p[i],"Int::cumulative"); Limits::nonnegative(u[i],"Int::cumulative"); Limits::check(static_cast<long long int>(s[i].max()) + p[i], "Int::cumulative"); mul_check(p[i],u[i]); w += s[i].width(); } mul_check(c.max(),w,s.size()); if (home.failed()) return; int minU = INT_MAX; int minU2 = INT_MAX; int maxU = INT_MIN; for (int i=u.size(); i--;) { if (u[i] < minU) { minU2 = minU; minU = u[i]; } else if (u[i] < minU2) minU2 = u[i]; if (u[i] > maxU) maxU = u[i]; } bool disjunctive = (minU > c.max()/2) || (minU2 > c.max()/2 && minU+minU2>c.max()); if (disjunctive) { GECODE_ME_FAIL(c.gq(home,maxU)); unary(home,s,p,icl); } else { int nonOptionals = 0; for (unsigned int i=u.size(); i--;) if (u[i]>0) nonOptionals++; TaskArray<ManFixPTask> t(home,nonOptionals); int cur = 0; for (int i=0; i<s.size(); i++) if (u[i]>0) t[cur++].init(s[i],p[i],u[i]); GECODE_ES_FAIL((ManProp<ManFixPTask,Cap>::post(home,c,t))); } }
void circuit(Home home, const IntArgs& c, const IntVarArgs& x, IntVar z, IntConLevel icl) { if (home.failed()) return; IntVarArgs y(home, x.size(), Int::Limits::min, Int::Limits::max); circuit(home, c, x, y, z, icl); }
void circuit(Home home, const IntArgs& c, const IntVarArgs& x, const IntVarArgs& y, IntVar z, IntConLevel icl) { int n = x.size(); if ((y.size() != n) || (c.size() != n*n)) throw Int::ArgumentSizeMismatch("Graph::circuit"); circuit(home, x, icl); if (home.failed()) return; IntArgs cx(n); for (int i=n; i--; ) { for (int j=0; j<n; j++) cx[j] = c[i*n+j]; element(home, cx, x[i], y[i]); } linear(home, y, IRT_EQ, z); }
void unary(Home home, const IntVarArgs& s, const IntVarArgs& p, const IntVarArgs& e, const BoolVarArgs& m, IntConLevel icl) { using namespace Gecode::Int; using namespace Gecode::Int::Unary; if ((s.size() != p.size()) || (s.size() != m.size()) || (s.size() != e.size())) throw Int::ArgumentSizeMismatch("Int::unary"); if (home.failed()) return; for (int i=p.size(); i--; ) { rel(home, p[i], IRT_GQ, 0); } bool allMandatory = true; for (int i=m.size(); i--;) { if (!m[i].one()) { allMandatory = false; break; } } if (allMandatory) { unary(home,s,p,e,icl); } else { TaskArray<OptFlexTask> t(home,s.size()); for (int i=s.size(); i--; ) t[i].init(s[i],p[i],e[i],m[i]); GECODE_ES_FAIL(OptProp<OptFlexTask>::post(home,t)); } }
void nooverlap(Home home, const IntVarArgs& x, const IntArgs& w, const IntVarArgs& y, const IntArgs& h, IntConLevel) { using namespace Int; using namespace NoOverlap; if (x.same(home) || y.same(home)) throw ArgumentSame("Int::nooverlap"); if ((x.size() != w.size()) || (x.size() != y.size()) || (x.size() != h.size())) throw ArgumentSizeMismatch("Int::nooverlap"); for (int i=x.size(); i--; ) { Limits::nonnegative(w[i],"Int::nooverlap"); Limits::nonnegative(h[i],"Int::nooverlap"); Limits::check(static_cast<double>(x[i].max()) + w[i], "Int::nooverlap"); Limits::check(static_cast<double>(y[i].max()) + h[i], "Int::nooverlap"); } if (home.failed()) return; ManBox<FixDim,2>* b = static_cast<Space&>(home).alloc<ManBox<FixDim,2> >(x.size()); for (int i=x.size(); i--; ) { b[i][0] = FixDim(x[i],w[i]); b[i][1] = FixDim(y[i],h[i]); } GECODE_ES_FAIL((NoOverlap::ManProp<FixDim,2>::post(home,b,x.size()))); }
void dom(Home home, const IntVarArgs& x, int n, IntConLevel) { Limits::check(n,"Int::dom"); if (home.failed()) return; for (int i=x.size(); i--; ) { IntView xv(x[i]); GECODE_ME_FAIL(xv.eq(home,n)); } }
void sorted(Home home, const IntVarArgs& x, const IntVarArgs& y, IntConLevel) { using namespace Int; if (x.size() != y.size()) throw ArgumentSizeMismatch("Int::Sorted"); if (x.same(home,y)) throw ArgumentSame("Int::Sorted"); if (home.failed()) return; if (x.size()==0) return; ViewArray<IntView> x0(home,x), y0(home,y), z0(home,0); GECODE_ES_FAIL( (Sorted::Sorted<IntView,false>::post(home,x0,y0,z0))); }