Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
11 kB · 296 lines
C++
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- *//* * Main authors: * Guido Tack <tack@gecode.org> * Christian Schulte <schulte@gecode.org> * * Contributing authors: * Gabor Szokoli <szokoli@gecode.org> * * 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_RELOP_HH#define GECODE_SET_RELOP_HH
#include <gecode/set.hh>#include <gecode/set/rel.hh>
namespace Gecode { namespace Set { namespace RelOp {
/** * \namespace Gecode::Set::RelOp * \brief Standard set operation propagators */
/** * \brief %Propagator for the superset of intersection * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */
template<class View0, class View1, class View2> class SuperOfInter : public MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_CLUB> { protected: using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_CLUB>::x0; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_CLUB>::x1; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_CLUB>::x2; /// Constructor for cloning \a p SuperOfInter(Space& home, SuperOfInter& p); /// Constructor for posting SuperOfInter(Home home, View0, View1, View2); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ z \supseteq x \cap y\f$ static ExecStatus post(Home home, View0 x, View1 y, View2 z); };
/** * \brief %Propagator for the subset of union * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */ template<class View0, class View1, class View2> class SubOfUnion : public MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY> { protected: using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x0; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x1; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x2; /// Constructor for cloning \a p SubOfUnion(Space& home, SubOfUnion& p); /// Constructor for posting SubOfUnion(Home home, View0, View1, View2); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ z \subseteq x \cap y\f$ static ExecStatus post(Home home,View0 x,View1 y,View2 z); };
/** * \brief %Propagator for ternary intersection * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */ template<class View0, class View1, class View2> class Intersection: public MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY> { protected: using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x0; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x1; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x2; /// Constructor for cloning \a p Intersection(Space& home, Intersection& p); /// Constructor for posting Intersection(Home home,View0,View1,View2); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ z=x\cap y\f$ static ExecStatus post(Home home,View0 x,View1 y,View2 z); };
/** * \brief %Propagator for ternary union * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */ template<class View0, class View1, class View2> class Union: public MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY> { protected: using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x0; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x1; using MixTernaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY, View2,PC_SET_ANY>::x2; /// Constructor for cloning \a p Union(Space& home, Union& p); /// Constructor for posting Union(Home home, View0, View1, View2); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ z=x\cup y\f$ static ExecStatus post(Home home,View0 x,View1 y,View2 z); };
/** * \brief %Propagator for nary intersection * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */ template<class View0, class View1> class IntersectionN : public MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY> { protected: using MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>::x; using MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>::y; /// Whether the any views share a variable implementation bool shared; /// Intersection of the determined \f$x_i\f$ (which are dropped) LUBndSet intOfDets; /// Constructor for cloning \a p IntersectionN(Space& home, IntersectionN& p); /// Constructor for posting IntersectionN(Home home, ViewArray<View0>&, View1); /// Constructor for posting IntersectionN(Home home, ViewArray<View0>&, const IntSet&, View1); public: /// Cost function virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Post propagator \f$ x = \bigcap_{i\in\{0,\dots,n-1\}} y_i \f$ static ExecStatus post(Home home,ViewArray<View0>& y,View1 x); /// Post propagator \f$ x = z\cap\bigcap_{i\in\{0,\dots,n-1\}} y_i \f$ static ExecStatus post(Home home,ViewArray<View0>& y, const IntSet& z,View1 x); };
/** * \brief %Propagator for nary union * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */ template<class View0, class View1> class UnionN : public MixNaryOnePropagator<View0,PC_SET_ANY, View1,PC_SET_ANY> { protected: using MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>::x; using MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>::y; /// Whether the any views share a variable implementation bool shared; /// Union of the determined \f$x_i\f$ (which are dropped) GLBndSet unionOfDets; /// Constructor for cloning \a p UnionN(Space& home, UnionN& p); /// Constructor for posting UnionN(Home home,ViewArray<View0>&,View1); /// Constructor for posting UnionN(Home home,ViewArray<View0>&,const IntSet&,View1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Cost function virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Post propagator \f$ x = \bigcup_{i\in\{0,\dots,n-1\}} y_i \f$ static ExecStatus post(Home home,ViewArray<View0>& y,View1 x); /// Post propagator \f$ x = z\cup\bigcup_{i\in\{0,\dots,n-1\}} y_i \f$ static ExecStatus post(Home home,ViewArray<View0>& y, const IntSet& z,View1 x); };
/** * \brief %Propagator for nary partition * * Requires \code #include <gecode/set/rel-op.hh> \endcode * \ingroup FuncSetProp */ template<class View0, class View1> class PartitionN : public MixNaryOnePropagator<View0,PC_SET_ANY, View1,PC_SET_ANY> { protected: using MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>::x; using MixNaryOnePropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>::y; /// Whether the any views share a variable implementation bool shared; /// Union of the determined \f$x_i\f$ (which are dropped) GLBndSet unionOfDets; /// Constructor for cloning \a p PartitionN(Space& home, PartitionN& p); /// Constructor for posting PartitionN(Home home, ViewArray<View0>&, View1); /// Constructor for posting PartitionN(Home home, ViewArray<View0>&, const IntSet&, View1); public: /// Copy propagator during cloning virtual Actor* copy(Space& home); /// Perform propagation virtual ExecStatus propagate(Space& home, const ModEventDelta& med); /// Cost function virtual PropCost cost(const Space& home, const ModEventDelta& med) const; /// Post propagator \f$ x = \biguplus_{i\in\{0,\dots,n-1\}} y_i \f$ static ExecStatus post(Home home,ViewArray<View0>& y,View1 x); /// Post propagator \f$ x = z\uplus\biguplus_{i\in\{0,\dots,n-1\}} y_i \f$ static ExecStatus post(Home home,ViewArray<View0>& y, const IntSet& z,View1 x); };
}}}
#include <gecode/set/rel-op/common.hpp>#include <gecode/set/rel-op/superofinter.hpp>#include <gecode/set/rel-op/subofunion.hpp>#include <gecode/set/rel-op/inter.hpp>#include <gecode/set/rel-op/union.hpp>#include <gecode/set/rel-op/partition.hpp>#include <gecode/set/rel-op/post.hpp>
#endif
// STATISTICS: set-prop