Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34namespace Gecode {
35
40 class AFC {
41 protected:
43 int n;
44 public:
46
47
54 AFC(void);
56 AFC(const AFC& a);
58 AFC& operator =(const AFC& a);
65 template<class Var>
66 AFC(Home home, const VarArgArray<Var>& x, double d, bool share=true);
73 template<class Var>
74 void init(Home home, const VarArgArray<Var>& x, double d, bool share=true);
76 operator bool(void) const;
80
82 ~AFC(void);
83
85
86
87 int size(void) const;
89
91
92
93 void decay(Space& home, double d);
95 double decay(const Space& home) const;
97 };
98
103 template<class Char, class Traits>
104 std::basic_ostream<Char,Traits>&
105 operator <<(std::basic_ostream<Char,Traits>& os,
106 const AFC& a);
107
108 /*
109 * AFC
110 *
111 */
112 forceinline int
113 AFC::size(void) const {
114 assert(n >= 0);
115 return n;
116 }
117
119 AFC::AFC(void) : n(-1) {}
120
122 AFC::operator bool(void) const {
123 return n >= 0;
124 }
125
126 template<class Var>
128 AFC::AFC(Home home, const VarArgArray<Var>& x, double d, bool share)
129 : n(x.size()) {
130 if ((d < 0.0) || (d > 1.0))
131 throw IllegalDecay("AFC");
132 static_cast<Space&>(home).afc_decay(d);
133 if (!share)
134 static_cast<Space&>(home).afc_unshare();
135 }
136 template<class Var>
137 forceinline void
138 AFC::init(Home home, const VarArgArray<Var>& x, double d, bool share) {
139 n = x.size();
140 if ((d < 0.0) || (d > 1.0))
141 throw IllegalDecay("AFC");
142 static_cast<Space&>(home).afc_decay(d);
143 if (!share)
144 static_cast<Space&>(home).afc_unshare();
145 }
146
147
149 AFC::AFC(const AFC& a)
150 : n(a.n) {}
153 n=a.n;
154 return *this;
155 }
157 AFC::~AFC(void) {}
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 n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Class for AFC (accumulated failure count) management.
Definition afc.hpp:40
~AFC(void)
Destructor.
Definition afc.hpp:157
int n
Number of views.
Definition afc.hpp:43
int size(void) const
Return number of AFC values.
Definition afc.hpp:113
AFC(void)
Construct as not yet intialized.
Definition afc.hpp:119
AFC & operator=(const AFC &a)
Assignment operator.
Definition afc.hpp:152
static const AFC def
Default (empty) AFC information.
Definition afc.hpp:78
void init(Home home, const VarArgArray< Var > &x, double d, bool share=true)
Initialize for variables x and decay factor d.
Definition afc.hpp:138
void decay(Space &home, double d)
Set decay factor to d.
Definition afc.hpp:160
Home class for posting propagators
Definition core.hpp:856
Exception: illegal decay factor
Computation spaces.
Definition core.hpp:1742
void afc_decay(double d)
Set AFC decay factor to d
Definition core.hpp:3247
Argument array for variables.
Definition array.hpp:774
#define GECODE_KERNEL_EXPORT
Definition kernel.hh:70
Gecode toplevel namespace
Archive & operator<<(Archive &e, FloatNumBranch nl)
Definition val-sel.hpp:39
Post propagator for SetVar x
Definition set.hh:767
#define forceinline
Definition config.hpp:187