Generated on Tue May 22 09:39:41 2018 for Gecode by doxygen 1.6.3

float.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2002
00010  *     Guido Tack, 2004
00011  *     Vincent Barichard, 2012
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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  * Configure linking
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 // Configure auto-linking
00074 #ifndef GECODE_BUILD_FLOAT
00075 #define GECODE_LIBRARY_NAME "Float"
00076 #include <gecode/support/auto-link.hpp>
00077 #endif
00078 
00079 // Include interval implementation
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   // Forward declaration
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    * This is used for the MSVC compiler for x64 or x86 with SSE enabled.
00135    *
00136    */
00138   typedef 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   /* transcendental functions: exp, log */
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     template<class InputIterator>
00964     FloatValArgs(InputIterator first, InputIterator last);
00966     FloatValArgs(int n, const FloatVal* e);
00968     FloatValArgs(const ArgArray<FloatVal>& a);
00969 
00971     GECODE_FLOAT_EXPORT
00972     static FloatValArgs create(int n, FloatVal start, int inc=1);
00974   };
00975 
00977   class FloatVarArgs : public VarArgArray<FloatVar> {
00978   public:
00980 
00981 
00982     FloatVarArgs(void) {}
00984     explicit FloatVarArgs(int n) : VarArgArray<FloatVar>(n) {}
00986     FloatVarArgs(const FloatVarArgs& a) : VarArgArray<FloatVar>(a) {}
00988     FloatVarArgs(const VarArray<FloatVar>& a) : VarArgArray<FloatVar>(a) {}
00990     FloatVarArgs(const std::vector<FloatVar>& a) : VarArgArray<FloatVar>(a) {}
00992     template<class InputIterator>
00993     FloatVarArgs(InputIterator first, InputIterator last)
00994     : VarArgArray<FloatVar>(first,last) {}
01006     GECODE_FLOAT_EXPORT
01007     FloatVarArgs(Space& home, int n, FloatNum min, FloatNum max);
01009   };
01011 
01027   class FloatVarArray : public VarArray<FloatVar> {
01028   public:
01030 
01031 
01032     FloatVarArray(void);
01034     FloatVarArray(Space& home, int n);
01036     FloatVarArray(const FloatVarArray& a);
01038     FloatVarArray(Space& home, const FloatVarArgs& a);
01050     GECODE_FLOAT_EXPORT
01051     FloatVarArray(Space& home, int n, FloatNum min, FloatNum max);
01053   };
01054 
01055 }
01056 
01057 #include <gecode/float/array.hpp>
01058 
01059 namespace Gecode {
01060 
01065   enum FloatRelType {
01066     FRT_EQ, 
01067     FRT_NQ, 
01068     FRT_LQ, 
01069     FRT_LE, 
01070     FRT_GQ, 
01071     FRT_GR 
01072   };
01073 
01081 
01082   GECODE_FLOAT_EXPORT void
01083   dom(Home home, FloatVar x, FloatVal n);
01085   GECODE_FLOAT_EXPORT void
01086   dom(Home home, const FloatVarArgs& x, FloatVal n);
01088   GECODE_FLOAT_EXPORT void
01089   dom(Home home, FloatVar x, FloatNum l, FloatNum m);
01091   GECODE_FLOAT_EXPORT void
01092   dom(Home home, const FloatVarArgs& x, FloatNum l, FloatNum u);
01094   GECODE_FLOAT_EXPORT void
01095   dom(Home home, FloatVar x, FloatVal n, Reify r);
01097   GECODE_FLOAT_EXPORT void
01098   dom(Home home, FloatVar x, FloatNum l, FloatNum u, Reify r);
01100   GECODE_FLOAT_EXPORT void
01101   dom(Home home, FloatVar x, FloatVar d);
01103   GECODE_FLOAT_EXPORT void
01104   dom(Home home, const FloatVarArgs& x, const FloatVarArgs& d);
01106 
01115   GECODE_FLOAT_EXPORT void
01116   rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1);
01120   GECODE_FLOAT_EXPORT void
01121   rel(Home home, FloatVar x, FloatRelType frt, FloatVal c);
01125   GECODE_FLOAT_EXPORT void
01126   rel(Home home, FloatVar x, FloatRelType frt, FloatVal c, Reify r);
01130   GECODE_FLOAT_EXPORT void
01131   rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1, Reify r);
01135   GECODE_FLOAT_EXPORT void
01136   rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c);
01140   GECODE_FLOAT_EXPORT void
01141   rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVar y);
01148   GECODE_FLOAT_EXPORT void
01149   ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z);
01150 
01151 }
01152 
01153 
01154 namespace Gecode {
01155 
01164   GECODE_FLOAT_EXPORT void
01165   min(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01169   GECODE_FLOAT_EXPORT void
01170   min(Home home, const FloatVarArgs& x, FloatVar y);
01173   GECODE_FLOAT_EXPORT void
01174   max(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01178   GECODE_FLOAT_EXPORT void
01179   max(Home home, const FloatVarArgs& x, FloatVar y);
01180 
01183   GECODE_FLOAT_EXPORT void
01184   abs(Home home, FloatVar x0, FloatVar x1);
01185 
01188   GECODE_FLOAT_EXPORT void
01189   mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01190 
01193   GECODE_FLOAT_EXPORT void
01194   sqr(Home home, FloatVar x0, FloatVar x1);
01195 
01198   GECODE_FLOAT_EXPORT void
01199   sqrt(Home home, FloatVar x0, FloatVar x1);
01200 
01203   GECODE_FLOAT_EXPORT void
01204   pow(Home home, FloatVar x0, int n, FloatVar x1);
01205 
01208   GECODE_FLOAT_EXPORT void
01209   nroot(Home home, FloatVar x0, int n, FloatVar x1);
01210 
01213   GECODE_FLOAT_EXPORT void
01214   div(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01215 #ifdef GECODE_HAS_MPFR
01216 
01218   GECODE_FLOAT_EXPORT void
01219   exp(Home home, FloatVar x0, FloatVar x1);
01222   GECODE_FLOAT_EXPORT void
01223   log(Home home, FloatVar x0, FloatVar x1);
01226   GECODE_FLOAT_EXPORT void
01227   pow(Home home, FloatNum base, FloatVar x0, FloatVar x1);
01230   GECODE_FLOAT_EXPORT void
01231   log(Home home, FloatNum base, FloatVar x0, FloatVar x1);
01234   GECODE_FLOAT_EXPORT void
01235   asin(Home home, FloatVar x0, FloatVar x1);
01238   GECODE_FLOAT_EXPORT void
01239   sin(Home home, FloatVar x0, FloatVar x1);
01242   GECODE_FLOAT_EXPORT void
01243   acos(Home home, FloatVar x0, FloatVar x1);
01246   GECODE_FLOAT_EXPORT void
01247   cos(Home home, FloatVar x0, FloatVar x1);
01250   GECODE_FLOAT_EXPORT void
01251   atan(Home home, FloatVar x0, FloatVar x1);
01254   GECODE_FLOAT_EXPORT void
01255   tan(Home home, FloatVar x0, FloatVar x1);
01257 #endif
01258 
01273   GECODE_FLOAT_EXPORT void
01274   linear(Home home, const FloatVarArgs& x,
01275          FloatRelType frt, FloatVal c);
01286   GECODE_FLOAT_EXPORT void
01287   linear(Home home, const FloatVarArgs& x,
01288          FloatRelType frt, FloatVar y);
01299   GECODE_FLOAT_EXPORT void
01300   linear(Home home, const FloatVarArgs& x,
01301          FloatRelType frt, FloatVal c, Reify r);
01312   GECODE_FLOAT_EXPORT void
01313   linear(Home home, const FloatVarArgs& x,
01314          FloatRelType frt, FloatVar y, Reify r);
01327   GECODE_FLOAT_EXPORT void
01328   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01329          FloatRelType frt, FloatVal c);
01343   GECODE_FLOAT_EXPORT void
01344   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01345          FloatRelType frt, FloatVar y);
01359   GECODE_FLOAT_EXPORT void
01360   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01361          FloatRelType frt, FloatVal c, Reify r);
01375   GECODE_FLOAT_EXPORT void
01376   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01377          FloatRelType frt, FloatVar y, Reify r);
01378 
01379 
01385 
01386   GECODE_FLOAT_EXPORT void
01387   channel(Home home, FloatVar x0, IntVar x1);
01389   void
01390   channel(Home home, IntVar x0, FloatVar x1);
01392   GECODE_FLOAT_EXPORT void
01393   channel(Home home, FloatVar x0, BoolVar x1);
01395   void
01396   channel(Home home, BoolVar x0, FloatVar x1);
01398 
01399 }
01400 
01401 #include <gecode/float/channel.hpp>
01402 
01403 namespace Gecode {
01404 
01413 
01414   GECODE_FLOAT_EXPORT void
01415   wait(Home home, FloatVar x, std::function<void(Space& home)> c);
01417   GECODE_FLOAT_EXPORT void
01418   wait(Home home, const FloatVarArgs& x, std::function<void(Space& home)> c);
01420 
01421 }
01422 
01423 namespace Gecode {
01424 
01438   typedef std::function<bool(const Space& home, FloatVar x, int i)>
01439     FloatBranchFilter;
01440 
01451   typedef std::function<double(const Space& home, FloatVar x, int i)>
01452     FloatBranchMerit;
01453 
01459   class FloatNumBranch {
01460   public:
01462     FloatNum n;
01464     bool l;
01465   };
01466 
01477   typedef std::function<FloatNumBranch(const Space& home, FloatVar x, int i)>
01478     FloatBranchVal;
01479 
01491   typedef std::function<void(Space& home, unsigned int a,
01492                              FloatVar x, int i, FloatNumBranch nl)>
01493     FloatBranchCommit;
01494 
01495 }
01496 
01497 #include <gecode/float/branch/traits.hpp>
01498 
01499 namespace Gecode {
01500 
01506   class FloatAFC : public AFC {
01507   public:
01515     FloatAFC(void);
01517     FloatAFC(const FloatAFC& a);
01519     FloatAFC& operator =(const FloatAFC& a);
01527     FloatAFC(Home home, const FloatVarArgs& x, double d=1.0, bool share=true);
01538     void init(Home home, const FloatVarArgs& x, double d=1.0, bool share=true);
01539   };
01540 
01541 }
01542 
01543 #include <gecode/float/branch/afc.hpp>
01544 
01545 namespace Gecode {
01546 
01552   class FloatAction : public Action {
01553   public:
01561     FloatAction(void);
01563     FloatAction(const FloatAction& a);
01565     FloatAction& operator =(const FloatAction& a);
01574     GECODE_FLOAT_EXPORT
01575     FloatAction(Home home, const FloatVarArgs& x, double d=1.0,
01576                   FloatBranchMerit bm=nullptr);
01588     GECODE_FLOAT_EXPORT void
01589     init(Home home, const FloatVarArgs& x, double d=1.0,
01590          FloatBranchMerit bm=nullptr);
01591   };
01592 
01593 }
01594 
01595 #include <gecode/float/branch/action.hpp>
01596 
01597 namespace Gecode {
01598 
01604   class FloatCHB : public CHB {
01605   public:
01613     FloatCHB(void);
01615     FloatCHB(const FloatCHB& chb);
01617     FloatCHB& operator =(const FloatCHB& chb);
01626     GECODE_FLOAT_EXPORT
01627     FloatCHB(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
01639     GECODE_FLOAT_EXPORT void
01640     init(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
01641   };
01642 
01643 }
01644 
01645 #include <gecode/float/branch/chb.hpp>
01646 
01647 namespace Gecode {
01648 
01650   typedef std::function<void(const Space &home, const Brancher& b,
01651                              unsigned int a,
01652                              FloatVar x, int i, const FloatNumBranch& n,
01653                              std::ostream& o)>
01654     FloatVarValPrint;
01655 
01656 }
01657 
01658 namespace Gecode {
01659 
01665   class FloatVarBranch : public VarBranch<FloatVar> {
01666   public:
01668     enum Select {
01669       SEL_NONE = 0,        
01670       SEL_RND,             
01671       SEL_MERIT_MIN,       
01672       SEL_MERIT_MAX,       
01673       SEL_DEGREE_MIN,      
01674       SEL_DEGREE_MAX,      
01675       SEL_AFC_MIN,         
01676       SEL_AFC_MAX,         
01677       SEL_ACTION_MIN,      
01678       SEL_ACTION_MAX,      
01679       SEL_CHB_MIN,         
01680       SEL_CHB_MAX,         
01681       SEL_MIN_MIN,         
01682       SEL_MIN_MAX,         
01683       SEL_MAX_MIN,         
01684       SEL_MAX_MAX,         
01685       SEL_SIZE_MIN,        
01686       SEL_SIZE_MAX,        
01687       SEL_DEGREE_SIZE_MIN, 
01688       SEL_DEGREE_SIZE_MAX, 
01689       SEL_AFC_SIZE_MIN,    
01690       SEL_AFC_SIZE_MAX,    
01691       SEL_ACTION_SIZE_MIN, 
01692       SEL_ACTION_SIZE_MAX, 
01693       SEL_CHB_SIZE_MIN,    
01694       SEL_CHB_SIZE_MAX     
01695     };
01696   protected:
01698     Select s;
01699   public:
01701     FloatVarBranch(void);
01703     FloatVarBranch(Rnd r);
01705     FloatVarBranch(Select s, BranchTbl t);
01707     FloatVarBranch(Select s, double, BranchTbl t);
01709     FloatVarBranch(Select s, FloatAFC a, BranchTbl t);
01711     FloatVarBranch(Select s, FloatAction a, BranchTbl t);
01713     FloatVarBranch(Select s, FloatCHB c, BranchTbl t);
01715     FloatVarBranch(Select s, FloatBranchMerit mf, BranchTbl t);
01717     Select select(void) const;
01719     void expand(Home home, const FloatVarArgs& x);
01720   };
01721 
01722 
01728 
01729   FloatVarBranch FLOAT_VAR_NONE(void);
01731   FloatVarBranch FLOAT_VAR_RND(Rnd r);
01733   FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl=nullptr);
01735   FloatVarBranch FLOAT_VAR_MERIT_MAX(FloatBranchMerit bm, BranchTbl tbl=nullptr);
01737   FloatVarBranch FLOAT_VAR_DEGREE_MIN(BranchTbl tbl=nullptr);
01739   FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr);
01741   FloatVarBranch FLOAT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
01743   FloatVarBranch FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl=nullptr);
01745   FloatVarBranch FLOAT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
01747   FloatVarBranch FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl=nullptr);
01749   FloatVarBranch FLOAT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
01751   FloatVarBranch FLOAT_VAR_ACTION_MIN(FloatAction a, BranchTbl tbl=nullptr);
01753   FloatVarBranch FLOAT_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
01755   FloatVarBranch FLOAT_VAR_ACTION_MAX(FloatAction a, BranchTbl tbl=nullptr);
01757   FloatVarBranch FLOAT_VAR_CHB_MIN(BranchTbl tbl=nullptr);
01759   FloatVarBranch FLOAT_VAR_CHB_MIN(FloatCHB a, BranchTbl tbl=nullptr);
01761   FloatVarBranch FLOAT_VAR_CHB_MAX(BranchTbl tbl=nullptr);
01763   FloatVarBranch FLOAT_VAR_CHB_MAX(FloatCHB a, BranchTbl tbl=nullptr);
01765   FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl=nullptr);
01767   FloatVarBranch FLOAT_VAR_MIN_MAX(BranchTbl tbl=nullptr);
01769   FloatVarBranch FLOAT_VAR_MAX_MIN(BranchTbl tbl=nullptr);
01771   FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl=nullptr);
01773   FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl=nullptr);
01775   FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl=nullptr);
01777   FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr);
01779   FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr);
01781   FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01783   FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl=nullptr);
01785   FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01787   FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl=nullptr);
01789   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01791   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(FloatAction a, BranchTbl tbl=nullptr);
01793   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01795   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(FloatAction a, BranchTbl tbl=nullptr);
01797   FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr);
01799   FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(FloatCHB c, BranchTbl tbl=nullptr);
01801   FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr);
01803   FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(FloatCHB a, BranchTbl tbl=nullptr);
01805 
01806 }
01807 
01808 #include <gecode/float/branch/var.hpp>
01809 
01810 namespace Gecode {
01811 
01817   class FloatValBranch : public ValBranch<FloatVar> {
01818   public:
01820     enum Select {
01821       SEL_SPLIT_MIN, 
01822       SEL_SPLIT_MAX, 
01823       SEL_SPLIT_RND,  
01824       SEL_VAL_COMMIT  
01825     };
01826   protected:
01828     Select s;
01829   public:
01831     FloatValBranch(Select s = SEL_SPLIT_MIN);
01833     FloatValBranch(Rnd r);
01835     FloatValBranch(FloatBranchVal v, FloatBranchCommit c);
01837     Select select(void) const;
01838   };
01839 
01845 
01846   FloatValBranch FLOAT_VAL_SPLIT_MIN(void);
01848   FloatValBranch FLOAT_VAL_SPLIT_MAX(void);
01850   FloatValBranch FLOAT_VAL_SPLIT_RND(Rnd r);
01857   FloatValBranch FLOAT_VAL(FloatBranchVal v, FloatBranchCommit c=nullptr);
01859 
01860 }
01861 
01862 #include <gecode/float/branch/val.hpp>
01863 
01864 namespace Gecode {
01865 
01871   class FloatAssign : public ValBranch<FloatVar> {
01872   public:
01874     enum Select {
01875       SEL_MIN,       
01876       SEL_MAX,       
01877       SEL_RND,       
01878       SEL_VAL_COMMIT 
01879     };
01880   protected:
01882     Select s;
01883   public:
01885     FloatAssign(Select s = SEL_MIN);
01887     FloatAssign(Rnd r);
01889     FloatAssign(FloatBranchVal v, FloatBranchCommit c);
01891     Select select(void) const;
01892   };
01893 
01899 
01900   FloatAssign FLOAT_ASSIGN_MIN(void);
01902   FloatAssign FLOAT_ASSIGN_MAX(void);
01904   FloatAssign FLOAT_ASSIGN_RND(Rnd r);
01910   FloatAssign FLOAT_ASSIGN(FloatBranchVal v, FloatBranchCommit c=nullptr);
01912 
01913 }
01914 
01915 #include <gecode/float/branch/assign.hpp>
01916 
01917 namespace Gecode {
01918 
01924   GECODE_FLOAT_EXPORT void
01925   branch(Home home, const FloatVarArgs& x,
01926          FloatVarBranch vars, FloatValBranch vals,
01927          FloatBranchFilter bf=nullptr,
01928          FloatVarValPrint vvp=nullptr);
01934   GECODE_FLOAT_EXPORT void
01935   branch(Home home, const FloatVarArgs& x,
01936          TieBreak<FloatVarBranch> vars, FloatValBranch vals,
01937          FloatBranchFilter bf=nullptr,
01938          FloatVarValPrint vvp=nullptr);
01944   GECODE_FLOAT_EXPORT void
01945   branch(Home home, FloatVar x, FloatValBranch vals,
01946          FloatVarValPrint vvp=nullptr);
01947 
01953   GECODE_FLOAT_EXPORT void
01954   assign(Home home, const FloatVarArgs& x, FloatAssign vals,
01955          FloatBranchFilter bf=nullptr,
01956          FloatVarValPrint vvp=nullptr);
01962   GECODE_FLOAT_EXPORT void
01963   assign(Home home, FloatVar x, FloatAssign vals,
01964          FloatVarValPrint vvp=nullptr);
01966 
01967 }
01968 
01969 namespace Gecode {
01970 
01971   /*
01972    * \brief Relaxed assignment of variables in \a x from values in \a sx
01973    *
01974    * The variables in \a x are assigned values from the assigned variables
01975    * in the solution \a sx with a relaxation probability \a p. That is,
01976    * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
01977    * assigned a value from \a sx.
01978    *
01979    * The random numbers are generated from the generator \a r. At least
01980    * one variable will not be assigned: in case the relaxation attempt
01981    * would suggest that all variables should be assigned, a single
01982    * variable will be selected randomly to remain unassigned.
01983    *
01984    * Throws an exception of type Float::ArgumentSizeMismatch, if \a x and
01985    * \a sx are of different size.
01986    *
01987    * Throws an exception of type Float::OutOfLimits, if \a p is not between
01988    * \a 0.0 and \a 1.0.
01989    *
01990    * \ingroup TaskModeFloat
01991    */
01992   GECODE_FLOAT_EXPORT void
01993   relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx,
01994         Rnd r, double p);
01995 
01996 }
01997 
01998 #include <gecode/float/trace/trace-view.hpp>
01999 
02000 namespace Gecode {
02001 
02011   class FloatTraceDelta {
02012   protected:
02014     Float::FloatView n;
02016     const Delta& d;
02017   public:
02019 
02020 
02021     FloatTraceDelta(Float::FloatTraceView o, Float::FloatView n,
02022                     const Delta& d);
02024 
02025 
02026 
02027     FloatNum min(void) const;
02029     FloatNum max(void) const;
02031   };
02032 
02033 }
02034 
02035 #include <gecode/float/trace/delta.hpp>
02036 
02037 #include <gecode/float/trace/traits.hpp>
02038 
02039 namespace Gecode {
02040 
02045   typedef ViewTracer<Float::FloatView> FloatTracer;
02050   typedef ViewTraceRecorder<Float::FloatView> FloatTraceRecorder;
02051 
02056   class GECODE_FLOAT_EXPORT StdFloatTracer : public FloatTracer {
02057   protected:
02059     std::ostream& os;
02060   public:
02062     StdFloatTracer(std::ostream& os0 = std::cerr);
02064     virtual void init(const Space& home, const FloatTraceRecorder& t);
02066     virtual void prune(const Space& home, const FloatTraceRecorder& t,
02067                        const ViewTraceInfo& vti, int i, FloatTraceDelta& d);
02069     virtual void fix(const Space& home, const FloatTraceRecorder& t);
02071     virtual void fail(const Space& home, const FloatTraceRecorder& t);
02073     virtual void done(const Space& home, const FloatTraceRecorder& t);
02075     static StdFloatTracer def;
02076   };
02077 
02078 
02083   GECODE_FLOAT_EXPORT void
02084   trace(Home home, const FloatVarArgs& x,
02085         TraceFilter tf,
02086         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
02087         FloatTracer& t = StdFloatTracer::def);
02092   void
02093   trace(Home home, const FloatVarArgs& x,
02094         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
02095         FloatTracer& t = StdFloatTracer::def);
02096 
02097 }
02098 
02099 #include <gecode/float/trace.hpp>
02100 
02101 #endif
02102 
02103 // IFDEF: GECODE_HAS_FLOAT_VARS
02104 // STATISTICS: float-post
02105