Generated on Tue Jul 18 2017 18:41:42 for Gecode by doxygen 1.8.13
afc.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2013
8  *
9  * Last modified:
10  * $Date: 2017-03-08 11:58:56 +0100 (Wed, 08 Mar 2017) $ by $Author: schulte $
11  * $Revision: 15562 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode {
39 
44  class AFC {
45  protected:
47  int n;
48  public:
50 
51 
58  AFC(void);
60  AFC(const AFC& a);
62  AFC& operator =(const AFC& a);
64  template<class Var>
65  AFC(Home home, const VarArgArray<Var>& x, double d);
67  template<class Var>
68  void init(Home home, const VarArgArray<Var>& x, double d);
70  operator bool(void) const;
74 
76 
77  void update(Space& home, bool share, AFC& a);
80  ~AFC(void);
82 
84 
85  int size(void) const;
88 
90 
91  void decay(Space& home, double d);
94  double decay(const Space& home) const;
96  };
97 
102  template<class Char, class Traits>
103  std::basic_ostream<Char,Traits>&
104  operator <<(std::basic_ostream<Char,Traits>& os,
105  const AFC& a);
106 
107  /*
108  * AFC
109  *
110  */
111  forceinline int
112  AFC::size(void) const {
113  assert(n >= 0);
114  return n;
115  }
116 
118  AFC::AFC(void) : n(-1) {}
119 
121  AFC::operator bool(void) const {
122  return n >= 0;
123  }
124 
125  template<class Var>
127  AFC::AFC(Home home, const VarArgArray<Var>& x, double d)
128  : n(x.size()) {
129  if ((d < 0.0) || (d > 1.0))
130  throw IllegalDecay("AFC");
131  static_cast<Space&>(home).afc_decay(d);
132  }
133  template<class Var>
134  forceinline void
135  AFC::init(Home home, const VarArgArray<Var>& x, double d) {
136  n = x.size();
137  if ((d < 0.0) || (d > 1.0))
138  throw IllegalDecay("AFC");
139  static_cast<Space&>(home).afc_decay(d);
140  }
141 
142 
144  AFC::AFC(const AFC& a)
145  : n(a.n) {}
148  n=a.n;
149  return *this;
150  }
152  AFC::~AFC(void) {}
153 
154  forceinline void
155  AFC::update(Space&, bool, AFC& a) {
156  n=a.n;
157  }
158 
159  forceinline void
160  AFC::decay(Space& home, double d) {
161  if ((d < 0.0) || (d > 1.0))
162  throw IllegalDecay("AFC");
163  home.afc_decay(d);
164  }
165 
166  forceinline double
167  AFC::decay(const Space& home) const {
168  return home.afc_decay();
169  }
170 
171 
172  template<class Char, class Traits>
173  std::basic_ostream<Char,Traits>&
174  operator <<(std::basic_ostream<Char,Traits>& os,
175  const AFC& a) {
176  (void)a;
177  return os << "AFC(no information available)";
178  }
179 
180 }
181 
182 // STATISTICS: kernel-branch
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1669
void init(Home home, const VarArgArray< Var > &x, double d)
Initialize for views x and decay factor d.
Definition: afc.hpp:135
~AFC(void)
Destructor.
Definition: afc.hpp:152
void afc_decay(double d)
Set AFC decay factor to d
Definition: core.hpp:3349
Computation spaces.
Definition: core.hpp:1748
Gecode::IntSet d(v, 7)
AFC(void)
Construct as not yet intialized.
Definition: afc.hpp:118
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
int size(void) const
Return number of AFC values.
Definition: afc.hpp:112
#define GECODE_KERNEL_EXPORT
Definition: kernel.hh:74
int n
Number of views.
Definition: afc.hpp:47
void decay(Space &home, double d)
Set decay factor to d.
Definition: afc.hpp:160
#define forceinline
Definition: config.hpp:173
static const AFC def
Default (empty) AFC information.
Definition: afc.hpp:72
Post propagator for SetVar x
Definition: set.hh:784
Gecode toplevel namespace
Argument array for variables.
Definition: array.hpp:53
void update(Space &home, bool share, AFC &a)
Updating during cloning.
Definition: afc.hpp:155
AFC & operator=(const AFC &a)
Assignment operator.
Definition: afc.hpp:147
Exception: illegal decay factor
Definition: exception.hpp:111
Home class for posting propagators
Definition: core.hpp:922