Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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
38namespace Gecode { namespace Float {
39
47
52 class FloatView : public VarImpView<FloatVar> {
53 protected:
55 public:
57
58
59 FloatView(void);
61 FloatView(const FloatVar& y);
65
67
68
69 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
92 bool zero_in(void) const;
94 bool in(FloatNum n) const;
96 bool in(const FloatVal& n) const;
98
100
101
102 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
127 FloatNum min(const Delta& d) const;
129 FloatNum max(const Delta& d) const;
131
133
134
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
161 MinusView(void);
163 explicit MinusView(const FloatView& y);
165
167
168
169 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
192 bool zero_in(void) const;
194 bool in(FloatNum n) const;
196 bool in(const FloatVal& n) const;
198
200
201
202 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
227 FloatNum min(const Delta& d) const;
229 FloatNum max(const Delta& d) const;
231
233
234
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
251
252 bool operator ==(const MinusView& x, const MinusView& y);
254 bool operator !=(const MinusView& x, const MinusView& y);
256
257
266 class OffsetView : public DerivedView<FloatView> {
267 protected:
271 public:
273
274
275 OffsetView(void);
277 explicit OffsetView(const FloatView& y, FloatNum c);
279
281
282
283 FloatNum offset(void) const;
285 void offset(FloatNum n);
287 FloatVal domain(void) const;
289 FloatNum min(void) const;
291 FloatNum max(void) const;
293 FloatNum med(void) const;
301 FloatVal val(void) const;
302
304 FloatNum size(void) const;
306
308
309
310 bool zero_in(void) const;
312 bool in(FloatNum n) const;
314 bool in(const FloatVal& n) const;
316
318
319
320 ModEvent lq(Space& home, int n);
322 ModEvent lq(Space& home, FloatNum n);
324 ModEvent lq(Space& home, FloatVal n);
325
327 ModEvent gq(Space& home, int n);
329 ModEvent gq(Space& home, FloatNum n);
331 ModEvent gq(Space& home, FloatVal n);
332
334 ModEvent eq(Space& home, int n);
336 ModEvent eq(Space& home, FloatNum n);
338 ModEvent eq(Space& home, const FloatVal& n);
339
341
343
344
345 FloatNum min(const Delta& d) const;
347 FloatNum max(const Delta& d) const;
349
351
352
355
357
358 void update(Space& home, OffsetView& y);
360
362
363
364 bool operator <(const OffsetView& y) const;
366 };
367
372 template<class Char, class Traits>
373 std::basic_ostream<Char,Traits>&
374 operator <<(std::basic_ostream<Char,Traits>& os, const OffsetView& x);
375
380
381 bool operator ==(const OffsetView& x, const OffsetView& y);
383 bool operator !=(const OffsetView& x, const OffsetView& y);
385
395 class ScaleView : public DerivedView<FloatView> {
396 protected:
400
401 public:
403
404
405 ScaleView(void);
407 ScaleView(FloatVal b, const FloatView& y);
409
411
412
413 FloatVal domain(void) const;
415 FloatVal scale(void) const;
417 FloatNum min(void) const;
419 FloatNum max(void) const;
421 FloatNum med(void) const;
422
430 FloatVal val(void) const;
431
433 FloatNum size(void) const;
435
437
438
439 bool zero_in(void) const;
441 bool in(FloatNum n) const;
443 bool in(const FloatVal& n) const;
445
447
448
449 ModEvent lq(Space& home, int n);
451 ModEvent lq(Space& home, FloatNum n);
453 ModEvent lq(Space& home, FloatVal n);
454
456 ModEvent gq(Space& home, int n);
458 ModEvent gq(Space& home, FloatNum n);
460 ModEvent gq(Space& home, FloatVal n);
461
463 ModEvent eq(Space& home, int n);
465 ModEvent eq(Space& home, FloatNum n);
467 ModEvent eq(Space& home, const FloatVal& n);
468
470
472
473
474 FloatNum min(const Delta& d) const;
476 FloatNum max(const Delta& d) const;
478
480
481
484
486
487 void update(Space& home, ScaleView& y);
489
491
492
493 bool operator <(const ScaleView& y) const;
495 };
496
501 template<class Char, class Traits>
502 std::basic_ostream<Char,Traits>&
503 operator <<(std::basic_ostream<Char,Traits>& os, const ScaleView& x);
504
509
510 bool operator ==(const ScaleView& x, const ScaleView& y);
512 bool operator !=(const ScaleView& x, const ScaleView& y);
514
515}}
516
524
525namespace Gecode { namespace Float {
530
532
533 enum RelTest {
537 };
538
540 template<class View> RelTest rtest_eq(View x, View y);
542 template<class View> RelTest rtest_eq(View x, FloatVal n);
543
545 template<class View> RelTest rtest_lq(View x, View y);
547 template<class View> RelTest rtest_lq(View x, FloatVal n);
548
550 template<class View> RelTest rtest_le(View x, View y);
552 template<class View> RelTest rtest_le(View x, FloatVal n);
553
555
556}}
557
559
560// STATISTICS: float-var
Generic domain change information to be supplied to advisors.
Definition core.hpp:204
static ModEvent me(const ModEventDelta &med)
Definition view.hpp:639
Float value type.
Definition float.hh:334
Float variables.
Definition float.hh:870
Float variable implementation.
Definition var-imp.hpp:76
Float view for float variables.
Definition view.hpp:52
FloatVal domain(void) const
Return domain.
Definition float.hpp:56
FloatNum max(void) const
Return maximum of domain.
Definition float.hpp:64
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition float.hpp:131
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition float.hpp:105
FloatNum min(void) const
Return minimum of domain.
Definition float.hpp:60
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition float.hpp:77
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition float.hpp:91
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
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition float.hpp:87
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition float.hpp:118
FloatView(void)
Default constructor.
Definition float.hpp:43
Minus float view.
Definition view.hpp:154
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition minus.hpp:128
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition minus.hpp:74
FloatVal domain(void) const
Return domain.
Definition minus.hpp:53
FloatNum min(void) const
Return minimum of domain.
Definition minus.hpp:57
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition minus.hpp:102
FloatNum max(void) const
Return maximum of domain.
Definition minus.hpp:61
FloatNum med(void) const
Return median of domain (closest representation)
Definition minus.hpp:65
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition minus.hpp:115
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition minus.hpp:84
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition minus.hpp:88
FloatVal val(void) const
Return assigned value.
Definition minus.hpp:69
MinusView(void)
Default constructor.
Definition minus.hpp:43
OffsetView float view.
Definition view.hpp:266
bool operator<(const OffsetView &y) const
Whether this view comes before view y (arbitray order)
Definition offset.hpp:184
FloatVal domain(void) const
Return domain.
Definition offset.hpp:62
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition offset.hpp:97
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition offset.hpp:83
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition offset.hpp:137
FloatVal val(void) const
Return assigned value.
Definition offset.hpp:78
void update(Space &home, OffsetView &y)
Definition offset.hpp:174
OffsetView(void)
Default constructor.
Definition offset.hpp:43
FloatNum c
Offset.
Definition view.hpp:269
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition offset.hpp:124
FloatNum med(void) const
Return median of domain (closest representation)
Definition offset.hpp:74
FloatNum max(void) const
Return maximum of domain.
Definition offset.hpp:70
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition offset.hpp:111
FloatNum min(void) const
Return minimum of domain.
Definition offset.hpp:66
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition offset.hpp:93
FloatNum offset(void) const
Return offset.
Definition offset.hpp:54
Scale float view.
Definition view.hpp:395
FloatVal scale(void) const
Return scale factor of scale view.
Definition scale.hpp:54
void update(Space &home, ScaleView &y)
Definition scale.hpp:179
FloatVal a
Scale factor.
Definition view.hpp:399
bool zero_in(void) const
Test whether 0 is contained in domain.
Definition scale.hpp:89
FloatNum min(void) const
Return minimum of domain.
Definition scale.hpp:62
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
Definition scale.hpp:107
bool operator<(const ScaleView &y) const
Whether this view comes before view y (arbitray order)
Definition scale.hpp:189
FloatNum size(void) const
Return size of domain (distance between maximum and minimum)
Definition scale.hpp:79
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Definition scale.hpp:123
FloatNum med(void) const
Return median of domain (closest representation)
Definition scale.hpp:70
ScaleView(void)
Default constructor.
Definition scale.hpp:43
bool in(FloatNum n) const
Test whether n is contained in domain.
Definition scale.hpp:93
FloatVal val(void) const
Return assigned value.
Definition scale.hpp:74
FloatVal domain(void) const
Return domain.
Definition scale.hpp:58
FloatNum max(void) const
Return maximum of domain.
Definition scale.hpp:66
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Definition scale.hpp:139
Computation spaces.
Definition core.hpp:1744
static ModEvent me(const ModEventDelta &med)
Definition view.hpp:552
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
double FloatNum
Floating point number base type.
Definition float.hh:106
Floating point numbers.
RelTest
Result of testing relation.
Definition view.hpp:533
@ RT_TRUE
Relation does hold.
Definition view.hpp:536
@ RT_FALSE
Relation does not hold.
Definition view.hpp:534
@ RT_MAYBE
Relation may hold or not.
Definition view.hpp:535
bool operator!=(const MinusView &x, const MinusView &y)
Definition minus.hpp:169
RelTest rtest_le(View x, View y)
Test whether view x is less than view y.
Definition rel-test.hpp:70
RelTest rtest_eq(View x, View y)
Test whether views x and y are equal.
Definition rel-test.hpp:40
bool operator==(const MinusView &x, const MinusView &y)
Definition minus.hpp:165
RelTest rtest_lq(View x, View y)
Test whether view x is less or equal than view y.
Definition rel-test.hpp:54
std::basic_ostream< Char, Traits > & operator<<(std::basic_ostream< Char, Traits > &os, const FloatView &x)
Definition print.hpp:58
RelTest
Result of testing relation.
Definition view.hpp:1734
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:773
Post propagator for SetVar x
Definition set.hh:773
int ModEvent
Type for modification events.
Definition core.hpp:62