Generated on Sat Jun 2 2018 07:17:44 for Gecode by doxygen 1.8.13
view.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  * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
6  *
7  * Copyright:
8  * Christian Schulte, 2005
9  * Vincent Barichard, 2012
10  *
11  * This file is part of Gecode, the generic constraint
12  * development environment:
13  * http://www.gecode.org
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining
16  * a copy of this software and associated documentation files (the
17  * "Software"), to deal in the Software without restriction, including
18  * without limitation the rights to use, copy, modify, merge, publish,
19  * distribute, sublicense, and/or sell copies of the Software, and to
20  * permit persons to whom the Software is furnished to do so, subject to
21  * the following conditions:
22  *
23  * The above copyright notice and this permission notice shall be
24  * included in all copies or substantial portions of the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33  *
34  */
35 
36 #include <iostream>
37 
38 namespace Gecode { namespace Float {
39 
52  class FloatView : public VarImpView<FloatVar> {
53  protected:
55  public:
57 
58  FloatView(void);
61  FloatView(const FloatVar& y);
65 
67 
68  FloatVal domain(void) const;
71  FloatNum min(void) const;
73  FloatNum max(void) const;
75  FloatNum med(void) const;
83  FloatVal val(void) const;
84 
86  FloatNum size(void) const;
88 
90 
91  bool zero_in(void) const;
94  bool in(FloatNum n) const;
96  bool in(const FloatVal& n) const;
98 
100 
101  ModEvent lq(Space& home, int n);
104  ModEvent lq(Space& home, FloatNum n);
106  ModEvent lq(Space& home, FloatVal n);
107 
109  ModEvent gq(Space& home, int n);
111  ModEvent gq(Space& home, FloatNum n);
113  ModEvent gq(Space& home, FloatVal n);
114 
116  ModEvent eq(Space& home, int n);
118  ModEvent eq(Space& home, FloatNum n);
120  ModEvent eq(Space& home, const FloatVal& n);
121 
123 
125 
126  FloatNum min(const Delta& d) const;
129  FloatNum max(const Delta& d) const;
131 
133 
134  static ModEventDelta med(ModEvent me);
137  };
138 
143  template<class Char, class Traits>
144  std::basic_ostream<Char,Traits>&
145  operator <<(std::basic_ostream<Char,Traits>& os, const FloatView& x);
146 
154  class MinusView : public DerivedView<FloatView> {
155  protected:
157  public:
159 
160  MinusView(void);
163  explicit MinusView(const FloatView& y);
165 
167 
168  FloatVal domain(void) const;
171  FloatNum min(void) const;
173  FloatNum max(void) const;
175  FloatNum med(void) const;
183  FloatVal val(void) const;
184 
186  FloatNum size(void) const;
188 
190 
191  bool zero_in(void) const;
194  bool in(FloatNum n) const;
196  bool in(const FloatVal& n) const;
198 
200 
201  ModEvent lq(Space& home, int n);
204  ModEvent lq(Space& home, FloatNum n);
206  ModEvent lq(Space& home, FloatVal n);
207 
209  ModEvent gq(Space& home, int n);
211  ModEvent gq(Space& home, FloatNum n);
213  ModEvent gq(Space& home, FloatVal n);
214 
216  ModEvent eq(Space& home, int n);
218  ModEvent eq(Space& home, FloatNum n);
220  ModEvent eq(Space& home, const FloatVal& n);
221 
223 
225 
226  FloatNum min(const Delta& d) const;
229  FloatNum max(const Delta& d) const;
231 
233 
234  static ModEventDelta med(ModEvent me);
237  };
238 
243  template<class Char, class Traits>
244  std::basic_ostream<Char,Traits>&
245  operator <<(std::basic_ostream<Char,Traits>& os, const MinusView& x);
246 
247 
256  class OffsetView : public DerivedView<FloatView> {
257  protected:
261  public:
263 
264  OffsetView(void);
267  explicit OffsetView(const FloatView& y, FloatNum c);
269 
271 
272  FloatNum offset(void) const;
275  void offset(FloatNum n);
277  FloatVal domain(void) const;
279  FloatNum min(void) const;
281  FloatNum max(void) const;
283  FloatNum med(void) const;
291  FloatVal val(void) const;
292 
294  FloatNum size(void) const;
296 
298 
299  bool zero_in(void) const;
302  bool in(FloatNum n) const;
304  bool in(const FloatVal& n) const;
306 
308 
309  ModEvent lq(Space& home, int n);
312  ModEvent lq(Space& home, FloatNum n);
314  ModEvent lq(Space& home, FloatVal n);
315 
317  ModEvent gq(Space& home, int n);
319  ModEvent gq(Space& home, FloatNum n);
321  ModEvent gq(Space& home, FloatVal n);
322 
324  ModEvent eq(Space& home, int n);
326  ModEvent eq(Space& home, FloatNum n);
328  ModEvent eq(Space& home, const FloatVal& n);
329 
331 
333 
334  FloatNum min(const Delta& d) const;
337  FloatNum max(const Delta& d) const;
339 
341 
342  static ModEventDelta med(ModEvent me);
345 
347 
348  void update(Space& home, OffsetView& y);
350  };
351 
356  template<class Char, class Traits>
357  std::basic_ostream<Char,Traits>&
358  operator <<(std::basic_ostream<Char,Traits>& os, const OffsetView& x);
359 
369  class ScaleView : public DerivedView<FloatView> {
370  protected:
374 
375  public:
377 
378  ScaleView(void);
381  ScaleView(FloatVal b, const FloatView& y);
383 
385 
386  FloatVal domain(void) const;
389  FloatVal scale(void) const;
391  FloatNum min(void) const;
393  FloatNum max(void) const;
395  FloatNum med(void) const;
396 
404  FloatVal val(void) const;
405 
407  FloatNum size(void) const;
409 
411 
412  bool zero_in(void) const;
415  bool in(FloatNum n) const;
417  bool in(const FloatVal& n) const;
419 
421 
422  ModEvent lq(Space& home, int n);
425  ModEvent lq(Space& home, FloatNum n);
427  ModEvent lq(Space& home, FloatVal n);
428 
430  ModEvent gq(Space& home, int n);
432  ModEvent gq(Space& home, FloatNum n);
434  ModEvent gq(Space& home, FloatVal n);
435 
437  ModEvent eq(Space& home, int n);
439  ModEvent eq(Space& home, FloatNum n);
441  ModEvent eq(Space& home, const FloatVal& n);
442 
444 
446 
447  FloatNum min(const Delta& d) const;
450  FloatNum max(const Delta& d) const;
452 
454 
455  static ModEventDelta med(ModEvent me);
458 
460 
461  void update(Space& home, ScaleView& y);
463  };
464 
469  template<class Char, class Traits>
470  std::basic_ostream<Char,Traits>&
471  operator <<(std::basic_ostream<Char,Traits>& os, const ScaleView& x);
472 
473 } }
474 
482 
483 namespace Gecode { namespace Float {
490  enum RelTest {
492  RT_FALSE = 0,
493  RT_MAYBE = 1,
494  RT_TRUE = 2
495  };
496 
498  template<class View> RelTest rtest_eq(View x, View y);
500  template<class View> RelTest rtest_eq(View x, FloatVal n);
501 
503  template<class View> RelTest rtest_lq(View x, View y);
505  template<class View> RelTest rtest_lq(View x, FloatVal n);
506 
508  template<class View> RelTest rtest_le(View x, View y);
510  template<class View> RelTest rtest_le(View x, FloatVal n);
511 
513 
514 }}
515 
517 
518 // STATISTICS: float-var
RelTest rtest_lq(View x, View y)
Test whether view x is less or equal than view y.
Definition: rel-test.hpp:54
void update(Space &home, VarImpView< FloatVar > &y)
Update this view to be a clone of view y.
Definition: view.hpp:555
FloatVal val(void) const
Return assigned value.
Definition: float.hpp:72
FloatNum med(void) const
Return median of domain (closest representation)
Definition: float.hpp:68
RelTest
Result of testing relation.
Definition: view.hpp:491
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition: float.hpp:118
OffsetView float view.
Definition: view.hpp:256
Relation does hold.
Definition: view.hpp:494
int ModEvent
Type for modification events.
Definition: core.hpp:62
Relation does not hold.
Definition: view.hpp:492
Computation spaces.
Definition: core.hpp:1701
Base-class for derived views.
Definition: view.hpp:230
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition: float.hpp:131
Gecode::IntSet d(v, 7)
FloatView(void)
Default constructor.
Definition: float.hpp:43
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition: float.hpp:91
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Float variable implementation.
Definition: var-imp.hpp:76
FloatNum min(void) const
Return minimum of domain.
Definition: float.hpp:60
Base-class for variable implementation views.
Definition: view.hpp:127
FloatVal a
Scale factor.
Definition: view.hpp:373
Float view for float variables.
Definition: view.hpp:52
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:765
Float value type.
Definition: float.hh:334
RelTest rtest_eq(View x, View y)
Test whether views x and y are equal.
Definition: rel-test.hpp:40
Generic domain change information to be supplied to advisors.
Definition: core.hpp:203
FloatNum max(void) const
Return maximum of domain.
Definition: float.hpp:64
Minus float view.
Definition: view.hpp:154
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
Definition: view.hpp:540
Float variables.
Definition: float.hh:870
RelTest rtest_le(View x, View y)
Test whether view x is less than view y.
Definition: rel-test.hpp:70
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition: float.hpp:77
Gecode toplevel namespace
Relation may hold or not.
Definition: view.hpp:493
VarImpType * x
Pointer to variable implementation.
Definition: view.hpp:135
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
FloatVal domain(void) const
Return domain.
Definition: float.hpp:56
double FloatNum
Floating point number base type.
Definition: float.hh:106
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition: float.hpp:105
Scale float view.
Definition: view.hpp:369
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition: float.hpp:87
FloatNum c
Offset.
Definition: view.hpp:259