Generated on for Gecode by doxygen 1.17.0
arithmetic.cpp
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.dev>
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.dev
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 "test/float.hh"
37
38#include <gecode/minimodel.hh>
39
40#include <cmath>
41#include <algorithm>
42#include <cfenv>
43#include <limits>
44
45namespace Test { namespace Float {
46
48 namespace Arithmetic {
49
55
56 class RoundingScope : public Base {
57 private:
58 template<class Policy>
59 static bool boost_operations(void) {
60 typedef boost::numeric::interval<Gecode::FloatNum,
61 boost::numeric::interval_lib::policies<Policy,
62 boost::numeric::interval_lib::checking_strict<
63 Gecode::FloatNum>>> Interval;
64 const int mode = std::fegetround();
65 // Boost fmod uses its unprotected policy for nested arithmetic.
66 const Interval remainder = boost::numeric::fmod(
67 Interval(5.0,5.0),Interval(3.0,3.0));
68 bool result = (remainder.lower() == 2.0) &&
69 (remainder.upper() == 2.0) && (std::fegetround() == mode);
70#ifdef GECODE_HAS_MPFR
71 // Unprotected policies must retain Gecode's MPFR operations.
72 const Interval sine = boost::numeric::sin(Interval(0.5));
73 result &= (sine.lower() <= 0.479425538604203) &&
74 (sine.upper() >= 0.479425538604203) &&
75 (std::fegetround() == mode);
76#endif
77 return result;
78 }
79 public:
81 : Base("Float::Arithmetic::RoundingScope", TestTags::check()) {}
82 virtual bool run(void) {
83 const int previous = std::fegetround();
84 const int modes[] = {
85 FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO
86 };
87 bool result = true;
88 for (int mode : modes) {
89 if (std::fesetround(mode) != 0)
90 continue;
91 {
93 const volatile Gecode::FloatNum one = 1.0;
94 const volatile Gecode::FloatNum half_ulp = std::ldexp(1.0,-53);
95 const Gecode::FloatNum lower = outer.add_down(one,half_ulp);
96 const Gecode::FloatNum upper = outer.add_up(one,half_ulp);
97 result &= (lower == 1.0) &&
98 (upper == std::nextafter(1.0,2.0));
99 const int enclosing = std::fegetround();
100 {
102 result &= inner.median(1.0,3.0) == 2.0;
103 }
104 result &= std::fegetround() == enclosing;
105 result &= boost_operations<Gecode::Float::Rounding>();
106 result &= boost_operations<
107 boost::numeric::interval_lib::save_state<
109 }
110 if (std::fegetround() != mode) {
111 olog << "Rounding scope changed caller mode " << mode
112 << std::endl;
113 result = false;
114 }
115 }
116 if (previous != -1)
117 std::fesetround(previous);
118 return result;
119 }
121
123 class DirectedRounding : public Base {
124 protected:
126 class RootSpace : public Gecode::Space {
127 public:
132 : source(*this,lo,hi), root(*this,0.0,1.0) {
133 Gecode::nroot(*this,source,2,root);
134 }
135
137 source.update(*this,s.source);
138 root.update(*this,s.root);
139 }
140
141 virtual Gecode::Space* copy(void) {
142 return new RootSpace(*this);
143 }
144 };
145 public:
147 : Base("Float::Arithmetic::DirectedRounding", TestTags::check()) {}
148 virtual bool run(void) {
149 bool result = true;
150 {
151 // Each exact result lies strictly between two adjacent doubles.
152 const volatile Gecode::FloatNum root_two = 0x1.6a09e667f3bccp+0;
153 const volatile Gecode::FloatNum one = 1.0;
154 const volatile Gecode::FloatNum three = 3.0;
155 const volatile Gecode::FloatNum quarter_ulp = std::ldexp(1.0,-54);
157 if ((r.mul_down(root_two,root_two) != 0x1.ffffffffffffep+0) ||
158 (r.mul_up(root_two,root_two) != 0x1.fffffffffffffp+0) ||
159 (r.div_down(one,three) != 0x1.5555555555555p-2) ||
160 (r.div_up(one,three) != 0x1.5555555555556p-2) ||
161 (r.add_down(one,-quarter_ulp) != 0x1.fffffffffffffp-1) ||
162 (r.add_up(one,-quarter_ulp) != 1.0)) {
163 olog << "Rounding operation was not directed" << std::endl;
164 result = false;
165 }
166 }
167 // Parallel search on examples/cartesian-heart reached this domain.
168 // A wrong mul_down made the root iteration create an empty interval.
169 RootSpace s(0x1p-1016,0x1p-1015);
170 if ((s.status() == Gecode::SS_FAILED) ||
171 (s.root.min() > 0x1p-508) ||
172 (s.root.max() < 0x1.6a09e667f3bcdp-508)) {
173 olog << "NthRoot removed the root of " << s.source << std::endl;
174 result = false;
175 }
176 return result;
177 }
179
181 class MedianRoundingMode : public Base {
182 public:
184 : Base("Float::Arithmetic::MedianRoundingMode", TestTags::check()) {}
185 virtual bool run(void) {
186 const int previous = std::fegetround();
187 const int modes[] = {
188 FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO
189 };
190 const Gecode::FloatNum limit =
191 std::numeric_limits<Gecode::FloatNum>::max();
192#if !defined(__FINITE_MATH_ONLY__) || !__FINITE_MATH_ONLY__
193 const Gecode::FloatNum infinity =
194 std::numeric_limits<Gecode::FloatNum>::infinity();
195#endif
196 const Gecode::FloatNum cases[][3] = {
197 {1.0,3.0,2.0}, {-3.0,-1.0,-2.0}, {-limit,limit,0.0},
198 {limit,limit,limit}, {-limit,-limit,-limit},
199 // Finite-math builds do not support infinite inputs.
200#if !defined(__FINITE_MATH_ONLY__) || !__FINITE_MATH_ONLY__
201 {-infinity,infinity,0.0}
202#endif
203 };
204 bool result = true;
205 for (int mode : modes)
206 for (const auto& c : cases) {
207 const Gecode::FloatVal value(c[0],c[1]);
208 if (std::fesetround(mode) != 0)
209 continue;
210 volatile Gecode::FloatNum direct;
211 {
213 direct = r.median(c[0],c[1]);
214 }
215 if ((std::fegetround() != mode) || (direct != c[2])) {
216 olog << "Direct median changed its result or rounding mode "
217 << mode << std::endl;
218 result = false;
219 }
220 const volatile Gecode::FloatNum median = value.med();
221 if ((std::fegetround() != mode) || (median != c[2])) {
222 olog << "Median query changed its result or rounding mode "
223 << mode << std::endl;
224 result = false;
225 }
226 }
227 if (previous != -1)
228 std::fesetround(previous);
229 return result;
230 }
232
234 class PositiveNRootBounds : public Base {
235 protected:
237 class RootSpace : public Gecode::Space {
238 public:
243 bool usePow)
244 : x0(*this, 0.0, usePow ? witness : hi),
245 x1(*this, usePow ? 0.0 : witness, usePow ? hi : witness) {
246 if (usePow) {
247 Gecode::pow(*this,x0,n,x1);
248 Gecode::rel(*this,x0,Gecode::FRT_EQ,witness);
249 } else {
250 Gecode::nroot(*this,x0,n,x1);
251 }
252 }
253
255 x0.update(*this,s.x0);
256 x1.update(*this,s.x1);
257 }
258
259 virtual Gecode::Space* copy(void) {
260 return new RootSpace(*this);
261 }
262 };
263
266 public:
271 : source(*this,0.0,hi),
272 root(*this,0.0,Gecode::Float::Limits::max) {
273 Gecode::nroot(*this,source,n,root);
274 }
275
277 source.update(*this,s.source);
278 root.update(*this,s.root);
279 }
280
281 virtual Gecode::Space* copy(void) {
282 return new NRootBoundSpace(*this);
283 }
284 };
285
287 bool check(Gecode::FloatNum hi, Gecode::FloatNum witness, int n,
288 int mode, bool usePow) const {
289 if (std::fesetround(mode) != 0)
290 return true;
291 RootSpace s(hi,witness,n,usePow);
292 if (s.status() != Gecode::SS_FAILED)
293 return true;
294 olog << "Root bound removed a solution for "
295 << (usePow ? "pow" : "nroot") << ", n=" << n
296 << ", mode=" << mode << std::endl;
297 return false;
298 }
299
301 int n, int mode) const {
302 if (std::fesetround(mode) != 0)
303 return true;
304 NRootBoundSpace s(hi,n);
305 if ((s.status() != Gecode::SS_FAILED) &&
306 (s.root.max() > rejected))
307 return true;
308 olog << "NRoot upper bound was not outward for n=" << n
309 << ", mode=" << mode << std::endl;
310 return false;
311 }
312 public:
315 : Base("Float::Arithmetic::PositiveNRootBounds",
316 TestTags::check()) {}
317
318 virtual bool run(void) {
319 const int oldMode = std::fegetround();
320 const int modes[] = {
321 FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO
322 };
323 struct Case {
325 Gecode::FloatNum witness;
326 int n;
327 } cases[] = {
328 {std::ldexp(static_cast<Gecode::FloatNum>(0x156e1fc2f8f359ULL),
329 -1049),
330 std::ldexp(static_cast<Gecode::FloatNum>(0x14484bfeebc28cULL),
331 -152), 10},
332 {std::numeric_limits<Gecode::FloatNum>::denorm_min(),
333 std::ldexp(static_cast<Gecode::FloatNum>(0x18406003b2ae42ULL),
334 -160), 10},
335 {std::numeric_limits<Gecode::FloatNum>::max(),
336 std::ldexp(static_cast<Gecode::FloatNum>(0x1965fea53d6e0fULL),
337 118), 6}
338 };
339 bool result = true;
340 const Gecode::FloatNum roundingHi =
341 std::ldexp(static_cast<Gecode::FloatNum>(0x1751def03d6f38ULL),
342 458);
343 const Gecode::FloatNum rejectedUpper =
344 std::ldexp(static_cast<Gecode::FloatNum>(0x1350f4c43079ceULL),
345 203);
346 for (unsigned int m=0; m<sizeof(modes)/sizeof(modes[0]); m++) {
347 for (unsigned int c=0; c<sizeof(cases)/sizeof(cases[0]); c++) {
348 result = check(cases[c].hi,cases[c].witness,cases[c].n,
349 modes[m],false) && result;
350 result = check(cases[c].hi,cases[c].witness,cases[c].n,
351 modes[m],true) && result;
352 }
353 result = checkBound(roundingHi,rejectedUpper,2,modes[m]) && result;
354 }
355 if (oldMode != -1)
356 std::fesetround(oldMode);
357 return result;
358 }
360
362 class PowConsistency : public Base {
363 protected:
365 class ZeroSpace : public Gecode::Space {
366 public:
370 ZeroSpace(int n, bool direct)
371 : x(*this,direct ? 0.0 : -1.0,direct ? 0.0 : 1.0),
372 y(*this,-1.0,2.0) {
373 Gecode::pow(*this,x,n,y);
374 }
375
377 x.update(*this,s.x);
378 y.update(*this,s.y);
379 }
380
381 virtual Gecode::Space* copy(void) {
382 return new ZeroSpace(*this);
383 }
384 };
385
388 public:
392 AdjacentZeroSpace(bool positive)
393 : x(*this,
394 positive ? 0.0
395 : -std::numeric_limits<Gecode::FloatNum>::denorm_min(),
396 positive ? std::numeric_limits<Gecode::FloatNum>::denorm_min()
397 : -0.0),
398 y(*this,-1.0,2.0) {
399 Gecode::pow(*this,x,0,y);
400 }
401
403 x.update(*this,s.x);
404 y.update(*this,s.y);
405 }
406
407 virtual Gecode::Space* copy(void) {
408 return new AdjacentZeroSpace(*this);
409 }
410 };
411
414 public:
419 : x(*this,
420 -std::ldexp(static_cast<Gecode::FloatNum>
421 (0x10000000000006ULL),-53),
422 -std::ldexp(static_cast<Gecode::FloatNum>
423 (0x10000000000004ULL),-53)),
424 y(*this,
425 std::ldexp(static_cast<Gecode::FloatNum>
426 (0x1000000000000aULL),-54),
427 std::ldexp(static_cast<Gecode::FloatNum>
428 (0x1000000000000cULL),-54)) {
429 Gecode::pow(*this,x,2,y);
430 }
431
433 x.update(*this,s.x);
434 y.update(*this,s.y);
435 }
436
437 virtual Gecode::Space* copy(void) {
438 return new FixpointSpace(*this);
439 }
440 };
441
444 public:
448 ZeroResultSpace(int n, bool direct)
449 : x(*this,-1.0,1.0),
450 y(*this,direct ? 0.0 : -1.0,direct ? 0.0 : 1.0) {
451 Gecode::pow(*this,x,n,y);
452 }
453
455 x.update(*this,s.x);
456 y.update(*this,s.y);
457 }
458
459 virtual Gecode::Space* copy(void) {
460 return new ZeroResultSpace(*this);
461 }
462 };
463
465 bool checkZero(int n) const {
466 ZeroSpace direct(n,true);
467 ZeroSpace delayed(n,false);
468 if (delayed.status() == Gecode::SS_FAILED) {
469 olog << "Pow wide base failed for n=" << n << std::endl;
470 return false;
471 }
472 ZeroSpace* clone = static_cast<ZeroSpace*>(delayed.clone());
473 Gecode::rel(*clone,clone->x,Gecode::FRT_EQ,0.0);
474 if (n == 0) {
475 const bool zeroRejected =
476 (direct.status() == Gecode::SS_FAILED) &&
477 (clone->status() == Gecode::SS_FAILED);
478 delete clone;
479 ZeroSpace* nonZero = static_cast<ZeroSpace*>(delayed.clone());
480 Gecode::rel(*nonZero,nonZero->x,Gecode::FRT_EQ,0.5);
481 const bool nonZeroAccepted =
482 (nonZero->status() != Gecode::SS_FAILED) &&
483 (nonZero->y.min() == 1.0) && (nonZero->y.max() == 1.0);
484 delete nonZero;
485 if (!zeroRejected || !nonZeroAccepted)
486 olog << "Pow exponent-zero semantics failed" << std::endl;
487 return zeroRejected && nonZeroAccepted;
488 }
489 const bool result =
490 (direct.status() != Gecode::SS_FAILED) &&
491 (direct.y.min() == 0.0) && (direct.y.max() == 0.0) &&
492 (clone->status() != Gecode::SS_FAILED) &&
493 (clone->y.min() == 0.0) && (clone->y.max() == 0.0);
494 delete clone;
495 if (!result)
496 olog << "Pow delayed zero failed for n=" << n << std::endl;
497 return result;
498 }
499
500 bool checkZeroResult(int n, bool direct) const {
501 ZeroResultSpace initial(n,direct);
502 if (initial.status() == Gecode::SS_FAILED) {
503 olog << "Pow zero result failed for n=" << n << std::endl;
504 return false;
505 }
506 ZeroResultSpace* clone =
507 static_cast<ZeroResultSpace*>(initial.clone());
508 if (!direct)
509 Gecode::rel(*clone,clone->y,Gecode::FRT_EQ,0.0);
510 const bool contracted =
511 (clone->status() != Gecode::SS_FAILED) &&
512 (clone->x.min() == 0.0) && (clone->x.max() == 0.0);
513 Gecode::rel(*clone,clone->x,Gecode::FRT_EQ,1.0);
514 const bool inconsistentRejected =
515 clone->status() == Gecode::SS_FAILED;
516 delete clone;
517 if (!contracted || !inconsistentRejected)
518 olog << "Pow zero result did not force zero base for n=" << n
519 << (direct ? " (direct)" : " (delayed)") << std::endl;
520 return contracted && inconsistentRejected;
521 }
522
523 bool checkAdjacentZero(bool positive) const {
524 AdjacentZeroSpace initial(positive);
525 // Adjacent intervals are assigned and cannot be narrowed further.
526 // Keep the unresolved nonzero constraint through propagation and cloning.
527 const bool actorRetained =
528 (initial.status() != Gecode::SS_FAILED) &&
529 (initial.y.min() == 1.0) && (initial.y.max() == 1.0) &&
530 (Gecode::PropagatorGroup::all.size(initial) > 0);
531
532 AdjacentZeroSpace* clone =
533 static_cast<AdjacentZeroSpace*>(initial.clone());
534 const bool cloneRetained =
535 (clone->status() != Gecode::SS_FAILED) &&
536 (clone->y.min() == 1.0) && (clone->y.max() == 1.0) &&
537 (Gecode::PropagatorGroup::all.size(*clone) > 0);
538 delete clone;
539
540 if (!actorRetained || !cloneRetained)
541 olog << "Pow adjacent exponent-zero semantics failed"
542 << (positive ? " (positive)" : " (negative)") << std::endl;
543 return actorRetained && cloneRetained;
544 }
545 public:
548 : Base("Float::Arithmetic::PowConsistency",
549 TestTags::check()) {}
550
551 virtual bool run(void) {
552 bool result = true;
553 for (int n=0; n<=3; n++)
554 result = checkZero(n) && result;
555 for (int n=1; n<=3; n++) {
556 result = checkZeroResult(n,true) && result;
557 result = checkZeroResult(n,false) && result;
558 }
559 result = checkAdjacentZero(true) && result;
560 result = checkAdjacentZero(false) && result;
561
562 FixpointSpace once;
563 if (once.status() == Gecode::SS_FAILED) {
564 olog << "Pow fixpoint instance failed" << std::endl;
565 return false;
566 }
567 FixpointSpace* twice = static_cast<FixpointSpace*>(once.clone());
568 Gecode::pow(*twice,twice->x,2,twice->y);
569 const bool fixpoint =
570 (twice->status() != Gecode::SS_FAILED) &&
571 (once.x.min() == twice->x.min()) &&
572 (once.x.max() == twice->x.max()) &&
573 (once.y.min() == twice->y.min()) &&
574 (once.y.max() == twice->y.max());
575 delete twice;
576 if (!fixpoint)
577 olog << "Pow posting did not reach a fixpoint" << std::endl;
578 return fixpoint && result;
579 }
581
583 class MultZeroEndpoint : public Base {
584 protected:
586 class MultSpace : public Gecode::Space {
587 public:
594 : x(*this,xl,xu), y(*this,yl,yu), z(*this,zl,zu) {
595 Gecode::mult(*this,x,y,z);
596 }
597
599 x.update(*this,s.x);
600 y.update(*this,s.y);
601 z.update(*this,s.z);
602 }
603
604 virtual Gecode::Space* copy(void) {
605 return new MultSpace(*this);
606 }
607 };
608
613 Gecode::FloatNum expectedMin,
614 Gecode::FloatNum expectedMax) const {
615 MultSpace s(xl,xu,yl,yu,zl,zu);
616 if ((s.status() == Gecode::SS_FAILED) ||
617 (s.x.min() < expectedMin) || (s.x.max() > expectedMax)) {
618 olog << "Multiplication endpoint-zero contraction failed: x="
619 << s.x << ", y=" << s.y << ", z=" << s.z << std::endl;
620 return false;
621 }
622 MultSpace* clone = static_cast<MultSpace*>(s.clone());
623 Gecode::mult(*clone,clone->x,clone->y,clone->z);
624 const bool fixpoint =
625 (clone->status() != Gecode::SS_FAILED) &&
626 (clone->x.min() == s.x.min()) && (clone->x.max() == s.x.max()) &&
627 (clone->y.min() == s.y.min()) && (clone->y.max() == s.y.max()) &&
628 (clone->z.min() == s.z.min()) && (clone->z.max() == s.z.max());
629 delete clone;
630 if (!fixpoint)
631 olog << "Multiplication endpoint-zero case was not at a fixpoint"
632 << std::endl;
633 return fixpoint;
634 }
635
636 bool fuzz(void) const {
637 unsigned int state = 0x6d756c74U;
638 for (unsigned int i=0; i<5000; i++) {
639 state = state * 1664525U + 1013904223U;
640 const Gecode::FloatNum am =
641 0.125 + static_cast<Gecode::FloatNum>((state >> 8) % 8000) /
642 512.0;
643 state = state * 1664525U + 1013904223U;
644 const Gecode::FloatNum bm =
645 0.125 + static_cast<Gecode::FloatNum>((state >> 8) % 8000) /
646 512.0;
647 const Gecode::FloatNum a = (i & 1U) ? -am : am;
648 const Gecode::FloatNum b = (i & 2U) ? -bm : bm;
649 const Gecode::FloatNum p = a * b;
650 const Gecode::FloatNum slack = 1.0 + am / 4.0;
651 const Gecode::FloatNum xl = a - slack;
652 const Gecode::FloatNum xu = a + slack;
653 const Gecode::FloatNum yl = (b < 0.0) ? -(bm + 1.0) : 0.0;
654 const Gecode::FloatNum yu = (b < 0.0) ? -0.0 : bm + 1.0;
655 MultSpace s(xl,xu,yl,yu,p,p);
656 if ((s.status() == Gecode::SS_FAILED) ||
657 (s.x.min() > a) || (s.x.max() < a) ||
658 (s.y.min() > b) || (s.y.max() < b) ||
659 (s.z.min() > p) || (s.z.max() < p)) {
660 olog << "Multiplication removed supported fuzz point " << i
661 << ": (" << a << ", " << b << ", " << p << ")"
662 << std::endl;
663 return false;
664 }
665 }
666 return true;
667 }
668 public:
671 : Base("Float::Arithmetic::MultZeroEndpoint",
672 TestTags::check()) {}
673
674 virtual bool run(void) {
675 bool result = true;
676 result = check(-1.0,1.0, 0.0,1.0, 0.5,1.0,
677 0.5,1.0) && result;
678 result = check(-1.0,1.0,-1.0,-0.0, 0.5,1.0,
679 -1.0,-0.5) && result;
680 result = check(-1.0,1.0, 0.0,1.0,-1.0,-0.5,
681 -1.0,-0.5) && result;
682 result = check(-1.0,1.0,-1.0,-0.0,-1.0,-0.5,
683 0.5,1.0) && result;
684
685 // Swapping the factors must recover the same contraction.
686 MultSpace swapped(0.0,1.0,-1.0,1.0,0.5,1.0);
687 result = (swapped.status() != Gecode::SS_FAILED) &&
688 (swapped.y.min() >= 0.5) && result;
689
690 // A zero product gives no sign information about the other factor.
691 MultSpace zeroProduct(-1.0,1.0,0.0,1.0,0.0,0.0);
692 result = (zeroProduct.status() != Gecode::SS_FAILED) &&
693 (zeroProduct.x.min() == -1.0) &&
694 (zeroProduct.x.max() == 1.0) && result;
695 MultSpace zeroFactor(0.0,0.0,-1.0,1.0,0.0,0.0);
696 result = (zeroFactor.status() != Gecode::SS_FAILED) &&
697 (zeroFactor.y.min() == -1.0) &&
698 (zeroFactor.y.max() == 1.0) && result;
699 if (!result)
700 olog << "Multiplication zero or swapped regression failed"
701 << std::endl;
702 return fuzz() && result;
703 }
705
707 class MultXYZ : public Test {
708 public:
710 MultXYZ(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
711 : Test(TestTags::sweep(),"Arithmetic::Mult::XYZ::"+s,3,d,st,CPLT_ASSIGNMENT,false) {}
712
713 virtual MaybeType solution(const Assignment& x) const {
714 return eq(x[0] * x[1], x[2]);
715 }
716
717 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
718 if (flip())
719 Gecode::mult(home, x[0], x[1], x[2]);
720 else
721 Gecode::rel(home, x[0] * x[1] == x[2]);
722 }
723 };
724
726 class MultXYZSol : public Test {
727 public:
729 MultXYZSol(TestTags tags, const std::string& s,
731 : Test(tags,"Arithmetic::Mult::XYZ::Sol::"+s,
732 3,d,st,EXTEND_ASSIGNMENT,false) {}
733
734 virtual MaybeType solution(const Assignment& x) const {
735 return eq(x[0] * x[1], x[2]);
736 }
737
738 virtual bool extendAssignment(Assignment& x) const {
739 Gecode::FloatVal d = x[0]*x[1];
740 if (Gecode::Float::subset(d, dom)) {
741 x.set(2, d);
742 return true;
743 } else {
744 return false;
745 }
746 }
747
748 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
749 Gecode::mult(home, x[0], x[1], x[2]);
750 }
751 };
752
754 class MultXXY : public Test {
755 public:
757 MultXXY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
758 : Test(TestTags::sweep(),"Arithmetic::Mult::XXY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
759
760 virtual MaybeType solution(const Assignment& x) const {
761 return eq(x[0] * x[0], x[1]);
762 }
763
764 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
765 Gecode::mult(home, x[0], x[0], x[1]);
766 }
767 };
768
770 class MultXXYSol : public Test {
771 public:
773 MultXXYSol(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
774 : Test(TestTags::sweep(),"Arithmetic::Mult::XXY::Sol::"+s,2,d,st,EXTEND_ASSIGNMENT,false) {}
775
776 virtual MaybeType solution(const Assignment& x) const {
777 return eq(x[0] * x[0], x[1]);
778 }
779
780 virtual bool extendAssignment(Assignment& x) const {
781 Gecode::FloatVal d = x[0]*x[0];
782 if (Gecode::Float::subset(d, dom)) {
783 x.set(1, d);
784 return true;
785 } else {
786 return false;
787 }
788 }
789
790 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
791 Gecode::mult(home, x[0], x[0], x[1]);
792 }
793 };
794
796 class MultXYX : public Test {
797 public:
799 MultXYX(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
800 : Test(TestTags::sweep(),"Arithmetic::Mult::XYX::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
801
802 virtual MaybeType solution(const Assignment& x) const {
803 return eq(x[0] * x[1], x[0]);
804 }
805
806 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
807 Gecode::mult(home, x[0], x[1], x[0]);
808 }
809 };
810
812 class MultXYY : public Test {
813 public:
815 MultXYY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
816 : Test(TestTags::sweep(),"Arithmetic::Mult::XYY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
817
818 virtual MaybeType solution(const Assignment& x) const {
819 return eq(x[0] * x[1], x[1]);
820 }
821
822 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
823 Gecode::mult(home, x[0], x[1], x[1]);
824 }
825 };
826
828 class MultXXX : public Test {
829 public:
831 MultXXX(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
832 : Test(TestTags::sweep(),"Arithmetic::Mult::XXX::"+s,1,d,st,CPLT_ASSIGNMENT,false) {}
833
834 virtual MaybeType solution(const Assignment& x) const {
835 return eq(x[0] * x[0], x[0]);
836 }
837
838 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
839 Gecode::mult(home, x[0], x[0], x[0]);
840 }
841 };
842
844 class Div : public Test {
845 public:
847 Div(TestTags tags, const std::string& s,
849 : Test(tags,"Arithmetic::Div::"+s,
850 3,d,st,CPLT_ASSIGNMENT,false) {}
851
852 virtual MaybeType solution(const Assignment& x) const {
853 return eq(x[0] / x[1], x[2]);
854 }
855
856 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
857 if (flip())
858 Gecode::div(home, x[0], x[1], x[2]);
859 else
860 Gecode::rel(home, x[0] / x[1] == x[2]);
861 }
862 };
863
865 class DivSol : public Test {
866 public:
868 DivSol(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
869 : Test(TestTags::sweep(),"Arithmetic::Div::Sol::"+s,3,d,st,EXTEND_ASSIGNMENT,false) {}
870
871 virtual MaybeType solution(const Assignment& x) const {
872 return eq(x[0] / x[1], x[2]);
873 }
874
875 virtual bool extendAssignment(Assignment& x) const {
876 Gecode::FloatVal d = x[0]/x[1];
877 if (Gecode::Float::subset(d, dom)) {
878 x.set(2, d);
879 return true;
880 } else {
881 return false;
882 }
883 }
884
885 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
886 Gecode::div(home, x[0], x[1], x[2]);
887 }
888 };
889
891 class SqrXY : public Test {
892 public:
894 SqrXY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
895 : Test(TestTags::sweep(),"Arithmetic::Sqr::XY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
896
897 virtual MaybeType solution(const Assignment& x) const {
898 return eq(x[0] * x[0], x[1]);
899 }
900
901 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
902 if (flip())
903 Gecode::sqr(home, x[0], x[1]);
904 else
905 Gecode::rel(home, sqr(x[0]) == x[1]);
906 }
907 };
908
910 class SqrXYSol : public Test {
911 public:
913 SqrXYSol(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
914 : Test(TestTags::sweep(),"Arithmetic::Sqr::XY::Sol::"+s,2,d,st,EXTEND_ASSIGNMENT,false) {}
915
916 virtual MaybeType solution(const Assignment& x) const {
917 return eq(x[0] * x[0], x[1]);
918 }
919
920 virtual bool extendAssignment(Assignment& x) const {
921 Gecode::FloatVal d = sqr(x[0]);
922 if (Gecode::Float::subset(d, dom)) {
923 x.set(1, d);
924 return true;
925 } else {
926 return false;
927 }
928 }
929
930 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
931 Gecode::sqr(home, x[0], x[1]);
932 }
933 };
934
936 class SqrXX : public Test {
937 public:
939 SqrXX(TestTags tags, const std::string& s,
941 : Test(tags,"Arithmetic::Sqr::XX::"+s,
942 1,d,st,CPLT_ASSIGNMENT,false) {}
943
944 virtual MaybeType solution(const Assignment& x) const {
945 return eq(x[0] * x[0], x[0]);
946 }
947
948 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
949 Gecode::sqr(home, x[0], x[0]);
950 }
951 };
952
954 class SqrtXY : public Test {
955 public:
957 SqrtXY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
958 : Test(TestTags::sweep(),"Arithmetic::Sqrt::XY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
959
960 virtual MaybeType solution(const Assignment& x) const {
961 switch (cmp(x[0], Gecode::FRT_GQ, 0.0)) {
962 case MT_FALSE: return MT_FALSE;
963 case MT_MAYBE: return MT_MAYBE;
964 default:
965 return eq(sqrt(x[0]), x[1]);
966 }
967 }
968
969 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
970 if (flip())
971 Gecode::sqrt(home, x[0], x[1]);
972 else
973 Gecode::rel(home, sqrt(x[0]) == x[1]);
974 }
975 };
976
978 class SqrtXYSol : public Test {
979 public:
981 SqrtXYSol(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
982 : Test(TestTags::sweep(),"Arithmetic::Sqrt::XY::Sol::"+s,2,d,st,EXTEND_ASSIGNMENT,false) {}
983
984 virtual MaybeType solution(const Assignment& x) const {
985 switch (cmp(x[0], Gecode::FRT_GQ, 0.0)) {
986 case MT_FALSE: return MT_FALSE;
987 case MT_MAYBE: return MT_MAYBE;
988 default:
989 return eq(sqrt(x[0]), x[1]);
990 }
991 }
992
993 virtual bool extendAssignment(Assignment& x) const {
994 Gecode::FloatVal d = sqrt(abs(x[0]));
995 if (Gecode::Float::subset(d, dom)) {
996 x.set(1, d);
997 return true;
998 } else {
999 return false;
1000 }
1001 }
1002
1003 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1004 Gecode::sqrt(home, x[0], x[1]);
1005 }
1006 };
1007
1009 class SqrtXX : public Test {
1010 public:
1012 SqrtXX(TestTags tags, const std::string& s,
1014 : Test(tags,"Arithmetic::Sqrt::XX::"+s,
1015 1,d,st,CPLT_ASSIGNMENT,false) {}
1016
1017 virtual MaybeType solution(const Assignment& x) const {
1018 switch (cmp(x[0], Gecode::FRT_GQ, 0.0)) {
1019 case MT_FALSE: return MT_FALSE;
1020 case MT_MAYBE: return MT_MAYBE;
1021 default:
1022 return eq(sqrt(x[0]), x[0]);
1023 }
1024 }
1025
1026 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1027 Gecode::sqrt(home, x[0], x[0]);
1028 }
1029 };
1030
1032 class PowXY : public Test {
1033 unsigned int n;
1034 public:
1036 PowXY(const std::string& s, const Gecode::FloatVal& d, unsigned int _n, Gecode::FloatNum st)
1037 : Test(TestTags::sweep(),"Arithmetic::Pow::N::"+str(_n)+"::XY::"+s,2,d,st,CPLT_ASSIGNMENT,false), n(_n) {}
1038
1039 virtual MaybeType solution(const Assignment& x) const {
1040 return eq(pow(x[0],n), x[1]);
1041 }
1042
1043 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1044 if (flip())
1045 Gecode::pow(home, x[0], n, x[1]);
1046 else
1047 Gecode::rel(home, pow(x[0],n) == x[1]);
1048 }
1049 };
1050
1052 class PowXYSol : public Test {
1053 unsigned int n;
1054 public:
1056 PowXYSol(TestTags tags, const std::string& s,
1057 const Gecode::FloatVal& d, unsigned int _n,
1059 : Test(tags,"Arithmetic::Pow::N::"+str(_n)+"::XY::Sol::"+s,
1060 2,d,st,EXTEND_ASSIGNMENT,false), n(_n) {}
1061
1062 virtual MaybeType solution(const Assignment& x) const {
1063 return eq(pow(x[0],n), x[1]);
1064 }
1065
1066 virtual bool extendAssignment(Assignment& x) const {
1067 Gecode::FloatVal d = pow(x[0],n);
1068 if (Gecode::Float::subset(d, dom)) {
1069 x.set(1, d);
1070 return true;
1071 } else {
1072 return false;
1073 }
1074 }
1075
1076 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1077 Gecode::pow(home, x[0], n, x[1]);
1078 }
1079 };
1080
1082 class PowXX : public Test {
1083 unsigned int n;
1084 public:
1086 PowXX(const std::string& s, const Gecode::FloatVal& d, unsigned int _n, Gecode::FloatNum st)
1087 : Test(TestTags::sweep(),"Arithmetic::Pow::N::"+str(_n)+"::XX::"+s,1,d,st,CPLT_ASSIGNMENT,false), n(_n) {}
1088
1089 virtual MaybeType solution(const Assignment& x) const {
1090 return eq(pow(x[0],n), x[0]);
1091 }
1092
1093 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1094 Gecode::pow(home, x[0], n, x[0]);
1095 }
1096 };
1097
1099 class NRootXY : public Test {
1100 unsigned int n;
1101 public:
1103 NRootXY(const std::string& s, const Gecode::FloatVal& d, unsigned int _n, Gecode::FloatNum st)
1104 : Test(TestTags::sweep(),"Arithmetic::NRoot::N::"+str(_n)+"::XY::"+s,2,d,st,CPLT_ASSIGNMENT,false), n(_n) {}
1105
1106 virtual MaybeType solution(const Assignment& x) const {
1107 if ((n == 0) || (x[0].min() < 0.0))
1108 return MT_FALSE;
1109 return eq(nroot(x[0],n), x[1]);
1110 }
1111
1112 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1113 if (flip())
1114 Gecode::nroot(home, x[0], n, x[1]);
1115 else
1116 Gecode::rel(home, nroot(x[0],n) == x[1]);
1117 }
1118 };
1119
1121 class NRootXYSol : public Test {
1122 unsigned int n;
1123 public:
1125 NRootXYSol(TestTags tags, const std::string& s,
1126 const Gecode::FloatVal& d, unsigned int _n,
1128 : Test(tags,"Arithmetic::NRoot::N::"+str(_n)+"::XY::Sol::"+s,
1129 2,d,st,EXTEND_ASSIGNMENT,false), n(_n) {}
1130
1131 virtual MaybeType solution(const Assignment& x) const {
1132 if ((n == 0) || (x[0].min() < 0.0))
1133 return MT_FALSE;
1134 return eq(nroot(x[0],n), x[1]);
1135 }
1136
1137 virtual bool extendAssignment(Assignment& x) const {
1138 if ((n == 0) || (x[0].min() < 0))
1139 return false;
1140 Gecode::FloatVal d = nroot(x[0],n);
1141 if (Gecode::Float::subset(d, dom)) {
1142 x.set(1, d);
1143 return true;
1144 } else {
1145 return false;
1146 }
1147 }
1148
1149 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1150 Gecode::nroot(home, x[0], n, x[1]);
1151 }
1152 };
1153
1155 class NRootXX : public Test {
1156 unsigned int n;
1157 public:
1159 NRootXX(const std::string& s, const Gecode::FloatVal& d, unsigned int _n, Gecode::FloatNum st)
1160 : Test(TestTags::sweep(),"Arithmetic::NRoot::N::"+str(_n)+"::XX::"+s,1,d,st,CPLT_ASSIGNMENT,false), n(_n) {}
1161
1162 virtual MaybeType solution(const Assignment& x) const {
1163 if ((n == 0) || (x[0].min() < 0))
1164 return MT_FALSE;
1165 return eq(nroot(x[0],n), x[0]);
1166 }
1167
1168 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1169 Gecode::nroot(home, x[0], n, x[0]);
1170 }
1171 };
1172
1174 class AbsXY : public Test {
1175 public:
1177 AbsXY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1178 : Test(TestTags::sweep(),"Arithmetic::Abs::XY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1179
1180 virtual MaybeType solution(const Assignment& x) const {
1181 return eq(abs(x[0]), x[1]);
1182 }
1183
1184 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1185 if (flip())
1186 Gecode::abs(home, x[0], x[1]);
1187 else
1188 Gecode::rel(home, abs(x[0]) == x[1]);
1189 }
1190 };
1191
1193 class AbsXX : public Test {
1194 public:
1196 AbsXX(TestTags tags, const std::string& s,
1198 : Test(tags,"Arithmetic::Abs::XX::"+s,
1199 1,d,st,CPLT_ASSIGNMENT,false) {}
1200
1201 virtual MaybeType solution(const Assignment& x) const {
1202 return eq(abs(x[0]), x[0]);
1203 }
1204
1205 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1206 Gecode::abs(home, x[0], x[0]);
1207 }
1208 };
1209
1211 class MinXYZ : public Test {
1212 public:
1214 MinXYZ(TestTags tags, const std::string& s,
1216 : Test(tags,"Arithmetic::Min::Bin::XYZ::"+s,
1217 3,d,st,CPLT_ASSIGNMENT,false) {}
1218
1219 virtual MaybeType solution(const Assignment& x) const {
1220 return eq(min(x[0],x[1]), x[2]);
1221 }
1222
1223 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1224 if (flip())
1225 Gecode::min(home, x[0], x[1], x[2]);
1226 else
1227 Gecode::rel(home, min(x[0],x[1]) == x[2]);
1228 }
1229 };
1230
1232 class MinXXY : public Test {
1233 public:
1235 MinXXY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1236 : Test(TestTags::sweep(),"Arithmetic::Min::Bin::XXY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1237
1238 virtual MaybeType solution(const Assignment& x) const {
1239 return eq(min(x[0],x[0]), x[1]);
1240 }
1241
1242 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1243 Gecode::min(home, x[0], x[0], x[1]);
1244 }
1245 };
1246
1248 class MinXYX : public Test {
1249 public:
1251 MinXYX(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1252 : Test(TestTags::sweep(),"Arithmetic::Min::Bin::XYX::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1253
1254 virtual MaybeType solution(const Assignment& x) const {
1255 return eq(min(x[0],x[1]), x[0]);
1256 }
1257
1258 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1259 Gecode::min(home, x[0], x[1], x[0]);
1260 }
1261 };
1262
1264 class MinXYY : public Test {
1265 public:
1267 MinXYY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1268 : Test(TestTags::sweep(),"Arithmetic::Min::Bin::XYY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1269
1270 virtual MaybeType solution(const Assignment& x) const {
1271 return eq(min(x[0],x[1]), x[1]);
1272 }
1273
1274 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1275 Gecode::min(home, x[0], x[1], x[1]);
1276 }
1277 };
1278
1280 class MinXXX : public Test {
1281 public:
1283 MinXXX(TestTags tags, const std::string& s,
1285 : Test(tags,"Arithmetic::Min::Bin::XXX::"+s,
1286 1,d,st,CPLT_ASSIGNMENT,false) {}
1287
1288 virtual MaybeType solution(const Assignment& x) const {
1289 return eq(min(x[0],x[0]), x[0]);
1290 }
1291
1292 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1293 Gecode::min(home, x[0], x[0], x[0]);
1294 }
1295 };
1296
1298 class MaxXYZ : public Test {
1299 public:
1301 MaxXYZ(TestTags tags, const std::string& s,
1303 : Test(tags,"Arithmetic::Max::Bin::XYZ::"+s,
1304 3,d,st,CPLT_ASSIGNMENT,false) {}
1305
1306 virtual MaybeType solution(const Assignment& x) const {
1307 return eq(max(x[0],x[1]), x[2]);
1308 }
1309
1310 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1311 if (flip())
1312 Gecode::max(home, x[0], x[1], x[2]);
1313 else
1314 Gecode::rel(home, max(x[0], x[1]) == x[2]);
1315 }
1316 };
1317
1319 class MaxXXY : public Test {
1320 public:
1322 MaxXXY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1323 : Test(TestTags::sweep(),"Arithmetic::Max::Bin::XXY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1324
1325 virtual MaybeType solution(const Assignment& x) const {
1326 return eq(max(x[0],x[0]), x[1]);
1327 }
1328
1329 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1330 Gecode::max(home, x[0], x[0], x[1]);
1331 }
1332 };
1333
1335 class MaxXYX : public Test {
1336 public:
1338 MaxXYX(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1339 : Test(TestTags::sweep(),"Arithmetic::Max::Bin::XYX::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1340
1341 virtual MaybeType solution(const Assignment& x) const {
1342 return eq(max(x[0],x[1]), x[0]);
1343 }
1344
1345 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1346 Gecode::max(home, x[0], x[1], x[0]);
1347 }
1348 };
1349
1351 class MaxXYY : public Test {
1352 public:
1354 MaxXYY(const std::string& s, const Gecode::FloatVal& d, Gecode::FloatNum st)
1355 : Test(TestTags::sweep(),"Arithmetic::Max::Bin::XYY::"+s,2,d,st,CPLT_ASSIGNMENT,false) {}
1356
1357 virtual MaybeType solution(const Assignment& x) const {
1358 return eq(max(x[0],x[1]), x[1]);
1359 }
1360
1361 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1362 Gecode::max(home, x[0], x[1], x[1]);
1363 }
1364 };
1365
1367 class MaxXXX : public Test {
1368 public:
1370 MaxXXX(TestTags tags, const std::string& s,
1372 : Test(tags,"Arithmetic::Max::Bin::XXX::"+s,
1373 1,d,st,CPLT_ASSIGNMENT,false) {}
1374
1375 virtual MaybeType solution(const Assignment& x) const {
1376 return eq(max(x[0],x[0]), x[0]);
1377 }
1378
1379 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1380 Gecode::max(home, x[0], x[0], x[0]);
1381 }
1382 };
1383
1385 class MinNary : public Test {
1386 public:
1389 : Test(TestTags::sweep(),"Arithmetic::Min::Nary",4,-4,4,0.5,CPLT_ASSIGNMENT,false) {}
1390
1391 virtual MaybeType solution(const Assignment& x) const {
1392 return eq(min(min(x[0],x[1]),x[2]), x[3]);
1393 }
1394
1395 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1397 m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
1398 if (flip())
1399 Gecode::min(home, m, x[3]);
1400 else
1401 Gecode::rel(home, min(m) == x[3]);
1402 }
1403 };
1404
1406 class MinNaryShared : public Test {
1407 public:
1410 : Test(TestTags::sweep(),"Arithmetic::Min::Nary::Shared",3,-4,4,0.5,CPLT_ASSIGNMENT,false) {}
1411
1412 virtual MaybeType solution(const Assignment& x) const {
1413 return eq(min(min(x[0],x[1]),x[2]), x[1]);
1414 }
1415
1416 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1418 m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
1419 Gecode::min(home, m, x[1]);
1420 }
1421 };
1422
1424 class MaxNary : public Test {
1425 public:
1428 : Test(TestTags::sweep(),"Arithmetic::Max::Nary",4,-4,4,0.5,CPLT_ASSIGNMENT,false) {}
1429
1430 virtual MaybeType solution(const Assignment& x) const {
1431 return eq(max(max(x[0],x[1]),x[2]), x[3]);
1432 }
1433
1434 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1436 m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
1437 if (flip())
1438 Gecode::max(home, m, x[3]);
1439 else
1440 Gecode::rel(home, max(m) == x[3]);
1441 }
1442 };
1443
1445 class MaxNaryShared : public Test {
1446 public:
1449 : Test(TestTags::sweep(),"Arithmetic::Max::Nary::Shared",3,-4,4,0.5,CPLT_ASSIGNMENT,false) {}
1450
1451 virtual MaybeType solution(const Assignment& x) const {
1452 return eq(max(max(x[0],x[1]),x[2]), x[1]);
1453 }
1454
1455 virtual void post(Gecode::Space& home, Gecode::FloatVarArray& x) {
1457 m[0]=x[0]; m[1]=x[1]; m[2]=x[2];
1458 Gecode::max(home, m, x[1]);
1459 }
1460 };
1461
1466
1470
1474
1478
1482
1486
1490
1494 TestTags::check(),"C",c,step);
1495
1499
1503
1507
1511
1515
1519
1523
1527
1531
1535 TestTags::check(),"C",c,2,step);
1536
1540
1544
1548
1552
1556
1560
1564
1568
1572 TestTags::check(),"C",c,2,step);
1573
1577
1581
1585
1589
1593
1597
1601
1605
1609
1611 TestTags::standard(),"Normal",Gecode::FloatVal(-1,1),1.0);
1612
1616
1620
1624
1628
1632
1634 TestTags::standard(),"Normal",Gecode::FloatVal(-1,1),1.0);
1635
1639
1643
1647
1651
1655
1661
1662 }
1663}}
1664
1665// STATISTICS: test-float
Float value type.
Definition float.hh:329
FloatNum med(void) const
Return median of float value.
Definition val.hpp:82
Passing float variables.
Definition float.hh:977
Float variable array.
Definition float.hh:1030
Float variables.
Definition float.hh:865
FloatNum min(void) const
Return minimum of domain.
Definition float.hpp:59
FloatNum max(void) const
Return maximum of domain.
Definition float.hpp:67
Floating point rounding policy that restores the caller's mode.
Definition float.hh:269
static PropagatorGroup all
Group of all propagators.
Definition core.hpp:796
Computation spaces.
Definition core.hpp:1787
Base(std::string s)
Create and register a standard test with name s.
Definition test.cpp:125
bool fixpoint(void)
Throw a coin whether to compute a fixpoint.
Definition test.hpp:111
TestTags tags(void) const
Return tags for test.
Definition test.hpp:95
Test for absolute value constraint with shared variables
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
AbsXX(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for absolute value constraint
AbsXY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Space posting an NthRoot constraint on a positive source.
Gecode::FloatVar source
Source and root variables.
RootSpace(Gecode::FloatNum lo, Gecode::FloatNum hi)
Post the square root of the source interval [lo,hi].
virtual Gecode::Space * copy(void)
Copy space during cloning.
Test for division constraint when solution is ensured
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
DivSol(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for division constraint
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Div(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for n-ary maximum constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MaxNaryShared(void)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for n-ary maximum constraint
MaxNary(void)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for binary maximum constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MaxXXX(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for binary maximum constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MaxXXY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for binary maximum constraint with shared variables
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MaxXYX(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for binary maximum constraint with shared variables
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
MaxXYY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for binary maximum constraint
MaxXYZ(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for n-ary minimmum constraint with shared variables
MinNaryShared(void)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for n-ary minimmum constraint
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MinNary(void)
Create and register test.
Test for binary minimum constraint with shared variables
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MinXXX(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for binary minimum constraint with shared variables
MinXXY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for binary minimum constraint with shared variables
MinXYX(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for binary minimum constraint with shared variables
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
MinXYY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for binary minimum constraint
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MinXYZ(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for multiplication constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
MultXXX(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for multiplication constraint with shared variables when solution is ensured
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
MultXXYSol(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for multiplication constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
MultXXY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
Test for multiplication constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MultXYX(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for multiplication constraint with shared variables
MultXYY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for multiplication constraint when solution is ensured
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
MultXYZSol(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
Test for multiplication constraint
MultXYZ(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Space exposing multiplication propagation at the public API.
MultSpace(Gecode::FloatNum xl, Gecode::FloatNum xu, Gecode::FloatNum yl, Gecode::FloatNum yu, Gecode::FloatNum zl, Gecode::FloatNum zu)
Post x * y = z for the supplied intervals.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Gecode::FloatVar x
Factors and product.
bool check(Gecode::FloatNum xl, Gecode::FloatNum xu, Gecode::FloatNum yl, Gecode::FloatNum yu, Gecode::FloatNum zl, Gecode::FloatNum zu, Gecode::FloatNum expectedMin, Gecode::FloatNum expectedMax) const
Check one endpoint-zero sign and magnitude contraction.
MultZeroEndpoint(void)
Create and register test.
virtual bool run(void)
Run sign, symmetry, signed-zero, and zero-product cases.
bool fuzz(void) const
Exercise supported points across endpoint-zero sign combinations.
Test for nroot constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
NRootXX(const std::string &s, const Gecode::FloatVal &d, unsigned int _n, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for nroot constraint where solution is ensured
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
NRootXYSol(TestTags tags, const std::string &s, const Gecode::FloatVal &d, unsigned int _n, Gecode::FloatNum st)
Create and register test.
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
Test for nroot constraint
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
NRootXY(const std::string &s, const Gecode::FloatVal &d, unsigned int _n, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Space exposing the propagated NthRoot upper bound.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Gecode::FloatVar source
Source and root variables.
NRootBoundSpace(NRootBoundSpace &s)
Clone constructor.
NRootBoundSpace(Gecode::FloatNum hi, int n)
Post an NthRoot constraint with an unconstrained root.
Space exercising the Pow and NthRoot propagators.
virtual Gecode::Space * copy(void)
Copy space during cloning.
RootSpace(Gecode::FloatNum hi, Gecode::FloatNum witness, int n, bool usePow)
Post an extreme Pow or NthRoot instance.
Gecode::FloatVar x0
Variables used by the propagator.
bool checkBound(Gecode::FloatNum hi, Gecode::FloatNum rejected, int n, int mode) const
Check that propagation returns a genuinely outward upper bound.
bool check(Gecode::FloatNum hi, Gecode::FloatNum witness, int n, int mode, bool usePow) const
Check that a known feasible boundary value is not removed.
virtual bool run(void)
Run test under every supported IEEE-754 rounding mode.
PositiveNRootBounds(void)
Create and register test.
Space for an adjacent interval containing zero at one endpoint.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Gecode::FloatVar x
Base and result variables.
AdjacentZeroSpace(AdjacentZeroSpace &s)
Clone constructor.
AdjacentZeroSpace(bool positive)
Post exponent zero on a positive or negative adjacent interval.
Space reproducing a Pow inverse-to-forward fixpoint.
virtual Gecode::Space * copy(void)
Copy space during cloning.
FixpointSpace(FixpointSpace &s)
Clone constructor.
FixpointSpace(void)
Post the fixpoint regression instance.
Gecode::FloatVar x
Base and result variables.
Space for direct and delayed assignment of the result to zero.
Gecode::FloatVar x
Base and result variables.
ZeroResultSpace(ZeroResultSpace &s)
Clone constructor.
ZeroResultSpace(int n, bool direct)
Post a power constraint with either a zero or a wide result.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Space for direct and delayed assignment of the base to zero.
virtual Gecode::Space * copy(void)
Copy space during cloning.
Gecode::FloatVar x
Base and result variables.
ZeroSpace(int n, bool direct)
Post a power constraint with either a zero or a wide base.
bool checkZero(int n) const
Test one exponent with direct and delayed zero assignment.
bool checkAdjacentZero(bool positive) const
Test exponent zero on an adjacent interval containing zero.
virtual bool run(void)
Run zero and fixpoint regressions.
bool checkZeroResult(int n, bool direct) const
Test that a zero result forces a zero base.
PowConsistency(void)
Create and register test.
Test for pow constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
PowXX(const std::string &s, const Gecode::FloatVal &d, unsigned int _n, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for pow constraint where solution is ensured
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
PowXYSol(TestTags tags, const std::string &s, const Gecode::FloatVal &d, unsigned int _n, Gecode::FloatNum st)
Create and register test.
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
Test for pow constraint
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
PowXY(const std::string &s, const Gecode::FloatVal &d, unsigned int _n, Gecode::FloatNum st)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
virtual bool run(void)
Run test.
Test for squaring constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
SqrXX(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for squaring constraint where solution is ensured
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
SqrXYSol(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for squaring constraint
SqrXY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for square root constraint with shared variables
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
SqrtXX(TestTags tags, const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Test for square root constraint where solution is ensured
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
virtual bool extendAssignment(Assignment &x) const
Extend assignment x.
SqrtXYSol(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
Test for square root constraint
virtual void post(Gecode::Space &home, Gecode::FloatVarArray &x)
Post constraint on x.
SqrtXY(const std::string &s, const Gecode::FloatVal &d, Gecode::FloatNum st)
Create and register test.
virtual MaybeType solution(const Assignment &x) const
Test whether x is solution
Base class for assignments
Definition float.hh:94
virtual void set(int i, const Gecode::FloatVal &val)=0
Set assignment to value val for variable i.
static MaybeType eq(Gecode::FloatVal x, Gecode::FloatVal y)
Whether x and y are equal.
Definition float.hpp:281
static MaybeType cmp(Gecode::FloatVal x, Gecode::FloatRelType r, Gecode::FloatVal y)
Compare x and y with respect to r.
Definition float.hpp:248
static std::string str(Gecode::FloatRelType frt)
Map float relation to string.
Definition float.hpp:207
bool flip(void)
Flip a coin and return true or false randomly.
Definition float.hpp:286
Gecode::FloatVal dom
Domain of variables.
Definition float.hh:264
Set of test tags.
Definition test.hh:105
static TestTags sweep(void)
Expensive parameter sweeps.
Definition test.hpp:59
static TestTags standard(void)
Standard suite without expensive sweeps.
Definition test.hpp:55
static TestTags check(void)
Integrity tests, also part of the standard suite.
Definition test.hpp:51
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
double FloatNum
Floating point number base type.
Definition float.hh:106
@ FRT_EQ
Equality ( ).
Definition float.hh:1071
@ FRT_GQ
Greater or equal ( ).
Definition float.hh:1075
Space(void)
Default constructor.
Definition core.cpp:121
Space * clone(void) const
Clone space.
Definition core.hpp:3384
SpaceStatus status(StatusStatistics &stat)
Query space status.
Definition core.cpp:281
@ SS_FAILED
Space is failed
Definition core.hpp:1727
bool subset(const FloatVal &x, const FloatVal &y)
Definition val.hpp:491
Gecode toplevel namespace
void sqr(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void abs(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void div(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void sqrt(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void pow(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for .
void nroot(Home home, FloatVar x0, int n, FloatVar x1)
Post propagator for for .
Tests for arithmetic constraints
PowXYSol pow_xy_sol_c_2(TestTags::sweep(),"C", c, 3, step)
PowXYSol pow_xy_sol_b_1(TestTags::sweep(),"B", b, 2, step)
AbsXY abs_xy_b("B", b, step)
NRootXYSol nroot_xy_sol_b_3(TestTags::sweep(),"B", b, 0, step)
SqrtXY sqrt_xy_b("B", b, step)
MinXYX min_xyx_b("B", b, step)
MultXYY mult_xyy_b("B", b, step)
AbsXY abs_xy_a("A", a, step)
Test::Float::Arithmetic::DirectedRounding directed_rounding
PowXX pow_xx_b_3("B", b, 0, step)
MinXYY min_xyy_a("A", a, step)
NRootXYSol nroot_xy_sol_a_3(TestTags::sweep(),"A", a, 0, step)
MultXYY mult_xyy_c("C", c, step)
NRootXX nroot_xx_b_1("B", b, 2, step)
MinXXY min_xxy_c("C", c, step)
NRootXX nroot_xx_b_2("B", b, 3, step)
Div div_b(TestTags::sweep(),"B", b, step)
NRootXYSol nroot_xy_sol_c_1(TestTags::check(),"C", c, 2, step)
DivSol div_sol_a("A", a, step)
SqrtXYSol sqrt_xy_sol_a("A", a, step)
Test::Float::Arithmetic::MedianRoundingMode median_rounding_mode
MaxXYZ max_xyz_c(TestTags::sweep(),"C", c, step)
SqrXYSol sqr_xy_sol_b("B", b, step)
SqrXX sqr_xx_a(TestTags::standard(),"A", a, step)
PowXX pow_xx_b_2("B", b, 3, step)
NRootXYSol nroot_xy_sol_b_1(TestTags::sweep(),"B", b, 2, step)
SqrXY sqr_xy_b("B", b, step)
SqrtXX sqrt_xx_a(TestTags::standard(),"A", a, step)
SqrtXX sqrt_xx_b(TestTags::sweep(),"B", b, step)
MaxXXX max_xxx_a(TestTags::standard(),"A", a, step)
PowXX pow_xx_c_1("C", c, 2, step)
SqrtXYSol sqrt_xy_sol_c("C", c, step)
Gecode::FloatVal c(-8, 8)
PowXY pow_xy_b_2("B", b, 3, step)
MultXXY mult_xxy_c("C", c, step)
NRootXX nroot_xx_a_2("A", a, 3, step)
PowXYSol pow_xy_sol_b_2(TestTags::sweep(),"B", b, 3, step)
MultXYZSol mult_xyz_sol_a(TestTags::sweep(),"A", a, step)
NRootXY nroot_xy_a_1("A", a, 2, step)
MaxXYX max_xyx_a("A", a, step)
MaxXYY max_xyy_a("A", a, step)
AbsXX abs_xx_c(TestTags::sweep(),"C", c, step)
MaxXYZ max_xyz_a(TestTags::sweep(),"A", a, step)
MinXYZ min_xyz_a(TestTags::sweep(),"A", a, step)
Test::Float::Arithmetic::MultZeroEndpoint mult_zero_endpoint
PowXYSol pow_xy_sol_a_2(TestTags::sweep(),"A", a, 3, step)
MinXYZ min_xyz_c(TestTags::sweep(),"C", c, step)
MinXYX min_xyx_a("A", a, step)
NRootXYSol nroot_xy_sol_a_1(TestTags::sweep(),"A", a, 2, step)
PowXX pow_xx_a_3("A", a, 0, step)
PowXY pow_xy_c_2("C", c, 3, step)
MultXYZ mult_xyz_b("B", b, step)
MultXYZSol mult_xyz_sol_b(TestTags::sweep(),"B", b, step)
NRootXY nroot_xy_b_2("B", b, 3, step)
MultXYX mult_xyx_a("A", a, step)
MultXYZ mult_xyz_c("C", c, step)
MultXYZ mult_xyz_a("A", a, step)
MultXXX mult_xxx_c("C", c, step)
MinXYZ min_xyz_normal(TestTags::standard(),"Normal", Gecode::FloatVal(-1, 1), 1.0)
MultXYZSol mult_xyz_sol_c(TestTags::check(),"C", c, step)
MinXXX min_xxx_c(TestTags::sweep(),"C", c, step)
Test::Float::Arithmetic::PositiveNRootBounds positive_nroot_bounds
NRootXYSol nroot_xy_sol_a_2(TestTags::sweep(),"A", a, 3, step)
MaxXXX max_xxx_c(TestTags::sweep(),"C", c, step)
PowXYSol pow_xy_sol_a_1(TestTags::sweep(),"A", a, 2, step)
MinXXX min_xxx_b(TestTags::sweep(),"B", b, step)
NRootXY nroot_xy_b_3("B", b, 0, step)
PowXYSol pow_xy_sol_c_1(TestTags::check(),"C", c, 2, step)
MaxXXX max_xxx_b(TestTags::sweep(),"B", b, step)
MinXXY min_xxy_b("B", b, step)
SqrtXX sqrt_xx_c(TestTags::sweep(),"C", c, step)
NRootXY nroot_xy_c_1("C", c, 2, step)
MinXYY min_xyy_b("B", b, step)
MinXYY min_xyy_c("C", c, step)
NRootXX nroot_xx_c_3("C", c, 0, step)
SqrXX sqr_xx_c(TestTags::sweep(),"C", c, step)
NRootXY nroot_xy_c_2("C", c, 3, step)
MinXYX min_xyx_c("C", c, step)
SqrtXY sqrt_xy_c("C", c, step)
Div div_a(TestTags::standard(),"A", a, step)
SqrtXY sqrt_xy_a("A", a, step)
MaxXXY max_xxy_b("B", b, step)
PowXY pow_xy_b_3("B", b, 0, step)
NRootXX nroot_xx_a_3("A", a, 0, step)
SqrtXYSol sqrt_xy_sol_b("B", b, step)
Gecode::FloatVal b(9, 12)
MaxXYZ max_xyz_b(TestTags::sweep(),"B", b, step)
MultXYX mult_xyx_b("B", b, step)
PowXYSol pow_xy_sol_a_3(TestTags::sweep(),"A", a, 0, step)
SqrXYSol sqr_xy_sol_a("A", a, step)
AbsXX abs_xx_b(TestTags::sweep(),"B", b, step)
Test::Float::Arithmetic::PowConsistency pow_consistency
MultXXYSol mult_xxy_sol_c("C", c, step)
MaxXYY max_xyy_b("B", b, step)
PowXY pow_xy_a_1("A", a, 2, step)
MinXXX min_xxx_a(TestTags::standard(),"A", a, step)
PowXY pow_xy_a_2("A", a, 3, step)
PowXYSol pow_xy_sol_c_3(TestTags::sweep(),"C", c, 0, step)
Gecode::FloatVal a(-8, 5)
SqrXY sqr_xy_c("C", c, step)
MultXXYSol mult_xxy_sol_b("B", b, step)
DivSol div_sol_c("C", c, step)
PowXX pow_xx_a_2("A", a, 3, step)
DivSol div_sol_b("B", b, step)
PowXY pow_xy_c_3("C", c, 0, step)
MaxXYX max_xyx_b("B", b, step)
AbsXX abs_xx_a(TestTags::standard(),"A", a, step)
MaxXXY max_xxy_c("C", c, step)
NRootXYSol nroot_xy_sol_c_2(TestTags::sweep(),"C", c, 3, step)
NRootXY nroot_xy_b_1("B", b, 2, step)
MultXXY mult_xxy_b("B", b, step)
PowXY pow_xy_b_1("B", b, 2, step)
PowXYSol pow_xy_sol_b_3(TestTags::sweep(),"B", b, 0, step)
AbsXY abs_xy_c("C", c, step)
const Gecode::FloatNum step
MultXYX mult_xyx_c("C", c, step)
MultXXX mult_xxx_a("A", a, step)
NRootXX nroot_xx_b_3("B", b, 0, step)
MultXXYSol mult_xxy_sol_a("A", a, step)
MaxXYY max_xyy_c("C", c, step)
PowXY pow_xy_a_3("A", a, 0, step)
NRootXY nroot_xy_a_2("A", a, 3, step)
PowXX pow_xx_b_1("B", b, 2, step)
MultXXY mult_xxy_a("A", a, step)
PowXX pow_xx_c_2("C", c, 3, step)
MinXXY min_xxy_a("A", a, step)
SqrXX sqr_xx_b(TestTags::sweep(),"B", b, step)
MaxXYX max_xyx_c("C", c, step)
MaxXYZ max_xyz_normal(TestTags::standard(),"Normal", Gecode::FloatVal(-1, 1), 1.0)
PowXY pow_xy_c_1("C", c, 2, step)
Test::Float::Arithmetic::RoundingScope rounding_scope
Div div_c(TestTags::sweep(),"C", c, step)
NRootXYSol nroot_xy_sol_c_3(TestTags::sweep(),"C", c, 0, step)
MultXXX mult_xxx_b("B", b, step)
NRootXX nroot_xx_a_1("A", a, 2, step)
SqrXY sqr_xy_a("A", a, step)
NRootXYSol nroot_xy_sol_b_2(TestTags::sweep(),"B", b, 3, step)
SqrXYSol sqr_xy_sol_c("C", c, step)
NRootXX nroot_xx_c_2("C", c, 3, step)
PowXX pow_xx_c_3("C", c, 0, step)
NRootXX nroot_xx_c_1("C", c, 2, step)
MaxXXY max_xxy_a("A", a, step)
MultXYY mult_xyy_a("A", a, step)
MinXYZ min_xyz_b(TestTags::sweep(),"B", b, step)
PowXX pow_xx_a_1("A", a, 2, step)
NRootXY nroot_xy_c_3("C", c, 0, step)
NRootXY nroot_xy_a_3("A", a, 0, step)
Testing domain floats.
Definition float.cpp:43
@ EXTEND_ASSIGNMENT
Definition float.hh:78
@ CPLT_ASSIGNMENT
Definition float.hh:76
MaybeType
Type for comparisons and solutions.
Definition float.hh:65
General test support.
Definition afc.cpp:41
std::ostringstream olog
Stream used for logging.
Definition test.cpp:54
Region r
Definition region.cpp:65
@ check
Basic integrity tests.
Definition test.hh:99
@ sweep
Really heavy sweep tests.
Definition test.hh:101