Generated on Tue Mar 24 2020 14:04:04 for Gecode by doxygen 1.8.17
arithmetic.hh
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  * Guido Tack <tack@gecode.org>
6  * Vincent Barichard <Vincent.Barichard@univ-angers.fr>
7  *
8  * Copyright:
9  * Christian Schulte, 2002
10  * Guido Tack, 2004
11  * Vincent Barichard, 2012
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_FLOAT_ARITHMETIC_HH__
39 #define __GECODE_FLOAT_ARITHMETIC_HH__
40 
41 #include <gecode/int.hh>
42 #include <gecode/float.hh>
43 #include <gecode/float/rel.hh>
44 
50 namespace Gecode { namespace Float { namespace Arithmetic {
51 
57  template<class VA, class VB>
58  class SqrPlus : public MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND> {
59  protected:
63  SqrPlus(Home home, VA x0, VB x1);
65  SqrPlus(Space& home, SqrPlus<VA,VB>& p);
66  public:
68  static ExecStatus post(Home home, VA x0, VB x1);
70  virtual Actor* copy(Space& home);
72  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
73  };
74 
81  template<class View>
82  class Sqr : public BinaryPropagator<View,PC_FLOAT_BND> {
83  protected:
86 
88  Sqr(Space& home, Sqr& p);
90  Sqr(Home home, View x0, View x1);
91  public:
93  virtual Actor* copy(Space& home);
95  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
97  static ExecStatus post(Home home, View x0, View x1);
98  };
99 
108  template<class A, class B>
109  class Sqrt : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
110  protected:
113 
115  Sqrt(Space& home, Sqrt& p);
117  Sqrt(Home home, A x0, B x1);
118  public:
120  virtual Actor* copy(Space& home);
122  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
124  static ExecStatus post(Home home, A x0, B x1);
125  };
126 
135  template<class A, class B>
136  class Abs : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
137  protected:
140 
142  Abs(Space& home, Abs& p);
144  Abs(Home home, A x0, B x1);
145  public:
147  Abs(Space& home, Propagator& p, A x0, B x1);
149  virtual Actor* copy(Space& home);
151  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
153  static ExecStatus post(Home home, A x0, B x1);
154  };
155 
164  template<class A, class B>
165  class Pow : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
166  protected:
169  int m_n;
170 
172  Pow(Space& home, Pow& p);
174  Pow(Home home, A x0, B x1, int n);
175  public:
177  virtual Actor* copy(Space& home);
179  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
181  static ExecStatus post(Home home, A x0, B x1, int n);
182  };
183 
192  template<class A, class B>
193  class NthRoot : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
194  protected:
197  int m_n;
198 
200  NthRoot(Space& home, NthRoot& p);
202  NthRoot(Home home, A x0, B x1, int n);
203  public:
205  virtual Actor* copy(Space& home);
207  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
209  static ExecStatus post(Home home, A x0, B x1, int n);
210  };
211 
218  template<class View>
219  class MultZeroOne : public BinaryPropagator<View,PC_FLOAT_BND> {
220  protected:
223 
227  MultZeroOne(Home home, View x0, View x1);
228  public:
230  virtual Actor* copy(Space& home);
232  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
234  static ExecStatus post(Home home, View x0, View x1);
235  };
236 
237 
243  template<class VA, class VB, class VC>
244  class MultPlus :
245  public MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND> {
246  protected:
250  public:
252  MultPlus(Home home, VA x0, VB x1, VC x2);
256  static ExecStatus post(Home home, VA x0, VB x1, VC x2);
258  virtual Actor* copy(Space& home);
260  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
261  };
262 
270  template<class View>
271  class Mult : public TernaryPropagator<View,PC_FLOAT_BND> {
272  protected:
276 
278  Mult(Space& home, Mult<View>& p);
279  public:
281  Mult(Home home, View x0, View x1, View x2);
283  static ExecStatus post(Home home, View x0, View x1, View x2);
285  virtual Actor* copy(Space& home);
287  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
288  };
289 
290 
299  template<class A, class B, class C>
300  class Div : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
301  protected:
306  Div(Space& home, Div& p);
308  Div(Home home, A x0, B x1, C x2);
309  public:
311  virtual Actor* copy(Space& home);
313  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
315  static ExecStatus post(Home home, A x0, B x1, C x2);
316  };
317 
326  template<class A, class B, class C>
327  class Min : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
328  protected:
333  Min(Space& home, Min& p);
335  Min(Home home, A x0, B x1, C x2);
336  public:
338  Min(Space& home, Propagator& p, A x0, B x1, C x2);
340  virtual Actor* copy(Space& home);
342  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
344  static ExecStatus post(Home home, A x0, B x1, C x2);
345  };
346 
355  template<class A, class B, class C>
356  class Max : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
357  protected:
362  Max(Space& home, Max& p);
364  Max(Home home, A x0, B x1, C x2);
365  public:
367  Max(Space& home, Propagator& p, A x0, B x1, C x2);
369  virtual Actor* copy(Space& home);
371  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
373  static ExecStatus post(Home home, A x0, B x1, C x2);
374  };
375 
382  template<class View>
383  class NaryMax : public NaryOnePropagator<View,PC_FLOAT_BND> {
384  protected:
387 
389  NaryMax(Space& home, NaryMax& p);
391  NaryMax(Home home, ViewArray<View>& x, View y);
392  public:
394  virtual Actor* copy(Space& home);
396  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
398  static ExecStatus post(Home home, ViewArray<View>& x, View y);
399  };
400 
401 }}}
402 
409 
410 #endif
411 
412 // STATISTICS: float-prop
static ExecStatus post(Home home, View x0, View x1)
Post propagator .
Definition: mult.hpp:69
NthRoot(Space &home, NthRoot &p)
Constructor for cloning p.
Definition: pow-nroot.hpp:145
static ExecStatus post(Home home, VA x0, VB x1)
Post propagator .
Definition: sqr-sqrt.hpp:51
int m_n
Definition: arithmetic.hh:197
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition: pow-nroot.hpp:49
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: mult.hpp:150
MultPlus(Home home, VA x0, VB x1, VC x2)
Constructor for posting.
Definition: mult.hpp:138
VB x1
View of type View1.
Definition: pattern.hpp:242
Propagator for bounds division operator
Definition: arithmetic.hh:300
View x1
Definition: pattern.hpp:116
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: mult.hpp:107
MultZeroOne(Space &home, MultZeroOne< View > &p)
Constructor for cloning p.
Definition: mult.hpp:96
Propagator for bounds consistent square root operator
Definition: arithmetic.hh:109
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: abs.hpp:66
Propagator for bounds consistent max operator
Definition: arithmetic.hh:356
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: abs.hpp:72
Propagator for bounds consistent min operator
Definition: arithmetic.hh:327
View y
Single view.
Definition: pattern.hpp:177
VA x0
View of type View0.
Definition: pattern.hpp:207
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: sqr-sqrt.hpp:191
Max(Space &home, Max &p)
Constructor for cloning p.
Definition: min-max.hpp:103
VA x0
View of type View0.
Definition: pattern.hpp:240
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: min-max.hpp:242
Div(Space &home, Div &p)
Constructor for cloning p.
Definition: div.hpp:49
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: sqr-sqrt.hpp:71
Computation spaces.
Definition: core.hpp:1742
Base-class for both propagators and branchers.
Definition: core.hpp:628
Sqr(Space &home, Sqr &p)
Constructor for cloning p.
Definition: sqr-sqrt.hpp:125
ViewArray< View > x
Array of views.
Definition: pattern.hpp:175
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator .
Definition: mult.hpp:314
Mixed ternary propagator.
Definition: pattern.hpp:237
SqrPlus(Home home, VA x0, VB x1)
Constructor for posting.
Definition: sqr-sqrt.hpp:46
VB x1
View of type View1.
Definition: pattern.hpp:209
Propagator for bounds consistent square operator
Definition: arithmetic.hh:82
View x2
Definition: pattern.hpp:116
Gecode toplevel namespace
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: min-max.hpp:114
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: mult.hpp:195
Base-class for propagators.
Definition: core.hpp:1064
Mixed binary propagator.
Definition: pattern.hpp:204
Sqrt(Space &home, Sqrt &p)
Constructor for cloning p.
Definition: sqr-sqrt.hpp:186
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: mult.hpp:201
Abs(Space &home, Abs &p)
Constructor for cloning p.
Definition: abs.hpp:61
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: pow-nroot.hpp:156
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: sqr-sqrt.hpp:197
Home class for posting propagators
Definition: core.hpp:856
Ternary propagator.
Definition: pattern.hpp:113
Mult(Space &home, Mult< View > &p)
Constructor for cloning p.
Definition: mult.hpp:190
(n+1)-ary propagator
Definition: pattern.hpp:172
Bounds or domain consistent propagator for .
Definition: arithmetic.hh:219
Propagator for bounds consistent pow operator
Definition: arithmetic.hh:165
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: pow-nroot.hpp:89
View x1
Definition: pattern.hpp:87
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: mult.hpp:156
View x0
Three views.
Definition: pattern.hpp:116
Bounds consistent n-ary maximum propagator.
Definition: arithmetic.hh:383
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1075
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition: abs.hpp:47
static ExecStatus post(Home home, VA x0, VB x1, VC x2)
Post propagator .
Definition: mult.hpp:169
static ExecStatus post(Home home, ViewArray< View > &x, View y)
Post propagator .
Definition: min-max.hpp:155
Pow(Space &home, Pow &p)
Constructor for cloning p.
Definition: pow-nroot.hpp:84
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition: div.hpp:60
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: pow-nroot.hpp:95
VC x2
View of type View2.
Definition: pattern.hpp:244
Bounds consistent positive multiplication propagator.
Definition: arithmetic.hh:244
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition: sqr-sqrt.hpp:170
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition: min-max.hpp:68
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: sqr-sqrt.hpp:130
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: min-max.hpp:187
Bounds consistent positive square propagator.
Definition: arithmetic.hh:58
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: sqr-sqrt.hpp:77
Min(Space &home, Min &p)
Constructor for cloning p.
Definition: min-max.hpp:51
Propagator for bounds consistent nth root operator
Definition: arithmetic.hh:193
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: div.hpp:54
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: min-max.hpp:78
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: min-max.hpp:130
View arrays.
Definition: array.hpp:253
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: div.hpp:69
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: sqr-sqrt.hpp:136
int m_n
Definition: arithmetic.hh:169
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: min-max.hpp:62
Binary propagator.
Definition: pattern.hpp:84
Propagator for bounds consistent absolute operator
Definition: arithmetic.hh:136
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition: min-max.hpp:120
static ExecStatus post(Home home, View x0, View x1)
Post propagator for .
Definition: sqr-sqrt.hpp:105
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: pow-nroot.hpp:150
View x0
Two views.
Definition: pattern.hpp:87
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
NaryMax(Space &home, NaryMax &p)
Constructor for cloning p.
Definition: min-max.hpp:182
Bounds consistent multiplication propagator.
Definition: arithmetic.hh:271
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition: pow-nroot.hpp:134
ExecStatus
Definition: core.hpp:472
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: mult.hpp:101