Generated on Thu Apr 5 2018 19:44:19 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$ by $Author$
11  * $Revision$
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);
69  template<class Var>
70  AFC(Home home, const VarArgArray<Var>& x, double d, bool share=true);
77  template<class Var>
78  void init(Home home, const VarArgArray<Var>& x, double d, bool share=true);
80  operator bool(void) const;
84 
86  ~AFC(void);
87 
89 
90  int size(void) const;
93 
95 
96  void decay(Space& home, double d);
99  double decay(const Space& home) const;
101  };
102 
107  template<class Char, class Traits>
108  std::basic_ostream<Char,Traits>&
109  operator <<(std::basic_ostream<Char,Traits>& os,
110  const AFC& a);
111 
112  /*
113  * AFC
114  *
115  */
116  forceinline int
117  AFC::size(void) const {
118  assert(n >= 0);
119  return n;
120  }
121 
123  AFC::AFC(void) : n(-1) {}
124 
126  AFC::operator bool(void) const {
127  return n >= 0;
128  }
129 
130  template<class Var>
132  AFC::AFC(Home home, const VarArgArray<Var>& x, double d, bool share)
133  : n(x.size()) {
134  if ((d < 0.0) || (d > 1.0))
135  throw IllegalDecay("AFC");
136  static_cast<Space&>(home).afc_decay(d);
137  if (!share)
138  static_cast<Space&>(home).afc_unshare();
139  }
140  template<class Var>
141  forceinline void
142  AFC::init(Home home, const VarArgArray<Var>& x, double d, bool share) {
143  n = x.size();
144  if ((d < 0.0) || (d > 1.0))
145  throw IllegalDecay("AFC");
146  static_cast<Space&>(home).afc_decay(d);
147  if (!share)
148  static_cast<Space&>(home).afc_unshare();
149  }
150 
151 
153  AFC::AFC(const AFC& a)
154  : n(a.n) {}
157  n=a.n;
158  return *this;
159  }
161  AFC::~AFC(void) {}
162 
163  forceinline void
164  AFC::decay(Space& home, double d) {
165  if ((d < 0.0) || (d > 1.0))
166  throw IllegalDecay("AFC");
167  home.afc_decay(d);
168  }
169 
170  forceinline double
171  AFC::decay(const Space& home) const {
172  return home.afc_decay();
173  }
174 
175 
176  template<class Char, class Traits>
177  std::basic_ostream<Char,Traits>&
178  operator <<(std::basic_ostream<Char,Traits>& os,
179  const AFC& a) {
180  (void)a;
181  return os << "AFC(no information available)";
182  }
183 
184 }
185 
186 // STATISTICS: kernel-branch
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1657
void init(Home home, const VarArgArray< Var > &x, double d, bool share=true)
Initialize for variables x and decay factor d.
Definition: afc.hpp:142
~AFC(void)
Destructor.
Definition: afc.hpp:161
void afc_decay(double d)
Set AFC decay factor to d
Definition: core.hpp:3167
#define forceinline
Definition: config.hpp:182
Computation spaces.
Definition: core.hpp:1668
Gecode::IntSet d(v, 7)
AFC(void)
Construct as not yet intialized.
Definition: afc.hpp:123
Class for AFC (accumulated failure count) management.
Definition: afc.hpp:44
int size(void) const
Return number of AFC values.
Definition: afc.hpp:117
#define GECODE_KERNEL_EXPORT
Definition: kernel.hh:74
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
int n
Number of views.
Definition: afc.hpp:47
void decay(Space &home, double d)
Set decay factor to d.
Definition: afc.hpp:164
static const AFC def
Default (empty) AFC information.
Definition: afc.hpp:82
Post propagator for SetVar x
Definition: set.hh:769
Gecode toplevel namespace
Argument array for variables.
Definition: array.hpp:53
AFC & operator=(const AFC &a)
Assignment operator.
Definition: afc.hpp:156
Exception: illegal decay factor
Definition: exception.hpp:111
Home class for posting propagators
Definition: core.hpp:846