/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte * Guido Tack * Vincent Barichard * * Copyright: * Christian Schulte, 2002 * Guido Tack, 2004 * 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_ARITHMETIC_HH #define GECODE_FLOAT_ARITHMETIC_HH #include #include #include /** * \namespace Gecode::Float::Arithmetic * \brief %Arithmetic propagators */ namespace Gecode { namespace Float { namespace Arithmetic { /** * \brief Bounds consistent positive square propagator * * This propagator provides multiplication for positive views only. */ template class SqrPlus : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for posting SqrPlus(Home home, VA x0, VB x1); /// Constructor for cloning \a p SqrPlus(Space& home, SqrPlus& p); public: /// Post propagator \f$x_0\cdot x_0=x_1\f$ static ExecStatus post(Home home, VA x0, VB x1); /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); }; /** * \brief %Propagator for bounds consistent square operator * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Sqr : public BinaryPropagator { protected: using BinaryPropagator::x0; using BinaryPropagator::x1; /// Constructor for cloning \a p Sqr(Space& home, Sqr& p); /// Constructor for creation Sqr(Home home, View x0, View x1); public: /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$x_0^2 = x_1\f$ static ExecStatus post(Home home, View x0, View x1); }; /** * \brief %Propagator for bounds consistent square root operator * * The types \a A and \a B give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Sqrt : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p Sqrt(Space& home, Sqrt& p); /// Constructor for creation Sqrt(Home home, A x0, B x1); public: /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$x_0^2 = x_1\f$ static ExecStatus post(Home home, A x0, B x1); }; /** * \brief %Propagator for bounds consistent absolute operator * * The types \a A and \a B give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Abs : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; /// Constructor for cloning \a p Abs(Space& home, Abs& p); /// Constructor for creation Abs(Home home, A x0, B x1); public: /// Constructor for rewriting \a p during cloning Abs(Space& home, Propagator& p, A x0, B x1); /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ |x_0| = x_1\f$ static ExecStatus post(Home home, A x0, B x1); }; /** * \brief %Propagator for bounds consistent pow operator * * The types \a A and \a B give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Pow : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; int m_n; /// Constructor for cloning \a p Pow(Space& home, Pow& p); /// Constructor for creation Pow(Home home, A x0, B x1, int n); public: /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$x_0^n = x_1\f$ static ExecStatus post(Home home, A x0, B x1, int n); }; /** * \brief %Propagator for bounds consistent nth root operator * * The types \a A and \a B give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class NthRoot : public MixBinaryPropagator { protected: using MixBinaryPropagator::x0; using MixBinaryPropagator::x1; int m_n; /// Constructor for cloning \a p NthRoot(Space& home, NthRoot& p); /// Constructor for creation NthRoot(Home home, A x0, B x1, int n); public: /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$x_0^(1/n) = x_1\f$ static ExecStatus post(Home home, A x0, B x1, int n); }; /** * \brief Bounds or domain consistent propagator for \f$x_0\times x_1=x_0\f$ * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class MultZeroOne : public BinaryPropagator { protected: using BinaryPropagator::x0; using BinaryPropagator::x1; /// Constructor for cloning \a p MultZeroOne(Space& home, MultZeroOne& p); /// Constructor for posting MultZeroOne(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\cdot x_1=x_0\f$ static ExecStatus post(Home home, View x0, View x1); }; /** * \brief Bounds consistent positive multiplication propagator * * This propagator provides multiplication for positive views only. */ template class MultPlus : public MixTernaryPropagator { protected: using MixTernaryPropagator::x0; using MixTernaryPropagator::x1; using MixTernaryPropagator::x2; public: /// Constructor for posting MultPlus(Home home, VA x0, VB x1, VC x2); /// Constructor for cloning \a p MultPlus(Space& home, MultPlus& p); /// Post propagator \f$x_0\cdot x_1=x_2\f$ static ExecStatus post(Home home, VA x0, VB x1, VC x2); /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); }; /** * \brief Bounds consistent multiplication propagator * * Requires \code #include \endcode * * \ingroup FuncFloatProp */ template class Mult : public TernaryPropagator { protected: using TernaryPropagator::x0; using TernaryPropagator::x1; using TernaryPropagator::x2; /// Constructor for cloning \a p Mult(Space& home, Mult& p); public: /// Constructor for posting Mult(Home home, View x0, View x1, View x2); /// Post propagator \f$x_0\cdot x_1=x_2\f$ static ExecStatus post(Home home, View x0, View x1, View x2); /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); }; /** * \brief %Propagator for bounds division operator * * The types \a A, \a B and \a C give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Div : public MixTernaryPropagator { protected: using MixTernaryPropagator::x0; using MixTernaryPropagator::x1; using MixTernaryPropagator::x2; /// Constructor for cloning \a p Div(Space& home, Div& p); /// Constructor for creation Div(Home home, A x0, B x1, C x2); public: /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ x_0 / x_1 = x_2\f$ static ExecStatus post(Home home, A x0, B x1, C x2); }; /** * \brief %Propagator for bounds consistent min operator * * The types \a A, \a B and \a C give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Min : public MixTernaryPropagator { protected: using MixTernaryPropagator::x0; using MixTernaryPropagator::x1; using MixTernaryPropagator::x2; /// Constructor for cloning \a p Min(Space& home, Min& p); /// Constructor for creation Min(Home home, A x0, B x1, C x2); public: /// Constructor for rewriting \a p during cloning Min(Space& home, Propagator& p, A x0, B x1, C x2); /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ min(x_0, x_1) = x_2\f$ static ExecStatus post(Home home, A x0, B x1, C x2); }; /** * \brief %Propagator for bounds consistent max operator * * The types \a A, \a B and \a C give the types of the views. * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class Max : public MixTernaryPropagator { protected: using MixTernaryPropagator::x0; using MixTernaryPropagator::x1; using MixTernaryPropagator::x2; /// Constructor for cloning \a p Max(Space& home, Max& p); /// Constructor for creation Max(Home home, A x0, B x1, C x2); public: /// Constructor for rewriting \a p during cloning Max(Space& home, Propagator& p, A x0, B x1, C x2); /// Create copy during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator for \f$ max(x_0, x_1) = x_2\f$ static ExecStatus post(Home home, A x0, B x1, C x2); }; /** * \brief Bounds consistent n-ary maximum propagator * * Requires \code #include \endcode * \ingroup FuncFloatProp */ template class NaryMax : public NaryOnePropagator { protected: using NaryOnePropagator::x; using NaryOnePropagator::y; /// Constructor for cloning \a p NaryMax(Space& home, NaryMax& p); /// Constructor for posting NaryMax(Home home, ViewArray& x, View y); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ \max x=y\f$ static ExecStatus post(Home home, ViewArray& x, View y); }; }}} #include #include #include #include #include #include #endif // STATISTICS: float-prop