Generated on Tue Mar 24 2020 14:04:04 for Gecode by doxygen 1.8.17
var-imp.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Filip Konvicka <filip.konvicka@logis.cz>
5  * Lubomir Moric <lubomir.moric@logis.cz>
6  * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
7  *
8  * Contributing authors:
9  * Christian Schulte <schulte@gecode.org>
10  *
11  * Copyright:
12  * LOGIS, s.r.o., 2008
13  * Christian Schulte, 2010
14  * Vincent Barichard, 2012
15  *
16  * This file is part of Gecode, the generic constraint
17  * development environment:
18  * http://www.gecode.org
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  *
39  */
40 
41 #include <cmath>
42 
43 namespace Gecode { namespace Float {
44 
45  class FloatVarImp;
46 
48  class FloatDelta : public Delta {
49  friend class FloatVarImp;
50  private:
51  FloatNum _min;
52  FloatNum _max;
53  public:
55  FloatDelta(void);
58  private:
60  FloatNum min(void) const;
62  FloatNum max(void) const;
63  };
64 
65 }}
66 
68 
69 namespace Gecode { namespace Float {
70 
76  class FloatVarImp : public FloatVarImpBase {
77  protected:
81  FloatVarImp(Space& home, FloatVarImp& x);
82  public:
84  FloatVarImp(Space& home, const FloatVal& d);
85 
87 
88  FloatVal domain(void) const;
91  FloatNum min(void) const;
93  FloatNum max(void) const;
95  FloatVal val(void) const;
97  FloatNum med(void) const;
98 
100  FloatNum size(void) const;
102 
104 
105  bool assigned(void) const;
107 
109  bool zero_in(void) const;
111  bool in(FloatNum n) const;
113  bool in(const FloatVal& n) const;
115 
117 
118  ModEvent eq(Space& home, FloatNum n);
121  ModEvent eq(Space& home, const FloatVal& n);
123  ModEvent lq(Space& home, FloatNum n);
125  ModEvent lq(Space& home, const FloatVal& n);
127  ModEvent gq(Space& home, FloatNum n);
129  ModEvent gq(Space& home, const FloatVal& n);
131 
133 
134 
142  GECODE_FLOAT_EXPORT void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
153  GECODE_FLOAT_EXPORT void subscribe(Space& home, Advisor& a, bool fail);
155 
157 
158  static ModEventDelta med(ModEvent me);
161 
162 
163  private:
165  GECODE_FLOAT_EXPORT FloatVarImp* perform_copy(Space& home);
166  public:
168 
169  FloatVarImp* copy(Space& home);
172 
174 
175  static FloatNum min(const Delta& d);
178  static FloatNum max(const Delta& d);
180  };
181 
182 }}
183 
185 
186 // STATISTICS: float-var
187 
Post propagator for SetVar x
Definition: set.hh:767
FloatVarImp(Space &home, FloatVarImp &x)
Constructor for cloning x.
Definition: float.hpp:53
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition: float.hpp:100
ModEvent fail(Space &home)
Run advisors to be run on failure and returns ME_GEN_FAILED.
Definition: core.hpp:4570
ModEvent lq(Space &home, FloatNum n)
Restrict domain values to be less or equal than n.
Definition: float.hpp:159
bool assigned(void) const
Test whether variable is assigned.
Definition: float.hpp:84
const FloatNum min
Smallest allowed float value.
Definition: float.hh:846
Computation spaces.
Definition: core.hpp:1742
FloatNum max(void) const
Return maximum of domain.
Definition: float.hpp:71
ModEvent gq(Space &home, FloatNum n)
Restrict domain values to be greater or equal than n.
Definition: float.hpp:133
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
Definition: float.cpp:50
Gecode toplevel namespace
Base-class for propagators.
Definition: core.hpp:1064
static void schedule(Gecode::Space &home, Gecode::Propagator &p, Gecode::ModEvent me)
Schedule propagator p.
Definition: var-imp.hpp:448
Float variable implementation.
Definition: var-imp.hpp:76
Generic domain change information to be supplied to advisors.
Definition: core.hpp:204
ModEvent eq(Space &home, FloatNum n)
Restrict domain values to be equal to n.
Definition: float.hpp:185
FloatDelta(void)
Create float delta as providing no information.
Definition: delta.hpp:44
double FloatNum
Floating point number base type.
Definition: float.hh:106
#define GECODE_FLOAT_EXPORT
Definition: float.hh:68
void reschedule(Space &home, Propagator &p, PropCond pc)
Re-schedule propagator p with propagation condition pc.
Definition: float.cpp:56
FloatNum min(void) const
Return minimum of domain.
Definition: float.hpp:67
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
FloatNum size(void) const
Return width of domain (distance between maximum and minimum)
Definition: float.hpp:89
FloatNum med(void) const
Return median of domain (closest representation)
Definition: float.hpp:79
int ModEvent
Type for modification events.
Definition: core.hpp:62
int PropCond
Type for propagation conditions.
Definition: core.hpp:72
Base-class for Float-variable implementations.
Definition: var-imp.hpp:185
Float value type.
Definition: float.hh:334
FloatVal dom
Domain information.
Definition: var-imp.hpp:79
Gecode::IntSet d(v, 7)
Base-class for advisors.
Definition: core.hpp:1292
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition: float.hpp:104
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
Definition: core.hpp:4270
Float delta information for advisors.
Definition: var-imp.hpp:48
Min _min("Int::Min")
FloatVal domain(void) const
Return domain.
Definition: float.hpp:63
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
FloatVal val(void) const
Return value of domain (only if assigned)
Definition: float.hpp:75
Max _max("Int::Max")
FloatVarImp * copy(Space &home)
Return copy of this variable.
Definition: float.hpp:216
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
const FloatNum max
Largest allowed float value.
Definition: float.hh:844