Generated on Sat Feb 7 2015 02:01:14 for Gecode by doxygen 1.8.9.1
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  * Last modified:
14  * $Date: 2013-02-14 16:29:11 +0100 (Thu, 14 Feb 2013) $ by $Author: schulte $
15  * $Revision: 13292 $
16  *
17  * This file is part of Gecode, the generic constraint
18  * development environment:
19  * http://www.gecode.org
20  *
21  * Permission is hereby granted, free of charge, to any person obtaining
22  * a copy of this software and associated documentation files (the
23  * "Software"), to deal in the Software without restriction, including
24  * without limitation the rights to use, copy, modify, merge, publish,
25  * distribute, sublicense, and/or sell copies of the Software, and to
26  * permit persons to whom the Software is furnished to do so, subject to
27  * the following conditions:
28  *
29  * The above copyright notice and this permission notice shall be
30  * included in all copies or substantial portions of the Software.
31  *
32  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39  *
40  */
41 
42 #ifndef __GECODE_FLOAT_ARITHMETIC_HH__
43 #define __GECODE_FLOAT_ARITHMETIC_HH__
44 
45 #include <gecode/int.hh>
46 #include <gecode/float.hh>
47 #include <gecode/float/rel.hh>
48 
54 namespace Gecode { namespace Float { namespace Arithmetic {
55 
61  template<class VA, class VB>
62  class SqrPlus : public MixBinaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND> {
63  protected:
67  SqrPlus(Home home, VA x0, VB x1);
69  SqrPlus(Space& home, bool share, SqrPlus<VA,VB>& p);
70  public:
72  static ExecStatus post(Home home, VA x0, VB x1);
74  virtual Actor* copy(Space& home, bool share);
76  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
77  };
78 
85  template<class View>
86  class Sqr : public BinaryPropagator<View,PC_FLOAT_BND> {
87  protected:
90 
92  Sqr(Space& home, bool share, Sqr& p);
94  Sqr(Home home, View x0, View x1);
95  public:
97  virtual Actor* copy(Space& home, bool share);
99  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
101  static ExecStatus post(Home home, View x0, View x1);
102  };
103 
112  template<class A, class B>
113  class Sqrt : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
114  protected:
117 
119  Sqrt(Space& home, bool share, Sqrt& p);
121  Sqrt(Home home, A x0, B x1);
122  public:
124  virtual Actor* copy(Space& home, bool share);
126  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
128  static ExecStatus post(Home home, A x0, B x1);
129  };
130 
139  template<class A, class B>
140  class Abs : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
141  protected:
144 
146  Abs(Space& home, bool share, Abs& p);
148  Abs(Home home, A x0, B x1);
149  public:
151  Abs(Space& home, bool share, Propagator& p, A x0, B x1);
153  virtual Actor* copy(Space& home, bool share);
155  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
157  static ExecStatus post(Home home, A x0, B x1);
158  };
159 
168  template<class A, class B>
169  class Pow : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
170  protected:
173  int m_n;
174 
176  Pow(Space& home, bool share, Pow& p);
178  Pow(Home home, A x0, B x1, int n);
179  public:
181  virtual Actor* copy(Space& home, bool share);
183  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
185  static ExecStatus post(Home home, A x0, B x1, int n);
186  };
187 
196  template<class A, class B>
197  class NthRoot : public MixBinaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND> {
198  protected:
201  int m_n;
202 
204  NthRoot(Space& home, bool share, NthRoot& p);
206  NthRoot(Home home, A x0, B x1, int n);
207  public:
209  virtual Actor* copy(Space& home, bool share);
211  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
213  static ExecStatus post(Home home, A x0, B x1, int n);
214  };
215 
222  template<class View>
223  class MultZeroOne : public BinaryPropagator<View,PC_FLOAT_BND> {
224  protected:
227 
229  MultZeroOne(Space& home, bool share, MultZeroOne<View>& p);
231  MultZeroOne(Home home, View x0, View x1);
232  public:
234  virtual Actor* copy(Space& home, bool share);
236  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
238  static ExecStatus post(Home home, View x0, View x1);
239  };
240 
241 
247  template<class VA, class VB, class VC>
248  class MultPlus :
249  public MixTernaryPropagator<VA,PC_FLOAT_BND,VB,PC_FLOAT_BND,VC,PC_FLOAT_BND> {
250  protected:
254  public:
256  MultPlus(Home home, VA x0, VB x1, VC x2);
258  MultPlus(Space& home, bool share, MultPlus<VA,VB,VC>& p);
260  static ExecStatus post(Home home, VA x0, VB x1, VC x2);
262  virtual Actor* copy(Space& home, bool share);
264  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
265  };
266 
274  template<class View>
275  class Mult : public TernaryPropagator<View,PC_FLOAT_BND> {
276  protected:
280 
282  Mult(Space& home, bool share, Mult<View>& p);
283  public:
285  Mult(Home home, View x0, View x1, View x2);
287  static ExecStatus post(Home home, View x0, View x1, View x2);
289  virtual Actor* copy(Space& home, bool share);
291  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
292  };
293 
294 
303  /*
304  template<class A, class B, class C>
305  class Mult : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
306  protected:
307  using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x0;
308  using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x1;
309  using MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND>::x2;
311  Mult(Space& home, bool share, Mult& p);
313  Mult(Home home, A x0, B x1, C x2);
314  public:
316  virtual Actor* copy(Space& home, bool share);
318  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
320  static ExecStatus post(Home home, A x0, B x1, C x2);
321  };
322  */
323 
332  template<class A, class B, class C>
333  class Div : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
334  protected:
339  Div(Space& home, bool share, Div& p);
341  Div(Home home, A x0, B x1, C x2);
342  public:
344  virtual Actor* copy(Space& home, bool share);
346  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
348  static ExecStatus post(Home home, A x0, B x1, C x2);
349  };
350 
359  template<class A, class B, class C>
360  class Min : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
361  protected:
366  Min(Space& home, bool share, Min& p);
368  Min(Home home, A x0, B x1, C x2);
369  public:
371  Min(Space& home, bool share, Propagator& p, A x0, B x1, C x2);
373  virtual Actor* copy(Space& home, bool share);
375  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
377  static ExecStatus post(Home home, A x0, B x1, C x2);
378  };
379 
388  template<class A, class B, class C>
389  class Max : public MixTernaryPropagator<A,PC_FLOAT_BND,B,PC_FLOAT_BND,C,PC_FLOAT_BND> {
390  protected:
395  Max(Space& home, bool share, Max& p);
397  Max(Home home, A x0, B x1, C x2);
398  public:
400  Max(Space& home, bool share, Propagator& p, A x0, B x1, C x2);
402  virtual Actor* copy(Space& home, bool share);
404  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
406  static ExecStatus post(Home home, A x0, B x1, C x2);
407  };
408 
415  template<class View>
416  class NaryMax : public NaryOnePropagator<View,PC_FLOAT_BND> {
417  protected:
420 
422  NaryMax(Space& home, bool share, NaryMax& p);
424  NaryMax(Home home, ViewArray<View>& x, View y);
425  public:
427  virtual Actor* copy(Space& home, bool share);
429  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
431  static ExecStatus post(Home home, ViewArray<View>& x, View y);
432  };
433 
440  template<class A, class B>
441  class Channel :
442  public MixBinaryPropagator<A,PC_FLOAT_BND,B,Gecode::Int::PC_INT_BND> {
443  protected:
446 
448  Channel(Space& home, bool share, Channel& p);
450  Channel(Home home, A x0, B x1);
451  public:
453  virtual Actor* copy(Space& home, bool share);
455  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
457  static ExecStatus post(Home home, A x0, B x1);
458  };
459 
460 }}}
461 
467 
468 #endif
469 
470 // STATISTICS: float-prop
static ExecStatus post(Home home, ViewArray< View > &x, View y)
Post propagator .
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Propagator for bounds consistent max operator
Definition: arithmetic.hh:389
Channel(Space &home, bool share, Channel &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: pow-nroot.hpp:158
Max(Space &home, bool share, Max &p)
Constructor for cloning p.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
ViewArray< View > x
Array of views.
Definition: propagator.hpp:175
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: div.hpp:71
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: mult.hpp:156
Sqrt(Space &home, bool share, Sqrt &p)
Constructor for cloning p.
Base-class for propagators.
Definition: core.hpp:755
MultPlus(Home home, VA x0, VB x1, VC x2)
Constructor for posting.
Definition: mult.hpp:143
Bounds consistent positive multiplication propagator.
Definition: arithmetic.hh:248
Pow(Space &home, bool share, Pow &p)
Constructor for cloning p.
Definition: pow-nroot.hpp:88
Sqr(Space &home, bool share, Sqr &p)
Constructor for cloning p.
Computation spaces.
Definition: core.hpp:1362
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Base-class for both propagators and branchers.
Definition: core.hpp:666
Mult(Space &home, bool share, Mult< View > &p)
Constructor for cloning p.
Definition: mult.hpp:196
static ExecStatus post(Home home, View x0, View x1)
Post propagator .
Definition: mult.hpp:73
static ExecStatus post(Home home, View x0, View x1)
Post propagator for .
NthRoot(Space &home, bool share, NthRoot &p)
Constructor for cloning p.
Definition: pow-nroot.hpp:147
Propagator for bounds consistent integer part operator
Definition: arithmetic.hh:441
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, VA x0, VB x1)
Post propagator .
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Bounds consistent positive square propagator.
Definition: arithmetic.hh:62
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Propagator for bounds consistent square operator
Definition: arithmetic.hh:86
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Propagator for bounds consistent pow operator
Definition: arithmetic.hh:169
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Binary propagator.
Definition: propagator.hpp:87
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition: pow-nroot.hpp:138
Mixed ternary propagator.
Definition: propagator.hpp:235
Bounds or domain consistent propagator for .
Definition: arithmetic.hh:223
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: mult.hpp:162
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:764
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Propagator for bounds consistent square root operator
Definition: arithmetic.hh:113
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: mult.hpp:112
Ternary propagator.
Definition: propagator.hpp:115
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition: pow-nroot.hpp:53
(n+1)-ary propagator
Definition: propagator.hpp:172
Bounds consistent multiplication propagator.
Definition: arithmetic.hh:275
Propagator for bounds consistent absolute operator
Definition: arithmetic.hh:140
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Abs(Space &home, bool share, Abs &p)
Constructor for cloning p.
View arrays.
Definition: array.hpp:234
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Definition: pow-nroot.hpp:152
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
MultZeroOne(Space &home, bool share, MultZeroOne< View > &p)
Constructor for cloning p.
Definition: mult.hpp:100
static ExecStatus post(Home home, VA x0, VB x1, VC x2)
Post propagator .
Definition: mult.hpp:175
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Mixed binary propagator.
Definition: propagator.hpp:203
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ExecStatus
Definition: core.hpp:523
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Div(Space &home, bool share, Div &p)
Constructor for cloning p.
Definition: div.hpp:53
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Definition: pow-nroot.hpp:93
NaryMax(Space &home, bool share, NaryMax &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: mult.hpp:207
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition: div.hpp:64
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator .
Definition: mult.hpp:320
Gecode toplevel namespace
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: pow-nroot.hpp:99
Propagator for bounds multiplication operator
Definition: arithmetic.hh:333
virtual Actor * copy(Space &home, bool share)
Create copy during cloning.
Definition: div.hpp:58
Bounds consistent n-ary maximum propagator.
Definition: arithmetic.hh:416
int ModEventDelta
Modification event deltas.
Definition: core.hpp:173
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Home class for posting propagators
Definition: core.hpp:717
Propagator for bounds consistent min operator
Definition: arithmetic.hh:360
Propagator for bounds consistent nth root operator
Definition: arithmetic.hh:197
Min(Space &home, bool share, Min &p)
Constructor for cloning p.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: mult.hpp:106
SqrPlus(Home home, VA x0, VB x1)
Constructor for posting.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: mult.hpp:201