LinExpr operator -(const IntVar& x, int c) { if (x.assigned() && Int::Limits::valid(x.val()-static_cast<double>(c))) return LinExpr(x.val()-static_cast<double>(c)); else return LinExpr(x,LinExpr::NT_ADD,-c); }
virtual void print(std::ostream& os) const { char output[s.val()+1][s.val()+1]; memset(output, 0, sizeof(output)); for (int i = 0; i < N-1; ++i) { for (int j = 0; j < size(i); ++j) { for (int k = 0; k < size(i); ++k) { output[x[i].val()+j][y[i].val()+k] = size(i); } } } bool one = false; for (int i = 0; i < s.val(); ++i) { for (int j = 0; j < s.val(); ++j) { if (output[i][j] == 0) { if (!one) { one = true; printf(" 1"); } else { printf(" "); } } else { printf("%2d", output[i][j]); } } printf("\n"); } }
LinExpr operator -(int c, const IntVar& x) { if (x.assigned() && Int::Limits::valid(static_cast<double>(c)-x.val())) return LinExpr(static_cast<double>(c)-x.val()); else return LinExpr(x,LinExpr::NT_SUB,c); }
LinExpr operator -(const IntVar& x, const IntVar& y) { if (x.assigned()) return x.val() - y; else if (y.assigned()) return x - y.val(); else return LinExpr(x,LinExpr::NT_SUB,y); }
LinExpr operator +(const IntVar& x, const IntVar& y) { if (x.assigned()) return x.val() + y; else if (y.assigned()) return x + y.val(); else return LinExpr(x,LinExpr::NT_ADD,y); }
LinExpr operator *(const IntVar& x, int a) { if (a == 0) return LinExpr(0.0); else if (x.assigned() && Int::Limits::valid(static_cast<double>(a)*x.val())) return LinExpr(static_cast<double>(a)*x.val()); else return LinExpr(x,a); }
void BElementExpr::post(Space& home, BoolVar b, bool pos, IntConLevel icl) { IntVar z = idx.post(home, icl); if (z.assigned() && z.val() >= 0 && z.val() < n) { BoolExpr be = pos ? (a[z.val()] == b) : (a[z.val()] == !b); be.rel(home,icl); } else { BoolVarArgs x(n); for (int i=n; i--;) x[i] = a[i].expr(home,icl); BoolVar res = pos ? b : (!b).expr(home,icl); element(home, x, z, res, icl); } }
LinExpr operator -(const IntVar& x) { if (x.assigned()) return LinExpr(-x.val()); else return LinExpr(x,LinExpr::NT_SUB,0); }
LinExpr operator -(const LinExpr& e, const IntVar& x) { if (x.assigned()) return e - x.val(); else return LinExpr(e,LinExpr::NT_SUB,x); }
LinExpr operator -(const IntVar& x, const LinExpr& e) { if (x.assigned()) return x.val() - e; else return LinExpr(x,LinExpr::NT_SUB,e); }
LinExpr operator +(const LinExpr& e, const IntVar& x) { if (x.assigned()) return e + x.val(); else return LinExpr(e,LinExpr::NT_ADD,x); }
LinExpr operator +(const IntVar& x, const LinExpr& e) { if (x.assigned()) return x.val() + e; else return LinExpr(x,LinExpr::NT_ADD,e); }
void cumulative(Home home, IntVar c, const IntVarArgs& s, const IntArgs& p, const IntArgs& u, const BoolVarArgs& m, IntConLevel icl) { if (c.assigned()) cumulative(home,c.val(),s,p,u,m,icl); else cumulative(home,Int::IntView(c),s,p,u,m,icl); }
void cumulative(Home home, IntVar c, const TaskTypeArgs& t, const IntVarArgs& s, const IntArgs& p, const IntArgs& u, IntConLevel icl) { if (c.assigned()) cumulative(home,c.val(),t,s,p,u,icl); else cumulative(home,Int::IntView(c),t,s,p,u,icl); }
int VersionProblem::GetPackageVersion(int packageId) { IntVar *var = GetPackageVersionVar(packageId); if (1 == var->size()) return var->val(); return UNRESOLVED_VARIABLE; }