this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Christopher Mears <Chris.Mears@monash.edu>
5 *
6 * Contributing authors:
7 * Christian Schulte <schulte@gecode.org>
8 * Guido Tack <tack@gecode.org>
9 *
10 * Copyright:
11 * Christopher Mears, 2011
12 * Christian Schulte, 2011
13 * Guido Tack, 2011
14 *
15 * This file is part of Gecode, the generic constraint
16 * development environment:
17 * http://www.gecode.org
18 *
19 * Permission is hereby granted, free of charge, to any person obtaining
20 * a copy of this software and associated documentation files (the
21 * "Software"), to deal in the Software without restriction, including
22 * without limitation the rights to use, copy, modify, merge, publish,
23 * distribute, sublicense, and/or sell copies of the Software, and to
24 * permit persons to whom the Software is furnished to do so, subject to
25 * the following conditions:
26 *
27 * The above copyright notice and this permission notice shall be
28 * included in all copies or substantial portions of the Software.
29 *
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 *
38 */
39
40#ifndef GECODE_SET_PRECEDE_HH
41#define GECODE_SET_PRECEDE_HH
42
43#include <gecode/set.hh>
44
45/**
46 * \namespace Gecode::Set::Precede
47 * \brief Value precedence propagators
48 */
49
50namespace Gecode { namespace Set { namespace Precede {
51
52 /**
53 * \brief Single value precedence propagator
54 *
55 * The propagator is based on: Yat Chiu Law and Jimmy H.M. Lee,
56 * Global Constraints for Integer and Set Value Precedence,
57 * CP 2004, 362--376.
58 *
59 * Requires \code #include <gecode/set/precede.hh> \endcode
60 * \ingroup FuncIntProp
61 */
62 template<class View>
63 class Single : public NaryPropagator<View,PC_SET_NONE> {
64 protected:
65 using NaryPropagator<View,PC_SET_NONE>::x;
66 /// %Advisors for views (by position in array)
67 class Index : public Advisor {
68 public:
69 /// The position of the view in the view array
70 int i;
71 /// Create index advisor
72 Index(Space& home, Propagator& p, Council<Index>& c, int i);
73 /// Clone index advisor \a a
74 Index(Space& home, Index& a);
75 };
76 /// The advisor council
77 Council<Index> c;
78 /// The value \a s must precede \a t
79 int s, t;
80 /// Pointers updated during propagation
81 int alpha, beta, gamma;
82 /// Update the alpha pointer
83 ExecStatus updateAlpha(Space& home);
84 /// Update the beta pointer
85 ExecStatus updateBeta(Space& home);
86 /// Constructor for posting
87 Single(Home home, ViewArray<View>& x, int s, int t, int beta, int gamma);
88 /// Constructor for cloning \a p
89 Single(Space& home, Single<View>& p);
90 public:
91 /// Copy propagator during cloning
92 virtual Propagator* copy(Space& home);
93 /// Cost function
94 virtual PropCost cost(const Space&, const ModEventDelta&) const;
95 /// Schedule function
96 virtual void reschedule(Space& home);
97 /// Delete propagator and return its size
98 virtual size_t dispose(Space& home);
99 /// Give advice to propagator
100 virtual ExecStatus advise(Space& home, Advisor& a, const Delta& d);
101 /// Perform propagation
102 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
103 /// Post propagator that \a s precedes \a t in \a x
104 static ExecStatus post(Home home, ViewArray<View>& x, int s, int t);
105 };
106
107}}}
108
109#include <gecode/set/precede/single.hpp>
110
111#endif
112
113// STATISTICS: set-prop