/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Guido Tack * Christian Schulte * * Contributing authors: * Gabor Szokoli * * Copyright: * Guido Tack, 2004 * Christian Schulte, 2004 * Gabor Szokoli, 2004 * * 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. * */ #ifndef GECODE_SET_REL_HH #define GECODE_SET_REL_HH #include namespace Gecode { namespace Set { namespace Rel { /** * \namespace Gecode::Set::Rel * \brief Standard set relation propagators */ /// Test whether two views are in fact the same template bool same(VX c, VY y); /** * \brief %Propagator for the subset constraint * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class Subset : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p Subset(Space& home, Subset& p); /// Constructor for posting Subset(Home home, View0 x0, View1 x1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x\subseteq y\f$ static ExecStatus post(Home home, View0 x, View1 y); }; /** * \brief %Propagator for the negated subset constraint * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class NoSubset : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p NoSubset(Space& home, NoSubset& p); /// Constructor for posting NoSubset(Home home, View0 x0, View1 x1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x\subseteq y\f$ static ExecStatus post(Home home,View0 x,View1 y); }; /** * \brief %Reified subset propagator * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class ReSubset : public Propagator { protected: /// Variable view View0 x0; /// Variable view View1 x1; /// Boolean control view CtrlView b; /// Constructor for cloning \a p ReSubset(Space& home, ReSubset& p); /// Constructor for posting ReSubset(Home home, View0 x0, View1 x1, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Cost function (defined as ternary low) virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Schedule function virtual void reschedule(Space& home); /// Delete propagator and return its size virtual size_t dispose(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ (x\subseteq y) \Leftrightarrow b \f$ static ExecStatus post(Home home, View0 x, View1 y, CtrlView b); }; /** * \brief %Propagator for set equality * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class Eq : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p Eq(Space& home, Eq& p); /// Constructor for posting Eq(Home home, View0 x0, View1 x1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x=y \f$ static ExecStatus post(Home home, View0 x, View1 y); }; /** * \brief %Reified equality propagator * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class ReEq : public Propagator { protected: View0 x0; View1 x1; CtrlView b; /// Constructor for cloning \a p ReEq(Space& home, ReEq&); /// Constructor for posting ReEq(Home home, View0 x0, View1 x1, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Cost function (defined as PC_TERNARY_LO) virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Schedule function virtual void reschedule(Space& home); /// Delete propagator and return its size virtual size_t dispose(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ (x=y) \Leftrightarrow b\f$ static ExecStatus post(Home home, View0 x, View1 y, CtrlView b); }; /** * \brief %Propagator for set less than or equal * * Propagates strict inequality if \a strict is true. * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class Lq : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p Lq(Space& home, Lq& p); /// Constructor for posting Lq(Home home, View0 x0, View1 x1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x\leq y \f$ static ExecStatus post(Home home, View0 x, View1 y); }; /** * \brief %Reified propagator for set less than or equal * * Propagates strict inequality if \a strict is true. * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class ReLq : public Propagator { protected: View0 x0; View1 x1; Gecode::Int::BoolView b; /// Constructor for cloning \a p ReLq(Space& home, ReLq& p); /// Constructor for posting ReLq(Home home, View0 x0, View1 x1, Gecode::Int::BoolView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Cost function (defined as PC_TERNARY_LO) virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Schedule function virtual void reschedule(Space& home); /// Delete propagator and return its size virtual size_t dispose(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ (x\leq y) \Leftrightarrow b\f$ static ExecStatus post(Home home, View0 x, View1 y, Gecode::Int::BoolView b); }; /** * \brief %Propagator for negated equality * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class Distinct : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p Distinct(Space& home, Distinct& p); /// Constructor for posting Distinct(Home home, View0 x0, View1 x1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x\neq y \f$ static ExecStatus post(Home home, View0 x, View1 y); }; /** * \brief %Propagator for negated equality * * This propagator actually propagates the distinctness, after the * Distinct propagator waited for one variable to become * assigned. * * Requires \code #include \endcode * \ingroup FuncSetProp */ template class DistinctDoit : public UnaryPropagator { protected: using UnaryPropagator::x0; /// The view that is already assigned ConstSetView y; /// Constructor for cloning \a p DistinctDoit(Space& home, DistinctDoit&); /// Constructor for posting DistinctDoit(Home home, View0 x0, ConstSetView y); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x\neq y \f$ static ExecStatus post(Home home, View0 x, ConstSetView y); }; }}} #include #include #include #include #include #include #include #include #include #endif // STATISTICS: set-prop