Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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
50namespace 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);
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
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
Base-class for both propagators and branchers.
Definition core.hpp:628
Binary propagator.
Definition pattern.hpp:84
Propagator for bounds consistent absolute operator
Abs(Space &home, Abs &p)
Constructor for cloning p.
Definition abs.hpp:61
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition abs.hpp:47
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition abs.hpp:72
Abs(Space &home, Propagator &p, A x0, B x1)
Constructor for rewriting p during cloning.
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition abs.hpp:66
Propagator for bounds division operator
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition div.hpp:54
Div(Space &home, Div &p)
Constructor for cloning p.
Definition div.hpp:49
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition div.hpp:69
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition div.hpp:60
Propagator for bounds consistent max operator
static ExecStatus post(Home home, A x0, B x1, C x2)
Post propagator for .
Definition min-max.hpp:120
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition min-max.hpp:114
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition min-max.hpp:130
Max(Space &home, Max &p)
Constructor for cloning p.
Definition min-max.hpp:103
Propagator for bounds consistent min operator
Min(Space &home, Min &p)
Constructor for cloning p.
Definition min-max.hpp:51
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 min-max.hpp:62
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition min-max.hpp:78
Bounds consistent positive multiplication propagator.
static ExecStatus post(Home home, VA x0, VB x1, VC x2)
Post propagator .
Definition mult.hpp:169
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition mult.hpp:150
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition mult.hpp:156
MultPlus(Home home, VA x0, VB x1, VC x2)
Constructor for posting.
Definition mult.hpp:138
Bounds or domain consistent propagator for .
static ExecStatus post(Home home, View x0, View x1)
Post propagator .
Definition mult.hpp:69
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition mult.hpp:107
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition mult.hpp:101
MultZeroOne(Space &home, MultZeroOne< View > &p)
Constructor for cloning p.
Definition mult.hpp:96
Bounds consistent multiplication propagator.
static ExecStatus post(Home home, View x0, View x1, View x2)
Post propagator .
Definition mult.hpp:314
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition mult.hpp:195
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition mult.hpp:201
Mult(Space &home, Mult< View > &p)
Constructor for cloning p.
Definition mult.hpp:190
Bounds consistent n-ary maximum propagator.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition min-max.hpp:187
static ExecStatus post(Home home, ViewArray< View > &x, View y)
Post propagator .
Definition min-max.hpp:155
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition min-max.hpp:242
NaryMax(Space &home, NaryMax &p)
Constructor for cloning p.
Definition min-max.hpp:182
Propagator for bounds consistent nth root operator
NthRoot(Space &home, NthRoot &p)
Constructor for cloning p.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home)
Create copy during cloning.
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Propagator for bounds consistent pow operator
static ExecStatus post(Home home, A x0, B x1, int n)
Post propagator for .
Definition pow-nroot.hpp:49
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition pow-nroot.hpp:95
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition pow-nroot.hpp:89
Pow(Space &home, Pow &p)
Constructor for cloning p.
Definition pow-nroot.hpp:84
Bounds consistent positive square propagator.
Definition arithmetic.hh:58
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sqr-sqrt.hpp:77
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition sqr-sqrt.hpp:71
SqrPlus(Home home, VA x0, VB x1)
Constructor for posting.
Definition sqr-sqrt.hpp:46
static ExecStatus post(Home home, VA x0, VB x1)
Post propagator .
Definition sqr-sqrt.hpp:51
Propagator for bounds consistent square operator
Definition arithmetic.hh:82
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition sqr-sqrt.hpp:130
static ExecStatus post(Home home, View x0, View x1)
Post propagator for .
Definition sqr-sqrt.hpp:105
Sqr(Space &home, Sqr &p)
Constructor for cloning p.
Definition sqr-sqrt.hpp:125
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition sqr-sqrt.hpp:136
Propagator for bounds consistent square root operator
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 sqr-sqrt.hpp:197
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition sqr-sqrt.hpp:170
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition sqr-sqrt.hpp:191
Home class for posting propagators
Definition core.hpp:856
Mixed binary propagator.
Definition pattern.hpp:204
Mixed ternary propagator.
Definition pattern.hpp:237
(n+1)-ary propagator
Definition pattern.hpp:172
Base-class for propagators.
Definition core.hpp:1064
ModEventDelta med
A set of modification events (used during propagation)
Definition core.hpp:1075
Computation spaces.
Definition core.hpp:1742
Ternary propagator.
Definition pattern.hpp:113
View arrays.
Definition array.hpp:253
int ModEventDelta
Modification event deltas.
Definition core.hpp:89
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
Definition var-type.hpp:292
Gecode toplevel namespace
ExecStatus
Definition core.hpp:472