/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2011 * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include namespace Gecode { namespace Int { namespace NoOverlap { bool optional(const BoolVarArgs& m) { for (int i=0; i(x[i].max()) + w[i], "Int::nooverlap"); Limits::check(static_cast(y[i].max()) + h[i], "Int::nooverlap"); } GECODE_POST; ManBox* b = static_cast(home).alloc >(x.size()); for (int i=0; i >::post(home,b,x.size()))); } void nooverlap(Home home, const IntVarArgs& x, const IntArgs& w, const IntVarArgs& y, const IntArgs& h, const BoolVarArgs& m, IntPropLevel) { using namespace Int; using namespace NoOverlap; if ((x.size() != w.size()) || (x.size() != y.size()) || (x.size() != h.size()) || (x.size() != m.size())) throw ArgumentSizeMismatch("Int::nooverlap"); for (int i=0; i(x[i].max()) + w[i], "Int::nooverlap"); Limits::check(static_cast(y[i].max()) + h[i], "Int::nooverlap"); } GECODE_POST; if (optional(m)) { OptBox* b = static_cast(home).alloc >(x.size()); for (int i=0; i >::post(home,b,x.size()))); } else { ManBox* b = static_cast(home).alloc >(x.size()); int n = 0; for (int i=0; i >::post(home,b,n))); } } void nooverlap(Home home, const IntVarArgs& x0, const IntVarArgs& w, const IntVarArgs& x1, const IntVarArgs& y0, const IntVarArgs& h, const IntVarArgs& y1, IntPropLevel) { using namespace Int; using namespace NoOverlap; if ((x0.size() != w.size()) || (x0.size() != x1.size()) || (x0.size() != y0.size()) || (x0.size() != h.size()) || (x0.size() != y1.size())) throw ArgumentSizeMismatch("Int::nooverlap"); GECODE_POST; for (int i=0; i* b = static_cast(home).alloc >(x0.size()); for (int i=0; i >::post(home,b,x0.size()))); } } void nooverlap(Home home, const IntVarArgs& x0, const IntVarArgs& w, const IntVarArgs& x1, const IntVarArgs& y0, const IntVarArgs& h, const IntVarArgs& y1, const BoolVarArgs& m, IntPropLevel) { using namespace Int; using namespace NoOverlap; if ((x0.size() != w.size()) || (x0.size() != x1.size()) || (x0.size() != y0.size()) || (x0.size() != h.size()) || (x0.size() != y1.size()) || (x0.size() != m.size())) throw ArgumentSizeMismatch("Int::nooverlap"); GECODE_POST; for (int i=0; i* b = static_cast(home).alloc >(x0.size()); for (int i=0; i >::post(home,b,x0.size()))); } else { ManBox* b = static_cast(home).alloc >(x0.size()); int n = 0; for (int i=0; i >::post(home,b,n))); } } } // STATISTICS: int-post