Generated on Sat Feb 7 2015 02:01:17 for Gecode by doxygen 1.8.9.1
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  * Last modified:
17  * $Date: 2013-02-04 17:54:05 +0100 (Mon, 04 Feb 2013) $ by $Author: schulte $
18  * $Revision: 13260 $
19  *
20  * This file is part of Gecode, the generic constraint
21  * development environment:
22  * http://www.gecode.org
23  *
24  * Permission is hereby granted, free of charge, to any person obtaining
25  * a copy of this software and associated documentation files (the
26  * "Software"), to deal in the Software without restriction, including
27  * without limitation the rights to use, copy, modify, merge, publish,
28  * distribute, sublicense, and/or sell copies of the Software, and to
29  * permit persons to whom the Software is furnished to do so, subject to
30  * the following conditions:
31  *
32  * The above copyright notice and this permission notice shall be
33  * included in all copies or substantial portions of the Software.
34  *
35  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42  *
43  */
44 
45 #include <cmath>
46 
47 namespace Gecode { namespace Float {
48 
49  class FloatVarImp;
50 
52  class FloatDelta : public Delta {
53  friend class FloatVarImp;
54  private:
55  FloatNum _min;
56  FloatNum _max;
57  public:
59  FloatDelta(void);
62  private:
64  FloatNum min(void) const;
66  FloatNum max(void) const;
67  };
68 
69 }}
70 
72 
73 namespace Gecode { namespace Float {
74 
80  class FloatVarImp : public FloatVarImpBase {
81  protected:
85  FloatVarImp(Space& home, bool share, FloatVarImp& x);
86  public:
88  FloatVarImp(Space& home, const FloatVal& d);
89 
91 
92  FloatVal domain(void) const;
95  FloatNum min(void) const;
97  FloatNum max(void) const;
99  FloatVal val(void) const;
101  FloatNum med(void) const;
102 
104  FloatNum size(void) const;
106 
108 
109  bool assigned(void) const;
111 
113  bool zero_in(void) const;
115  bool in(FloatNum n) const;
117  bool in(const FloatVal& n) const;
119 
121 
122  ModEvent eq(Space& home, FloatNum n);
125  ModEvent eq(Space& home, const FloatVal& n);
127  ModEvent lq(Space& home, FloatNum n);
129  ModEvent lq(Space& home, const FloatVal& n);
131  ModEvent gq(Space& home, FloatNum n);
133  ModEvent gq(Space& home, const FloatVal& n);
135 
137 
138 
146  void subscribe(Space& home, Propagator& p, PropCond pc, bool schedule=true);
148  void cancel(Space& home, Propagator& p, PropCond pc);
150  void subscribe(Space& home, Advisor& a);
152  void cancel(Space& home, Advisor& a);
154 
156 
157  static ModEventDelta med(ModEvent me);
160 
161 
162  private:
164  GECODE_FLOAT_EXPORT FloatVarImp* perform_copy(Space& home, bool share);
165  public:
167 
168  FloatVarImp* copy(Space& home, bool share);
171 
173 
174  static FloatNum min(const Delta& d);
177  static FloatNum max(const Delta& d);
179  };
180 
181 }}
182 
184 
185 // STATISTICS: float-var
186 
#define GECODE_FLOAT_EXPORT
Definition: float.hh:70
FloatNum min(void) const
Return minimum of domain.
Definition: float.hpp:71
bool assigned(void) const
Test whether variable is assigned.
Definition: float.hpp:88
const FloatNum max
Largest allowed float value.
Definition: float.hh:831
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc.
Definition: float.hpp:240
FloatVal dom
Domain information.
Definition: var-imp.hpp:83
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition: float.hpp:104
int ModEvent
Type for modification events.
Definition: core.hpp:146
static void schedule(Space &home, Propagator &p, ModEvent me, bool force=false)
Schedule propagator p with modification event me.
Base-class for propagators.
Definition: core.hpp:755
Base-class for advisors.
Definition: core.hpp:926
Computation spaces.
Definition: core.hpp:1362
Min _min("Int::Min")
Gecode::IntSet d(v, 7)
FloatVarImp(Space &home, bool share, FloatVarImp &x)
Constructor for cloning x.
Definition: float.hpp:57
FloatNum size(void) const
Return width of domain (distance between maximum and minimum)
Definition: float.hpp:93
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
const FloatNum min
Smallest allowed float value.
Definition: float.hh:833
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
FloatNum med(void) const
Return median of domain (closest representation)
Definition: float.hpp:83
static ModEvent me(const ModEventDelta &med)
Project modification event for this variable type from med.
Max _max("Int::Max")
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition: float.hpp:108
Float variable implementation.
Definition: var-imp.hpp:80
FloatDelta(void)
Create float delta as providing no information.
Definition: delta.hpp:48
int PropCond
Type for propagation conditions.
Definition: core.hpp:156
Float delta information for advisors.
Definition: var-imp.hpp:52
FloatVarImp * copy(Space &home, bool share)
Return copy of this variable.
Definition: float.hpp:220
FloatVal val(void) const
Return value of domain (only if assigned)
Definition: float.hpp:79
Float value type.
Definition: float.hh:321
ModEvent eq(Space &home, FloatNum n)
Restrict domain values to be equal to n.
Definition: float.hpp:189
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Generic domain change information to be supplied to advisors.
Definition: core.hpp:275
FloatVal domain(void) const
Return domain.
Definition: float.hpp:67
ModEvent gq(Space &home, FloatNum n)
Restrict domain values to be greater or equal than n.
Definition: float.hpp:137
Gecode toplevel namespace
FloatNum max(void) const
Return maximum of domain.
Definition: float.hpp:75
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
Definition: float.hpp:236
Base-class for Float-variable implementations.
Definition: var-imp.hpp:152
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
double FloatNum
Floating point number base type.
Definition: float.hh:108
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
ModEvent lq(Space &home, FloatNum n)
Restrict domain values to be less or equal than n.
Definition: float.hpp:163