00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef __GECODE_FLOAT_HH__
00039 #define __GECODE_FLOAT_HH__
00040
00041 #include <climits>
00042 #include <cfloat>
00043 #include <iostream>
00044
00045 #include <functional>
00046
00047 #include <gecode/kernel.hh>
00048 #include <gecode/int.hh>
00049
00050
00051
00052
00053
00054 #if !defined(GECODE_STATIC_LIBS) && \
00055 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00056
00057 #ifdef GECODE_BUILD_FLOAT
00058 #define GECODE_FLOAT_EXPORT __declspec( dllexport )
00059 #else
00060 #define GECODE_FLOAT_EXPORT __declspec( dllimport )
00061 #endif
00062
00063 #else
00064
00065 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00066 #define GECODE_FLOAT_EXPORT __attribute__ ((visibility("default")))
00067 #else
00068 #define GECODE_FLOAT_EXPORT
00069 #endif
00070
00071 #endif
00072
00073
00074 #ifndef GECODE_BUILD_FLOAT
00075 #define GECODE_LIBRARY_NAME "Float"
00076 #include <gecode/support/auto-link.hpp>
00077 #endif
00078
00079
00080 #include <gecode/third-party/boost/numeric/interval.hpp>
00081
00093 #include <gecode/float/exception.hpp>
00094
00095 #include <gecode/float/nextafter.hpp>
00096
00097 namespace Gecode {
00098
00106 typedef double FloatNum;
00107
00109 FloatNum pi_half_lower(void);
00111 FloatNum pi_half_upper(void);
00113 FloatNum pi_lower(void);
00115 FloatNum pi_upper(void);
00117 FloatNum pi_twice_lower(void);
00119 FloatNum pi_twice_upper(void);
00120
00121
00122 class FloatVal;
00123
00124 }
00125
00126 #include <gecode/float/num.hpp>
00127
00128 namespace Gecode { namespace Float {
00129
00130
00131 #if defined(_MSC_VER) && (defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP > 0)))
00132
00133
00134
00135
00136
00138 typedef gecode_boost::numeric::interval_lib::save_state< gecode_boost::numeric::interval_lib::rounded_arith_std<FloatNum> >
00139 RoundingBase;
00140
00141 #else
00142
00144 typedef gecode_boost::numeric::interval_lib::rounded_arith_opp<FloatNum>
00145 RoundingBase;
00146
00147 #endif
00148
00154 class Rounding : public RoundingBase {
00155 public:
00157
00158
00159 Rounding(void);
00161 ~Rounding(void);
00163
00165
00166
00167 FloatNum add_down(FloatNum x, FloatNum y);
00169 FloatNum add_up (FloatNum x, FloatNum y);
00171 FloatNum sub_down(FloatNum x, FloatNum y);
00173 FloatNum sub_up (FloatNum x, FloatNum y);
00175 FloatNum mul_down(FloatNum x, FloatNum y);
00177 FloatNum mul_up (FloatNum x, FloatNum y);
00179 FloatNum div_down(FloatNum x, FloatNum y);
00181 FloatNum div_up (FloatNum x, FloatNum y);
00183 FloatNum sqrt_down(FloatNum x);
00185 FloatNum sqrt_up (FloatNum x);
00187
00189
00190
00191 FloatNum median(FloatNum x, FloatNum y);
00193 FloatNum int_down(FloatNum x);
00195 FloatNum int_up (FloatNum x);
00197
00198 #ifdef GECODE_HAS_MPFR
00199
00200
00201
00202 GECODE_FLOAT_EXPORT FloatNum exp_down(FloatNum x);
00204 GECODE_FLOAT_EXPORT FloatNum exp_up (FloatNum x);
00206 GECODE_FLOAT_EXPORT FloatNum log_down(FloatNum x);
00208 GECODE_FLOAT_EXPORT FloatNum log_up (FloatNum x);
00210
00212
00213
00214 GECODE_FLOAT_EXPORT FloatNum sin_down(FloatNum x);
00216 GECODE_FLOAT_EXPORT FloatNum sin_up (FloatNum x);
00218 GECODE_FLOAT_EXPORT FloatNum cos_down(FloatNum x);
00220 GECODE_FLOAT_EXPORT FloatNum cos_up (FloatNum x);
00222 GECODE_FLOAT_EXPORT FloatNum tan_down(FloatNum x);
00224 GECODE_FLOAT_EXPORT FloatNum tan_up (FloatNum x);
00226
00228
00229
00230 GECODE_FLOAT_EXPORT FloatNum asin_down(FloatNum x);
00232 GECODE_FLOAT_EXPORT FloatNum asin_up (FloatNum x);
00234 GECODE_FLOAT_EXPORT FloatNum acos_down(FloatNum x);
00236 GECODE_FLOAT_EXPORT FloatNum acos_up (FloatNum x);
00238 GECODE_FLOAT_EXPORT FloatNum atan_down(FloatNum x);
00240 GECODE_FLOAT_EXPORT FloatNum atan_up (FloatNum x);
00242
00244
00245
00246 GECODE_FLOAT_EXPORT FloatNum sinh_down(FloatNum x);
00248 GECODE_FLOAT_EXPORT FloatNum sinh_up (FloatNum x);
00250 GECODE_FLOAT_EXPORT FloatNum cosh_down(FloatNum x);
00252 GECODE_FLOAT_EXPORT FloatNum cosh_up (FloatNum x);
00254 GECODE_FLOAT_EXPORT FloatNum tanh_down(FloatNum x);
00256 GECODE_FLOAT_EXPORT FloatNum tanh_up (FloatNum x);
00258
00260
00261
00262 GECODE_FLOAT_EXPORT FloatNum asinh_down(FloatNum x);
00264 GECODE_FLOAT_EXPORT FloatNum asinh_up (FloatNum x);
00266 GECODE_FLOAT_EXPORT FloatNum acosh_down(FloatNum x);
00268 GECODE_FLOAT_EXPORT FloatNum acosh_up (FloatNum x);
00270 GECODE_FLOAT_EXPORT FloatNum atanh_down(FloatNum x);
00272 GECODE_FLOAT_EXPORT FloatNum atanh_up (FloatNum x);
00274 #endif
00275 };
00276
00277 }}
00278
00279 #include <gecode/float/rounding.hpp>
00280
00281 namespace Gecode { namespace Float {
00282
00287 bool subset(const FloatVal& x, const FloatVal& y);
00292 bool proper_subset(const FloatVal& x, const FloatVal& y);
00297 bool overlap(const FloatVal& x, const FloatVal& y);
00298
00303 FloatVal intersect(const FloatVal& x, const FloatVal& y);
00308 FloatVal hull(const FloatVal& x, const FloatVal& y);
00313 FloatVal hull(const FloatVal& x, const FloatNum& y);
00318 FloatVal hull(const FloatNum& x, const FloatVal& y);
00323 FloatVal hull(const FloatNum& x, const FloatNum& y);
00324
00325 }}
00326
00327 namespace Gecode {
00328
00334 class FloatVal {
00335 friend FloatVal operator +(const FloatVal& x);
00336 friend FloatVal operator -(const FloatVal& x);
00337 friend FloatVal operator +(const FloatVal& x, const FloatVal& y);
00338 friend FloatVal operator +(const FloatVal& x, const FloatNum& y);
00339 friend FloatVal operator +(const FloatNum& x, const FloatVal& y);
00340 friend FloatVal operator -(const FloatVal& x, const FloatVal& y);
00341 friend FloatVal operator -(const FloatVal& x, const FloatNum& y);
00342 friend FloatVal operator -(const FloatNum& x, const FloatVal& y);
00343 friend FloatVal operator *(const FloatVal& x, const FloatVal& y);
00344 friend FloatVal operator *(const FloatVal& x, const FloatNum& y);
00345 friend FloatVal operator *(const FloatNum& x, const FloatVal& y);
00346 friend FloatVal operator /(const FloatVal& x, const FloatVal& y);
00347 friend FloatVal operator /(const FloatVal& x, const FloatNum& y);
00348 friend FloatVal operator /(const FloatNum& x, const FloatVal& y);
00349
00350 friend bool operator <(const FloatVal& x, const FloatVal& y);
00351 friend bool operator <(const FloatVal& x, const FloatNum& y);
00352 friend bool operator <(const FloatNum& x, const FloatVal& y);
00353 friend bool operator <=(const FloatVal& x, const FloatVal& y);
00354 friend bool operator <=(const FloatVal& x, const FloatNum& y);
00355 friend bool operator <=(const FloatNum& x, const FloatVal& y);
00356 friend bool operator >(const FloatVal& x, const FloatVal& y);
00357 friend bool operator >(const FloatVal& x, const FloatNum& y);
00358 friend bool operator >(const FloatNum& x, const FloatVal& y);
00359 friend bool operator >=(const FloatVal& x, const FloatVal& y);
00360 friend bool operator >=(const FloatVal& x, const FloatNum& y);
00361 friend bool operator >=(const FloatNum& x, const FloatVal& y);
00362 friend bool operator ==(const FloatVal& x, const FloatVal& y);
00363 friend bool operator ==(const FloatVal& x, const FloatNum& y);
00364 friend bool operator ==(const FloatNum& x, const FloatVal& y);
00365 friend bool operator !=(const FloatVal& x, const FloatVal& y);
00366 friend bool operator !=(const FloatVal& x, const FloatNum& y);
00367 friend bool operator !=(const FloatNum& x, const FloatVal& y);
00368
00369 template<class Char, class Traits>
00370 friend std::basic_ostream<Char,Traits>&
00371 operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
00372
00373 friend FloatVal abs(const FloatVal& x);
00374 friend FloatVal sqrt(const FloatVal& x);
00375 friend FloatVal sqr(const FloatVal& x);
00376 friend FloatVal pow(const FloatVal& x, int n);
00377 friend FloatVal nroot(const FloatVal& x, int n);
00378
00379 friend FloatVal max(const FloatVal& x, const FloatVal& y);
00380 friend FloatVal max(const FloatVal& x, const FloatNum& y);
00381 friend FloatVal max(const FloatNum& x, const FloatVal& y);
00382 friend FloatVal min(const FloatVal& x, const FloatVal& y);
00383 friend FloatVal min(const FloatVal& x, const FloatNum& y);
00384 friend FloatVal min(const FloatNum& x, const FloatVal& y);
00385
00386 #ifdef GECODE_HAS_MPFR
00387 friend FloatVal exp(const FloatVal& x);
00388 friend FloatVal log(const FloatVal& x);
00389 friend FloatVal fmod(const FloatVal& x, const FloatVal& y);
00390 friend FloatVal fmod(const FloatVal& x, const FloatNum& y);
00391 friend FloatVal fmod(const FloatNum& x, const FloatVal& y);
00392 friend FloatVal sin(const FloatVal& x);
00393 friend FloatVal cos(const FloatVal& x);
00394 friend FloatVal tan(const FloatVal& x);
00395 friend FloatVal asin(const FloatVal& x);
00396 friend FloatVal acos(const FloatVal& x);
00397 friend FloatVal atan(const FloatVal& x);
00398 friend FloatVal sinh(const FloatVal& x);
00399 friend FloatVal cosh(const FloatVal& x);
00400 friend FloatVal tanh(const FloatVal& x);
00401 friend FloatVal asinh(const FloatVal& x);
00402 friend FloatVal acosh(const FloatVal& x);
00403 friend FloatVal atanh(const FloatVal& x);
00404 #endif
00405
00406 friend bool Float::subset(const FloatVal& x, const FloatVal& y);
00407 friend bool Float::proper_subset(const FloatVal& x, const FloatVal& y);
00408 friend bool Float::overlap(const FloatVal& x, const FloatVal& y);
00409 friend FloatVal Float::intersect(const FloatVal& x, const FloatVal& y);
00410 friend FloatVal Float::hull(const FloatVal& x, const FloatVal& y);
00411 friend FloatVal Float::hull(const FloatVal& x, const FloatNum& y);
00412 friend FloatVal Float::hull(const FloatNum& x, const FloatVal& y);
00413 friend FloatVal Float::hull(const FloatNum& x, const FloatNum& y);
00414 protected:
00416 typedef gecode_boost::numeric::interval_lib::save_state<Float::Rounding> R;
00418 typedef gecode_boost::numeric::interval_lib::checking_strict<FloatNum> P;
00420 typedef gecode_boost::numeric::interval
00421 <FloatNum,
00422 gecode_boost::numeric::interval_lib::policies<R, P> >
00423 FloatValImpType;
00425 FloatValImpType x;
00427 explicit FloatVal(const FloatValImpType& i);
00428 public:
00430
00431
00432 FloatVal(void);
00434 FloatVal(const FloatNum& n);
00436 FloatVal(const FloatNum& l, const FloatNum& u);
00438 FloatVal(const FloatVal& v);
00439
00441 FloatVal& operator =(const FloatNum& n);
00443 FloatVal& operator =(const FloatVal& v);
00444
00446 void assign(FloatNum const &l, FloatNum const &u);
00448
00450
00451
00452 FloatNum min(void) const;
00454 FloatNum max(void) const;
00456 FloatNum size(void) const;
00458 FloatNum med(void) const;
00460
00462
00463
00464 bool tight(void) const;
00466 bool singleton(void) const;
00468 bool in(FloatNum n) const;
00470 bool zero_in(void) const;
00472
00474
00475
00476 static FloatVal hull(FloatNum x, FloatNum y);
00478 static FloatVal pi_half(void);
00480 static FloatVal pi(void);
00482 static FloatVal pi_twice(void);
00484
00486
00487
00488 FloatVal& operator +=(const FloatNum& n);
00490 FloatVal& operator -=(const FloatNum& n);
00492 FloatVal& operator *=(const FloatNum& n);
00494 FloatVal& operator /=(const FloatNum& n);
00496 FloatVal& operator +=(const FloatVal& v);
00498 FloatVal& operator -=(const FloatVal& v);
00500 FloatVal& operator *=(const FloatVal& v);
00502 FloatVal& operator /=(const FloatVal& v);
00504 };
00505
00510 FloatVal operator +(const FloatVal& x);
00515 FloatVal operator -(const FloatVal& x);
00516
00521 FloatVal operator +(const FloatVal& x, const FloatVal& y);
00526 FloatVal operator +(const FloatVal& x, const FloatNum& y);
00531 FloatVal operator +(const FloatNum& x, const FloatVal& y);
00536 FloatVal operator -(const FloatVal& x, const FloatVal& y);
00541 FloatVal operator -(const FloatVal& x, const FloatNum& y);
00546 FloatVal operator -(const FloatNum& x, const FloatVal& y);
00551 FloatVal operator *(const FloatVal& x, const FloatVal& y);
00556 FloatVal operator *(const FloatVal& x, const FloatNum& y);
00561 FloatVal operator *(const FloatNum& x, const FloatVal& y);
00566 FloatVal operator /(const FloatVal& x, const FloatVal& y);
00571 FloatVal operator /(const FloatVal& x, const FloatNum& y);
00576 FloatVal operator /(const FloatNum& r, const FloatVal& x);
00577
00582 bool operator <(const FloatVal& x, const FloatVal& y);
00587 bool operator <(const FloatVal& x, const FloatNum& y);
00592 bool operator <(const FloatNum& x, const FloatVal& y);
00593
00598 bool operator <=(const FloatVal& x, const FloatVal& y);
00603 bool operator <=(const FloatVal& x, const FloatNum& y);
00608 bool operator <=(const FloatNum& x, const FloatVal& y);
00609
00614 bool operator >(const FloatVal& x, const FloatVal& y);
00619 bool operator >(const FloatVal& x, const FloatNum& y);
00624 bool operator >(const FloatNum& x, const FloatVal& y);
00625
00630 bool operator >=(const FloatVal& x, const FloatVal& y);
00635 bool operator >=(const FloatVal& x, const FloatNum& y);
00640 bool operator >=(const FloatNum& x, const FloatVal& y);
00645 bool operator ==(const FloatVal& x, const FloatVal& y);
00650 bool operator ==(const FloatVal& x, const FloatNum& y);
00655 bool operator ==(const FloatNum& x, const FloatVal& y);
00656
00661 bool operator !=(const FloatVal& x, const FloatVal& y);
00666 bool operator !=(const FloatVal& x, const FloatNum& y);
00671 bool operator !=(const FloatNum& x, const FloatVal& y);
00672
00677 template<class Char, class Traits>
00678 std::basic_ostream<Char,Traits>&
00679 operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
00680
00685 FloatVal abs(const FloatVal& x);
00690 FloatVal sqrt(const FloatVal& x);
00695 FloatVal sqr(const FloatVal& x);
00700 FloatVal pow(const FloatVal& x, int n);
00705 FloatVal nroot(const FloatVal& x, int n);
00706
00711 FloatVal max(const FloatVal& x, const FloatVal& y);
00716 FloatVal max(const FloatVal& x, const FloatNum& y);
00721 FloatVal max(const FloatNum& x, const FloatVal& y);
00726 FloatVal min(const FloatVal& x, const FloatVal& y);
00731 FloatVal min(const FloatVal& x, const FloatNum& y);
00736 FloatVal min(const FloatNum& x, const FloatVal& y);
00737
00738 #ifdef GECODE_HAS_MPFR
00739
00744 FloatVal exp(const FloatVal& x);
00749 FloatVal log(const FloatVal& x);
00750
00755 FloatVal fmod(const FloatVal& x, const FloatVal& y);
00760 FloatVal fmod(const FloatVal& x, const FloatNum& y);
00765 FloatVal fmod(const FloatNum& x, const FloatVal& y);
00766
00771 FloatVal sin(const FloatVal& x);
00776 FloatVal cos(const FloatVal& x);
00781 FloatVal tan(const FloatVal& x);
00786 FloatVal asin(const FloatVal& x);
00791 FloatVal acos(const FloatVal& x);
00796 FloatVal atan(const FloatVal& x);
00797
00802 FloatVal sinh(const FloatVal& x);
00807 FloatVal cosh(const FloatVal& x);
00812 FloatVal tanh(const FloatVal& x);
00817 FloatVal asinh(const FloatVal& x);
00822 FloatVal acosh(const FloatVal& x);
00827 FloatVal atanh(const FloatVal& x);
00828
00829 #endif
00830
00831 }
00832
00833 #include <gecode/float/val.hpp>
00834
00835 namespace Gecode { namespace Float {
00836
00842 namespace Limits {
00844 const FloatNum max = std::numeric_limits<FloatNum>::max();
00846 const FloatNum min = -max;
00848 bool valid(const FloatVal& n);
00850 void check(const FloatVal& n, const char* l);
00851 }
00852
00853 }}
00854
00855 #include <gecode/float/limits.hpp>
00856
00857 #include <gecode/float/var-imp.hpp>
00858
00859 namespace Gecode {
00860
00861 namespace Float {
00862 class FloatView;
00863 }
00864
00870 class FloatVar : public VarImpVar<Float::FloatVarImp> {
00871 friend class FloatVarArray;
00872 friend class FloatVarArgs;
00873 private:
00874 using VarImpVar<Float::FloatVarImp>::x;
00881 void _init(Space& home, FloatNum min, FloatNum max);
00882 public:
00884
00885
00886 FloatVar(void);
00888 FloatVar(const FloatVar& y);
00890 FloatVar(const Float::FloatView& y);
00902 GECODE_FLOAT_EXPORT FloatVar(Space& home, FloatNum min, FloatNum max);
00904
00906
00907
00908 FloatVal domain(void) const;
00910 FloatNum min(void) const;
00912 FloatNum max(void) const;
00914 FloatNum med(void) const;
00916 FloatNum size(void) const;
00924 FloatVal val(void) const;
00925
00927
00929
00930
00931 bool in(const FloatVal& n) const;
00933 };
00934
00939 template<class Char, class Traits>
00940 std::basic_ostream<Char,Traits>&
00941 operator <<(std::basic_ostream<Char,Traits>& os, const FloatVar& x);
00942 }
00943
00944 #include <gecode/float/view.hpp>
00945 #include <gecode/float/array-traits.hpp>
00946
00947 namespace Gecode {
00948
00950 class FloatValArgs : public ArgArray<FloatVal> {
00951 public:
00953
00954
00955 FloatValArgs(void);
00957 explicit FloatValArgs(int n);
00959 FloatValArgs(const SharedArray<FloatVal>& x);
00961 FloatValArgs(const std::vector<FloatVal>& x);
00963 FloatValArgs(std::initializer_list<FloatVal> x);
00965 template<class InputIterator>
00966 FloatValArgs(InputIterator first, InputIterator last);
00968 FloatValArgs(int n, const FloatVal* e);
00970 FloatValArgs(const ArgArray<FloatVal>& a);
00971
00973 GECODE_FLOAT_EXPORT
00974 static FloatValArgs create(int n, FloatVal start, int inc=1);
00976 };
00977
00979 class FloatVarArgs : public VarArgArray<FloatVar> {
00980 public:
00982
00983
00984 FloatVarArgs(void);
00986 explicit FloatVarArgs(int n);
00988 FloatVarArgs(const FloatVarArgs& a);
00990 FloatVarArgs(const VarArray<FloatVar>& a);
00992 FloatVarArgs(const std::vector<FloatVar>& a);
00994 FloatVarArgs(std::initializer_list<FloatVar> a);
00996 template<class InputIterator>
00997 FloatVarArgs(InputIterator first, InputIterator last);
01009 GECODE_FLOAT_EXPORT
01010 FloatVarArgs(Space& home, int n, FloatNum min, FloatNum max);
01012 };
01014
01030 class FloatVarArray : public VarArray<FloatVar> {
01031 public:
01033
01034
01035 FloatVarArray(void);
01037 FloatVarArray(Space& home, int n);
01039 FloatVarArray(const FloatVarArray& a);
01041 FloatVarArray(Space& home, const FloatVarArgs& a);
01053 GECODE_FLOAT_EXPORT
01054 FloatVarArray(Space& home, int n, FloatNum min, FloatNum max);
01056 };
01057
01058 }
01059
01060 #include <gecode/float/array.hpp>
01061
01062 namespace Gecode {
01063
01068 enum FloatRelType {
01069 FRT_EQ,
01070 FRT_NQ,
01071 FRT_LQ,
01072 FRT_LE,
01073 FRT_GQ,
01074 FRT_GR
01075 };
01076
01084
01085 GECODE_FLOAT_EXPORT void
01086 dom(Home home, FloatVar x, FloatVal n);
01088 GECODE_FLOAT_EXPORT void
01089 dom(Home home, const FloatVarArgs& x, FloatVal n);
01091 GECODE_FLOAT_EXPORT void
01092 dom(Home home, FloatVar x, FloatNum l, FloatNum m);
01094 GECODE_FLOAT_EXPORT void
01095 dom(Home home, const FloatVarArgs& x, FloatNum l, FloatNum u);
01097 GECODE_FLOAT_EXPORT void
01098 dom(Home home, FloatVar x, FloatVal n, Reify r);
01100 GECODE_FLOAT_EXPORT void
01101 dom(Home home, FloatVar x, FloatNum l, FloatNum u, Reify r);
01103 GECODE_FLOAT_EXPORT void
01104 dom(Home home, FloatVar x, FloatVar d);
01106 GECODE_FLOAT_EXPORT void
01107 dom(Home home, const FloatVarArgs& x, const FloatVarArgs& d);
01109
01118 GECODE_FLOAT_EXPORT void
01119 rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1);
01123 GECODE_FLOAT_EXPORT void
01124 rel(Home home, FloatVar x, FloatRelType frt, FloatVal c);
01128 GECODE_FLOAT_EXPORT void
01129 rel(Home home, FloatVar x, FloatRelType frt, FloatVal c, Reify r);
01133 GECODE_FLOAT_EXPORT void
01134 rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1, Reify r);
01138 GECODE_FLOAT_EXPORT void
01139 rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c);
01143 GECODE_FLOAT_EXPORT void
01144 rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVar y);
01151 GECODE_FLOAT_EXPORT void
01152 ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z);
01153
01154 }
01155
01156
01157 namespace Gecode {
01158
01167 GECODE_FLOAT_EXPORT void
01168 min(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01172 GECODE_FLOAT_EXPORT void
01173 min(Home home, const FloatVarArgs& x, FloatVar y);
01176 GECODE_FLOAT_EXPORT void
01177 max(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01181 GECODE_FLOAT_EXPORT void
01182 max(Home home, const FloatVarArgs& x, FloatVar y);
01183
01186 GECODE_FLOAT_EXPORT void
01187 abs(Home home, FloatVar x0, FloatVar x1);
01188
01191 GECODE_FLOAT_EXPORT void
01192 mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01193
01196 GECODE_FLOAT_EXPORT void
01197 sqr(Home home, FloatVar x0, FloatVar x1);
01198
01201 GECODE_FLOAT_EXPORT void
01202 sqrt(Home home, FloatVar x0, FloatVar x1);
01203
01206 GECODE_FLOAT_EXPORT void
01207 pow(Home home, FloatVar x0, int n, FloatVar x1);
01208
01211 GECODE_FLOAT_EXPORT void
01212 nroot(Home home, FloatVar x0, int n, FloatVar x1);
01213
01216 GECODE_FLOAT_EXPORT void
01217 div(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01218 #ifdef GECODE_HAS_MPFR
01219
01221 GECODE_FLOAT_EXPORT void
01222 exp(Home home, FloatVar x0, FloatVar x1);
01225 GECODE_FLOAT_EXPORT void
01226 log(Home home, FloatVar x0, FloatVar x1);
01229 GECODE_FLOAT_EXPORT void
01230 pow(Home home, FloatNum base, FloatVar x0, FloatVar x1);
01233 GECODE_FLOAT_EXPORT void
01234 log(Home home, FloatNum base, FloatVar x0, FloatVar x1);
01237 GECODE_FLOAT_EXPORT void
01238 asin(Home home, FloatVar x0, FloatVar x1);
01241 GECODE_FLOAT_EXPORT void
01242 sin(Home home, FloatVar x0, FloatVar x1);
01245 GECODE_FLOAT_EXPORT void
01246 acos(Home home, FloatVar x0, FloatVar x1);
01249 GECODE_FLOAT_EXPORT void
01250 cos(Home home, FloatVar x0, FloatVar x1);
01253 GECODE_FLOAT_EXPORT void
01254 atan(Home home, FloatVar x0, FloatVar x1);
01257 GECODE_FLOAT_EXPORT void
01258 tan(Home home, FloatVar x0, FloatVar x1);
01260 #endif
01261
01276 GECODE_FLOAT_EXPORT void
01277 linear(Home home, const FloatVarArgs& x,
01278 FloatRelType frt, FloatVal c);
01289 GECODE_FLOAT_EXPORT void
01290 linear(Home home, const FloatVarArgs& x,
01291 FloatRelType frt, FloatVar y);
01302 GECODE_FLOAT_EXPORT void
01303 linear(Home home, const FloatVarArgs& x,
01304 FloatRelType frt, FloatVal c, Reify r);
01315 GECODE_FLOAT_EXPORT void
01316 linear(Home home, const FloatVarArgs& x,
01317 FloatRelType frt, FloatVar y, Reify r);
01330 GECODE_FLOAT_EXPORT void
01331 linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01332 FloatRelType frt, FloatVal c);
01346 GECODE_FLOAT_EXPORT void
01347 linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01348 FloatRelType frt, FloatVar y);
01362 GECODE_FLOAT_EXPORT void
01363 linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01364 FloatRelType frt, FloatVal c, Reify r);
01378 GECODE_FLOAT_EXPORT void
01379 linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01380 FloatRelType frt, FloatVar y, Reify r);
01381
01382
01388
01389 GECODE_FLOAT_EXPORT void
01390 channel(Home home, FloatVar x0, IntVar x1);
01392 void
01393 channel(Home home, IntVar x0, FloatVar x1);
01395 GECODE_FLOAT_EXPORT void
01396 channel(Home home, FloatVar x0, BoolVar x1);
01398 void
01399 channel(Home home, BoolVar x0, FloatVar x1);
01401
01402 }
01403
01404 #include <gecode/float/channel.hpp>
01405
01406 namespace Gecode {
01407
01416
01417 GECODE_FLOAT_EXPORT void
01418 wait(Home home, FloatVar x, std::function<void(Space& home)> c);
01420 GECODE_FLOAT_EXPORT void
01421 wait(Home home, const FloatVarArgs& x, std::function<void(Space& home)> c);
01423
01424 }
01425
01426 namespace Gecode {
01427
01441 typedef std::function<bool(const Space& home, FloatVar x, int i)>
01442 FloatBranchFilter;
01443
01454 typedef std::function<double(const Space& home, FloatVar x, int i)>
01455 FloatBranchMerit;
01456
01462 class FloatNumBranch {
01463 public:
01465 FloatNum n;
01467 bool l;
01468 };
01469
01480 typedef std::function<FloatNumBranch(const Space& home, FloatVar x, int i)>
01481 FloatBranchVal;
01482
01494 typedef std::function<void(Space& home, unsigned int a,
01495 FloatVar x, int i, FloatNumBranch nl)>
01496 FloatBranchCommit;
01497
01498 }
01499
01500 #include <gecode/float/branch/traits.hpp>
01501
01502 namespace Gecode {
01503
01509 class FloatAFC : public AFC {
01510 public:
01518 FloatAFC(void);
01520 FloatAFC(const FloatAFC& a);
01522 FloatAFC& operator =(const FloatAFC& a);
01530 FloatAFC(Home home, const FloatVarArgs& x, double d=1.0, bool share=true);
01541 void init(Home home, const FloatVarArgs& x, double d=1.0, bool share=true);
01542 };
01543
01544 }
01545
01546 #include <gecode/float/branch/afc.hpp>
01547
01548 namespace Gecode {
01549
01555 class FloatAction : public Action {
01556 public:
01564 FloatAction(void);
01566 FloatAction(const FloatAction& a);
01568 FloatAction& operator =(const FloatAction& a);
01577 GECODE_FLOAT_EXPORT
01578 FloatAction(Home home, const FloatVarArgs& x, double d=1.0,
01579 FloatBranchMerit bm=nullptr);
01591 GECODE_FLOAT_EXPORT void
01592 init(Home home, const FloatVarArgs& x, double d=1.0,
01593 FloatBranchMerit bm=nullptr);
01594 };
01595
01596 }
01597
01598 #include <gecode/float/branch/action.hpp>
01599
01600 namespace Gecode {
01601
01607 class FloatCHB : public CHB {
01608 public:
01616 FloatCHB(void);
01618 FloatCHB(const FloatCHB& chb);
01620 FloatCHB& operator =(const FloatCHB& chb);
01629 GECODE_FLOAT_EXPORT
01630 FloatCHB(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
01642 GECODE_FLOAT_EXPORT void
01643 init(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
01644 };
01645
01646 }
01647
01648 #include <gecode/float/branch/chb.hpp>
01649
01650 namespace Gecode {
01651
01653 typedef std::function<void(const Space &home, const Brancher& b,
01654 unsigned int a,
01655 FloatVar x, int i, const FloatNumBranch& n,
01656 std::ostream& o)>
01657 FloatVarValPrint;
01658
01659 }
01660
01661 namespace Gecode {
01662
01668 class FloatVarBranch : public VarBranch<FloatVar> {
01669 public:
01671 enum Select {
01672 SEL_NONE = 0,
01673 SEL_RND,
01674 SEL_MERIT_MIN,
01675 SEL_MERIT_MAX,
01676 SEL_DEGREE_MIN,
01677 SEL_DEGREE_MAX,
01678 SEL_AFC_MIN,
01679 SEL_AFC_MAX,
01680 SEL_ACTION_MIN,
01681 SEL_ACTION_MAX,
01682 SEL_CHB_MIN,
01683 SEL_CHB_MAX,
01684 SEL_MIN_MIN,
01685 SEL_MIN_MAX,
01686 SEL_MAX_MIN,
01687 SEL_MAX_MAX,
01688 SEL_SIZE_MIN,
01689 SEL_SIZE_MAX,
01690 SEL_DEGREE_SIZE_MIN,
01691 SEL_DEGREE_SIZE_MAX,
01692 SEL_AFC_SIZE_MIN,
01693 SEL_AFC_SIZE_MAX,
01694 SEL_ACTION_SIZE_MIN,
01695 SEL_ACTION_SIZE_MAX,
01696 SEL_CHB_SIZE_MIN,
01697 SEL_CHB_SIZE_MAX
01698 };
01699 protected:
01701 Select s;
01702 public:
01704 FloatVarBranch(void);
01706 FloatVarBranch(Rnd r);
01708 FloatVarBranch(Select s, BranchTbl t);
01710 FloatVarBranch(Select s, double, BranchTbl t);
01712 FloatVarBranch(Select s, FloatAFC a, BranchTbl t);
01714 FloatVarBranch(Select s, FloatAction a, BranchTbl t);
01716 FloatVarBranch(Select s, FloatCHB c, BranchTbl t);
01718 FloatVarBranch(Select s, FloatBranchMerit mf, BranchTbl t);
01720 Select select(void) const;
01722 void expand(Home home, const FloatVarArgs& x);
01723 };
01724
01725
01731
01732 FloatVarBranch FLOAT_VAR_NONE(void);
01734 FloatVarBranch FLOAT_VAR_RND(Rnd r);
01736 FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl=nullptr);
01738 FloatVarBranch FLOAT_VAR_MERIT_MAX(FloatBranchMerit bm, BranchTbl tbl=nullptr);
01740 FloatVarBranch FLOAT_VAR_DEGREE_MIN(BranchTbl tbl=nullptr);
01742 FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr);
01744 FloatVarBranch FLOAT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
01746 FloatVarBranch FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl=nullptr);
01748 FloatVarBranch FLOAT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
01750 FloatVarBranch FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl=nullptr);
01752 FloatVarBranch FLOAT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
01754 FloatVarBranch FLOAT_VAR_ACTION_MIN(FloatAction a, BranchTbl tbl=nullptr);
01756 FloatVarBranch FLOAT_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
01758 FloatVarBranch FLOAT_VAR_ACTION_MAX(FloatAction a, BranchTbl tbl=nullptr);
01760 FloatVarBranch FLOAT_VAR_CHB_MIN(BranchTbl tbl=nullptr);
01762 FloatVarBranch FLOAT_VAR_CHB_MIN(FloatCHB a, BranchTbl tbl=nullptr);
01764 FloatVarBranch FLOAT_VAR_CHB_MAX(BranchTbl tbl=nullptr);
01766 FloatVarBranch FLOAT_VAR_CHB_MAX(FloatCHB a, BranchTbl tbl=nullptr);
01768 FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl=nullptr);
01770 FloatVarBranch FLOAT_VAR_MIN_MAX(BranchTbl tbl=nullptr);
01772 FloatVarBranch FLOAT_VAR_MAX_MIN(BranchTbl tbl=nullptr);
01774 FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl=nullptr);
01776 FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl=nullptr);
01778 FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl=nullptr);
01780 FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr);
01782 FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr);
01784 FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01786 FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl=nullptr);
01788 FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01790 FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl=nullptr);
01792 FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01794 FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(FloatAction a, BranchTbl tbl=nullptr);
01796 FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01798 FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(FloatAction a, BranchTbl tbl=nullptr);
01800 FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr);
01802 FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(FloatCHB c, BranchTbl tbl=nullptr);
01804 FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr);
01806 FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(FloatCHB a, BranchTbl tbl=nullptr);
01808
01809 }
01810
01811 #include <gecode/float/branch/var.hpp>
01812
01813 namespace Gecode {
01814
01820 class FloatValBranch : public ValBranch<FloatVar> {
01821 public:
01823 enum Select {
01824 SEL_SPLIT_MIN,
01825 SEL_SPLIT_MAX,
01826 SEL_SPLIT_RND,
01827 SEL_VAL_COMMIT
01828 };
01829 protected:
01831 Select s;
01832 public:
01834 FloatValBranch(Select s = SEL_SPLIT_MIN);
01836 FloatValBranch(Rnd r);
01838 FloatValBranch(FloatBranchVal v, FloatBranchCommit c);
01840 Select select(void) const;
01841 };
01842
01848
01849 FloatValBranch FLOAT_VAL_SPLIT_MIN(void);
01851 FloatValBranch FLOAT_VAL_SPLIT_MAX(void);
01853 FloatValBranch FLOAT_VAL_SPLIT_RND(Rnd r);
01860 FloatValBranch FLOAT_VAL(FloatBranchVal v, FloatBranchCommit c=nullptr);
01862
01863 }
01864
01865 #include <gecode/float/branch/val.hpp>
01866
01867 namespace Gecode {
01868
01874 class FloatAssign : public ValBranch<FloatVar> {
01875 public:
01877 enum Select {
01878 SEL_MIN,
01879 SEL_MAX,
01880 SEL_RND,
01881 SEL_VAL_COMMIT
01882 };
01883 protected:
01885 Select s;
01886 public:
01888 FloatAssign(Select s = SEL_MIN);
01890 FloatAssign(Rnd r);
01892 FloatAssign(FloatBranchVal v, FloatBranchCommit c);
01894 Select select(void) const;
01895 };
01896
01902
01903 FloatAssign FLOAT_ASSIGN_MIN(void);
01905 FloatAssign FLOAT_ASSIGN_MAX(void);
01907 FloatAssign FLOAT_ASSIGN_RND(Rnd r);
01913 FloatAssign FLOAT_ASSIGN(FloatBranchVal v, FloatBranchCommit c=nullptr);
01915
01916 }
01917
01918 #include <gecode/float/branch/assign.hpp>
01919
01920 namespace Gecode {
01921
01927 GECODE_FLOAT_EXPORT void
01928 branch(Home home, const FloatVarArgs& x,
01929 FloatVarBranch vars, FloatValBranch vals,
01930 FloatBranchFilter bf=nullptr,
01931 FloatVarValPrint vvp=nullptr);
01937 GECODE_FLOAT_EXPORT void
01938 branch(Home home, const FloatVarArgs& x,
01939 TieBreak<FloatVarBranch> vars, FloatValBranch vals,
01940 FloatBranchFilter bf=nullptr,
01941 FloatVarValPrint vvp=nullptr);
01947 GECODE_FLOAT_EXPORT void
01948 branch(Home home, FloatVar x, FloatValBranch vals,
01949 FloatVarValPrint vvp=nullptr);
01950
01956 GECODE_FLOAT_EXPORT void
01957 assign(Home home, const FloatVarArgs& x,
01958 FloatVarBranch vars, FloatAssign vals,
01959 FloatBranchFilter bf=nullptr,
01960 FloatVarValPrint vvp=nullptr);
01966 GECODE_FLOAT_EXPORT void
01967 assign(Home home, const FloatVarArgs& x,
01968 TieBreak<FloatVarBranch> vars, FloatAssign vals,
01969 FloatBranchFilter bf=nullptr,
01970 FloatVarValPrint vvp=nullptr);
01976 GECODE_FLOAT_EXPORT void
01977 assign(Home home, FloatVar x, FloatAssign vals,
01978 FloatVarValPrint vvp=nullptr);
01979
01980 }
01981
01982 namespace Gecode {
01983
01989 void
01990 branch(Home home, const FloatVarArgs& x, FloatValBranch vals,
01991 FloatBranchFilter bf=nullptr,
01992 FloatVarValPrint vvp=nullptr);
01998 void
01999 assign(Home home, const FloatVarArgs& x, FloatAssign vals,
02000 FloatBranchFilter bf=nullptr,
02001 FloatVarValPrint vvp=nullptr);
02002
02003 }
02004
02005 #include <gecode/float/branch.hpp>
02006
02007 namespace Gecode {
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030 GECODE_FLOAT_EXPORT void
02031 relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx,
02032 Rnd r, double p);
02033
02034 }
02035
02036 #include <gecode/float/trace/trace-view.hpp>
02037
02038 namespace Gecode {
02039
02049 class FloatTraceDelta {
02050 protected:
02052 Float::FloatView n;
02054 const Delta& d;
02055 public:
02057
02058
02059 FloatTraceDelta(Float::FloatTraceView o, Float::FloatView n,
02060 const Delta& d);
02062
02063
02064
02065 FloatNum min(void) const;
02067 FloatNum max(void) const;
02069 };
02070
02071 }
02072
02073 #include <gecode/float/trace/delta.hpp>
02074
02075 #include <gecode/float/trace/traits.hpp>
02076
02077 namespace Gecode {
02078
02083 typedef ViewTracer<Float::FloatView> FloatTracer;
02088 typedef ViewTraceRecorder<Float::FloatView> FloatTraceRecorder;
02089
02094 class GECODE_FLOAT_EXPORT StdFloatTracer : public FloatTracer {
02095 protected:
02097 std::ostream& os;
02098 public:
02100 StdFloatTracer(std::ostream& os0 = std::cerr);
02102 virtual void init(const Space& home, const FloatTraceRecorder& t);
02104 virtual void prune(const Space& home, const FloatTraceRecorder& t,
02105 const ViewTraceInfo& vti, int i, FloatTraceDelta& d);
02107 virtual void fix(const Space& home, const FloatTraceRecorder& t);
02109 virtual void fail(const Space& home, const FloatTraceRecorder& t);
02111 virtual void done(const Space& home, const FloatTraceRecorder& t);
02113 static StdFloatTracer def;
02114 };
02115
02116
02121 GECODE_FLOAT_EXPORT void
02122 trace(Home home, const FloatVarArgs& x,
02123 TraceFilter tf,
02124 int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
02125 FloatTracer& t = StdFloatTracer::def);
02130 void
02131 trace(Home home, const FloatVarArgs& x,
02132 int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
02133 FloatTracer& t = StdFloatTracer::def);
02134
02135 }
02136
02137 #include <gecode/float/trace.hpp>
02138
02139 #endif
02140
02141
02142
02143