Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
13 kB · 383 lines
C++
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- *//* * Main authors: * Christian Schulte <schulte@gecode.org> * Guido Tack <tack@gecode.org> * Vincent Barichard <Vincent.Barichard@univ-angers.fr> * * Contributing authors: * Gabor Szokoli <szokoli@gecode.org> * * Copyright: * Christian Schulte, 2002 * Guido Tack, 2004 * Gabor Szokoli, 2003 * Vincent Barichard, 2012 * * 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_FLOAT_REL_HH#define GECODE_FLOAT_REL_HH
#include <gecode/int.hh>#include <gecode/float.hh>
/** * \namespace Gecode::Float::Rel * \brief Simple relation propagators */namespace Gecode { namespace Float { namespace Rel {
/* * Equality propagators * */
/** * \brief Binary bounds consistent equality propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */ template<class View0, class View1> class Eq : public MixBinaryPropagator<View0,PC_FLOAT_BND,View1,PC_FLOAT_BND> { protected: using MixBinaryPropagator<View0,PC_FLOAT_BND,View1,PC_FLOAT_BND>::x0; using MixBinaryPropagator<View0,PC_FLOAT_BND,View1,PC_FLOAT_BND>::x1;
/// Constructor for cloning \a p Eq(Space& home, Eq<View0,View1>& p); public: /// Constructor for posting Eq(Home home, View0 x0, View1 x1); /// Constructor for rewriting \a p during cloning Eq(Space& home, Propagator& p, View0 x0, View1 x1); /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post bounds consistent propagator \f$ x_0 = x_1\f$ static ExecStatus post(Home home, View0 x0, View1 x1); };
/** * \brief n-ary bounds consistent equality propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */ template<class View> class NaryEq : public NaryPropagator<View,PC_FLOAT_BND> { protected: using NaryPropagator<View,PC_FLOAT_BND>::x;
/// Constructor for cloning \a p NaryEq(Space& home, NaryEq<View>& p); /// Constructor for posting NaryEq(Home home, ViewArray<View>&); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /** * \brief Cost function * * If a view has been assigned, the cost is low unary. * Otherwise it is low linear. */ virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post bounds consistent propagator \f$ x_0 = x_1=\ldots =x_{|x|-1}\f$ static ExecStatus post(Home home, ViewArray<View>& x); };
/** * \brief Reified binary bounds consistent equality propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */ template<class View, class CtrlView, ReifyMode rm> class ReEq : public Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView> { protected: using Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>::x0; using Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>::x1; using Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>::b;
/// Constructor for cloning \a p ReEq(Space& home, ReEq& p); /// Constructor for posting ReEq(Home home, View x0, View x1, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post bounds consistent propagator \f$ (x_0 = x_1)\Leftrightarrow b\f$ static ExecStatus post(Home home, View x0, View x1, CtrlView b); };
/** * \brief Reified bounds consistent equality with float propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */ template<class View, class CtrlView, ReifyMode rm> class ReEqFloat : public Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView> { protected: using Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>::x0; using Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>::b;
/// Float constant to check FloatVal c; /// Constructor for cloning \a p ReEqFloat(Space& home, ReEqFloat& p); /// Constructor for posting ReEqFloat(Home home, View x, FloatVal c, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post bounds consistent propagator \f$ (x = c)\Leftrightarrow b\f$ static ExecStatus post(Home home, View x, FloatVal c, CtrlView b); };
/** * \brief Binary bounds consistent disequality propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */ template<class View0, class View1> class Nq : public MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL> { protected: using MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>::x0; using MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>::x1;
/// Constructor for cloning \a p Nq(Space& home, Nq<View0,View1>& p); public: /// Constructor for posting Nq(Home home, View0 x0, View1 x1); /// Constructor for rewriting \a p during cloning Nq(Space& home, Propagator& p, View0 x0, View1 x1); /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post bounds consistent propagator \f$ x_0 \neq x_1\f$ static ExecStatus post(Home home, View0 x0, View1 x1); };
/** * \brief Binary bounds consistent disequality propagator with float value * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */ template<class View> class NqFloat : public UnaryPropagator<View,PC_FLOAT_VAL> { protected: using UnaryPropagator<View,PC_FLOAT_VAL>::x0;
/// Float constant to check FloatVal c; /// Constructor for cloning \a p NqFloat(Space& home, NqFloat<View>& p); public: /// Constructor for posting NqFloat(Home home, View x, FloatVal c); /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post bounds consistent propagator \f$ x_0 \neq c\f$ static ExecStatus post(Home home, View x0, FloatVal c); };
/* * Order propagators * */
/** * \brief Less or equal propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */
template<class View> class Lq : public BinaryPropagator<View,PC_FLOAT_BND> { protected: using BinaryPropagator<View,PC_FLOAT_BND>::x0; using BinaryPropagator<View,PC_FLOAT_BND>::x1;
/// Constructor for cloning \a p Lq(Space& home, Lq& p); /// Constructor for posting Lq(Home home, View x0, View 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_0 \leq x_1\f$ static ExecStatus post(Home home, View x0, View x1); };
/** * \brief Less propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */
template<class View> class Le : public BinaryPropagator<View,PC_FLOAT_BND> { protected: using BinaryPropagator<View,PC_FLOAT_BND>::x0; using BinaryPropagator<View,PC_FLOAT_BND>::x1;
/// Constructor for cloning \a p Le(Space& home, Le& p); /// Constructor for posting Le(Home home, View x0, View 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_0 \le x_1\f$ static ExecStatus post(Home home, View x0, View x1); };
/* * Reified order propagators * */
/** * \brief Reified less or equal with float propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */
template<class View, class CtrlView, ReifyMode rm> class ReLqFloat : public Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView> { protected: using Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>::x0; using Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>::b;
/// Float constant to check FloatVal c; /// Constructor for cloning \a p ReLqFloat(Space& home, ReLqFloat& p); /// Constructor for posting ReLqFloat(Home home, View x, FloatVal c, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ (x \leq c)\Leftrightarrow b\f$ static ExecStatus post(Home home, View x, FloatVal c, CtrlView b); };
/** * \brief Reified less with float propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */
template<class View, class CtrlView, ReifyMode rm> class ReLeFloat : public Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView> { protected: using Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>::x0; using Int::ReUnaryPropagator<View,PC_FLOAT_BND,CtrlView>::b;
/// Float constant to check FloatVal c; /// Constructor for cloning \a p ReLeFloat(Space& home, ReLeFloat& p); /// Constructor for posting ReLeFloat(Home home, View x, FloatVal c, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ (x < c)\Leftrightarrow b\f$ static ExecStatus post(Home home, View x, FloatVal c, CtrlView b); };
/** * \brief Reified less or equal propagator * * Requires \code #include <gecode/float/rel.hh> \endcode * \ingroup FuncFloatProp */
template<class View, class CtrlView, ReifyMode rm> class ReLq : public Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView> { protected: using Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>::x0; using Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>::x1; using Int::ReBinaryPropagator<View,PC_FLOAT_BND,CtrlView>::b;
/// Constructor for cloning \a p ReLq(Space& home, ReLq& p); /// Constructor for posting ReLq(Home home, View x0, View x1, CtrlView b); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ (x_0 \leq x_1)\Leftrightarrow b\f$ static ExecStatus post(Home home, View x0, View x1, CtrlView b); };
}}}
#include <gecode/float/rel/eq.hpp>#include <gecode/float/rel/nq.hpp>#include <gecode/float/rel/lq-le.hpp>
#endif
// STATISTICS: float-prop