Generated on Tue Apr 18 10:21:32 2017 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  *  Last modified:
00014  *     $Date: 2017-04-10 13:21:37 +0200 (Mon, 10 Apr 2017) $ by $Author: schulte $
00015  *     $Revision: 15631 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #ifndef __GECODE_FLOAT_HH__
00043 #define __GECODE_FLOAT_HH__
00044 
00045 #include <climits>
00046 #include <cfloat>
00047 #include <iostream>
00048 
00049 #include <functional>
00050 
00051 #include <gecode/kernel.hh>
00052 #include <gecode/int.hh>
00053 
00054 /*
00055  * Configure linking
00056  *
00057  */
00058 #if !defined(GECODE_STATIC_LIBS) && \
00059     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00060 
00061 #ifdef GECODE_BUILD_FLOAT
00062 #define GECODE_FLOAT_EXPORT __declspec( dllexport )
00063 #else
00064 #define GECODE_FLOAT_EXPORT __declspec( dllimport )
00065 #endif
00066 
00067 #else
00068 
00069 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00070 #define GECODE_FLOAT_EXPORT __attribute__ ((visibility("default")))
00071 #else
00072 #define GECODE_FLOAT_EXPORT
00073 #endif
00074 
00075 #endif
00076 
00077 // Configure auto-linking
00078 #ifndef GECODE_BUILD_FLOAT
00079 #define GECODE_LIBRARY_NAME "Float"
00080 #include <gecode/support/auto-link.hpp>
00081 #endif
00082 
00083 // Include interval implementation
00084 #include <gecode/third-party/boost/numeric/interval.hpp>
00085 
00097 #include <gecode/float/exception.hpp>
00098 
00099 #include <gecode/float/nextafter.hpp>
00100 
00101 namespace Gecode {
00102 
00110   typedef double FloatNum;
00111 
00113   FloatNum pi_half_lower(void);
00115   FloatNum pi_half_upper(void);
00117   FloatNum pi_lower(void);
00119   FloatNum pi_upper(void);
00121   FloatNum pi_twice_lower(void);
00123   FloatNum pi_twice_upper(void);
00124 
00125   // Forward declaration
00126   class FloatVal;
00127 
00128 }
00129 
00130 #include <gecode/float/num.hpp>
00131 
00132 namespace Gecode { namespace Float {
00133 
00134 
00135 #if defined(_MSC_VER) && (defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP > 0)))
00136 
00137   /*
00138    * This is used for the MSVC compiler for x64 or x86 with SSE enabled.
00139    *
00140    */
00142   typedef gecode_boost::numeric::interval_lib::rounded_arith_std<FloatNum>
00143     RoundingBase;
00144 
00145 #else
00146 
00148   typedef gecode_boost::numeric::interval_lib::rounded_arith_opp<FloatNum>
00149     RoundingBase;
00150 
00151 #endif
00152 
00158   class Rounding : public RoundingBase {
00159   public:
00161 
00162 
00163     Rounding(void);
00165     ~Rounding(void);
00167 
00169 
00170 
00171     FloatNum add_down(FloatNum x, FloatNum y);
00173     FloatNum add_up  (FloatNum x, FloatNum y);
00175     FloatNum sub_down(FloatNum x, FloatNum y);
00177     FloatNum sub_up  (FloatNum x, FloatNum y);
00179     FloatNum mul_down(FloatNum x, FloatNum y);
00181     FloatNum mul_up  (FloatNum x, FloatNum y);
00183     FloatNum div_down(FloatNum x, FloatNum y);
00185     FloatNum div_up  (FloatNum x, FloatNum y);
00187     FloatNum sqrt_down(FloatNum x);
00189     FloatNum sqrt_up  (FloatNum x);
00191 
00193 
00194 
00195     FloatNum median(FloatNum x, FloatNum y);
00197     FloatNum int_down(FloatNum x);
00199     FloatNum int_up  (FloatNum x);
00201 
00202 #ifdef GECODE_HAS_MPFR
00203 
00204 
00205 
00206     GECODE_FLOAT_EXPORT FloatNum exp_down(FloatNum x);
00208     GECODE_FLOAT_EXPORT FloatNum exp_up  (FloatNum x);
00210     GECODE_FLOAT_EXPORT FloatNum log_down(FloatNum x);
00212     GECODE_FLOAT_EXPORT FloatNum log_up  (FloatNum x);
00214 
00216 
00217 
00218     GECODE_FLOAT_EXPORT FloatNum sin_down(FloatNum x);
00220     GECODE_FLOAT_EXPORT FloatNum sin_up  (FloatNum x);
00222     GECODE_FLOAT_EXPORT FloatNum cos_down(FloatNum x);
00224     GECODE_FLOAT_EXPORT FloatNum cos_up  (FloatNum x);
00226     GECODE_FLOAT_EXPORT FloatNum tan_down(FloatNum x);
00228     GECODE_FLOAT_EXPORT FloatNum tan_up  (FloatNum x);
00230 
00232 
00233 
00234     GECODE_FLOAT_EXPORT FloatNum asin_down(FloatNum x);
00236     GECODE_FLOAT_EXPORT FloatNum asin_up  (FloatNum x);
00238     GECODE_FLOAT_EXPORT FloatNum acos_down(FloatNum x);
00240     GECODE_FLOAT_EXPORT FloatNum acos_up  (FloatNum x);
00242     GECODE_FLOAT_EXPORT FloatNum atan_down(FloatNum x);
00244     GECODE_FLOAT_EXPORT FloatNum atan_up  (FloatNum x);
00246 
00248 
00249 
00250     GECODE_FLOAT_EXPORT FloatNum sinh_down(FloatNum x);
00252     GECODE_FLOAT_EXPORT FloatNum sinh_up  (FloatNum x);
00254     GECODE_FLOAT_EXPORT FloatNum cosh_down(FloatNum x);
00256     GECODE_FLOAT_EXPORT FloatNum cosh_up  (FloatNum x);
00258     GECODE_FLOAT_EXPORT FloatNum tanh_down(FloatNum x);
00260     GECODE_FLOAT_EXPORT FloatNum tanh_up  (FloatNum x);
00262 
00264 
00265 
00266     GECODE_FLOAT_EXPORT FloatNum asinh_down(FloatNum x);
00268     GECODE_FLOAT_EXPORT FloatNum asinh_up  (FloatNum x);
00270     GECODE_FLOAT_EXPORT FloatNum acosh_down(FloatNum x);
00272     GECODE_FLOAT_EXPORT FloatNum acosh_up  (FloatNum x);
00274     GECODE_FLOAT_EXPORT FloatNum atanh_down(FloatNum x);
00276     GECODE_FLOAT_EXPORT FloatNum atanh_up  (FloatNum x);
00278 #endif
00279   };
00280 
00281 }}
00282 
00283 #include <gecode/float/rounding.hpp>
00284 
00285 namespace Gecode { namespace Float {
00286 
00291   bool subset(const FloatVal& x, const FloatVal& y);
00296   bool proper_subset(const FloatVal& x, const FloatVal& y);
00301   bool overlap(const FloatVal& x, const FloatVal& y);
00302 
00307   FloatVal intersect(const FloatVal& x, const FloatVal& y);
00312   FloatVal hull(const FloatVal& x, const FloatVal& y);
00317   FloatVal hull(const FloatVal& x, const FloatNum& y);
00322   FloatVal hull(const FloatNum& x, const FloatVal& y);
00327   FloatVal hull(const FloatNum& x, const FloatNum& y);
00328 
00329 }}
00330 
00331 namespace Gecode {
00332 
00338   class FloatVal {
00339     friend FloatVal operator +(const FloatVal& x);
00340     friend FloatVal operator -(const FloatVal& x);
00341     friend FloatVal operator +(const FloatVal& x, const FloatVal& y);
00342     friend FloatVal operator +(const FloatVal& x, const FloatNum& y);
00343     friend FloatVal operator +(const FloatNum& x, const FloatVal& y);
00344     friend FloatVal operator -(const FloatVal& x, const FloatVal& y);
00345     friend FloatVal operator -(const FloatVal& x, const FloatNum& y);
00346     friend FloatVal operator -(const FloatNum& x, const FloatVal& y);
00347     friend FloatVal operator *(const FloatVal& x, const FloatVal& y);
00348     friend FloatVal operator *(const FloatVal& x, const FloatNum& y);
00349     friend FloatVal operator *(const FloatNum& x, const FloatVal& y);
00350     friend FloatVal operator /(const FloatVal& x, const FloatVal& y);
00351     friend FloatVal operator /(const FloatVal& x, const FloatNum& y);
00352     friend FloatVal operator /(const FloatNum& x, const FloatVal& y);
00353 
00354     friend bool operator <(const FloatVal& x, const FloatVal& y);
00355     friend bool operator <(const FloatVal& x, const FloatNum& y);
00356     friend bool operator <(const FloatNum& x, const FloatVal& y);
00357     friend bool operator <=(const FloatVal& x, const FloatVal& y);
00358     friend bool operator <=(const FloatVal& x, const FloatNum& y);
00359     friend bool operator <=(const FloatNum& x, const FloatVal& y);
00360     friend bool operator >(const FloatVal& x, const FloatVal& y);
00361     friend bool operator >(const FloatVal& x, const FloatNum& y);
00362     friend bool operator >(const FloatNum& x, const FloatVal& y);
00363     friend bool operator >=(const FloatVal& x, const FloatVal& y);
00364     friend bool operator >=(const FloatVal& x, const FloatNum& y);
00365     friend bool operator >=(const FloatNum& x, const FloatVal& y);
00366     friend bool operator ==(const FloatVal& x, const FloatVal& y);
00367     friend bool operator ==(const FloatVal& x, const FloatNum& y);
00368     friend bool operator ==(const FloatNum& x, const FloatVal& y);
00369     friend bool operator !=(const FloatVal& x, const FloatVal& y);
00370     friend bool operator !=(const FloatVal& x, const FloatNum& y);
00371     friend bool operator !=(const FloatNum& x, const FloatVal& y);
00372 
00373     template<class Char, class Traits>
00374     friend std::basic_ostream<Char,Traits>&
00375     operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
00376 
00377     friend FloatVal abs(const FloatVal& x);
00378     friend FloatVal sqrt(const FloatVal& x);
00379     friend FloatVal sqr(const FloatVal& x);
00380     friend FloatVal pow(const FloatVal& x, int n);
00381     friend FloatVal nroot(const FloatVal& x, int n);
00382 
00383     friend FloatVal max(const FloatVal& x, const FloatVal& y);
00384     friend FloatVal max(const FloatVal& x, const FloatNum& y);
00385     friend FloatVal max(const FloatNum& x, const FloatVal& y);
00386     friend FloatVal min(const FloatVal& x, const FloatVal& y);
00387     friend FloatVal min(const FloatVal& x, const FloatNum& y);
00388     friend FloatVal min(const FloatNum& x, const FloatVal& y);
00389 
00390 #ifdef GECODE_HAS_MPFR
00391     friend FloatVal exp(const FloatVal& x);
00392     friend FloatVal log(const FloatVal& x);
00393     friend FloatVal fmod(const FloatVal& x, const FloatVal& y);
00394     friend FloatVal fmod(const FloatVal& x, const FloatNum& y);
00395     friend FloatVal fmod(const FloatNum& x, const FloatVal& y);
00396     friend FloatVal sin(const FloatVal& x);
00397     friend FloatVal cos(const FloatVal& x);
00398     friend FloatVal tan(const FloatVal& x);
00399     friend FloatVal asin(const FloatVal& x);
00400     friend FloatVal acos(const FloatVal& x);
00401     friend FloatVal atan(const FloatVal& x);
00402     friend FloatVal sinh(const FloatVal& x);
00403     friend FloatVal cosh(const FloatVal& x);
00404     friend FloatVal tanh(const FloatVal& x);
00405     friend FloatVal asinh(const FloatVal& x);
00406     friend FloatVal acosh(const FloatVal& x);
00407     friend FloatVal atanh(const FloatVal& x);
00408 #endif
00409 
00410     friend bool Float::subset(const FloatVal& x, const FloatVal& y);
00411     friend bool Float::proper_subset(const FloatVal& x, const FloatVal& y);
00412     friend bool Float::overlap(const FloatVal& x, const FloatVal& y);
00413     friend FloatVal Float::intersect(const FloatVal& x, const FloatVal& y);
00414     friend FloatVal Float::hull(const FloatVal& x, const FloatVal& y);
00415     friend FloatVal Float::hull(const FloatVal& x, const FloatNum& y);
00416     friend FloatVal Float::hull(const FloatNum& x, const FloatVal& y);
00417     friend FloatVal Float::hull(const FloatNum& x, const FloatNum& y);
00418   protected:
00420     typedef gecode_boost::numeric::interval_lib::save_state<Float::Rounding> R;
00422     typedef gecode_boost::numeric::interval_lib::checking_strict<FloatNum> P;
00424     typedef gecode_boost::numeric::interval
00425       <FloatNum,
00426        gecode_boost::numeric::interval_lib::policies<R, P> >
00427     FloatValImpType;
00429     FloatValImpType x;
00431     explicit FloatVal(const FloatValImpType& i);
00432   public:
00434 
00435 
00436     FloatVal(void);
00438     FloatVal(const FloatNum& n);
00440     FloatVal(const FloatNum& l, const FloatNum& u);
00442     FloatVal(const FloatVal& v);
00443 
00445     FloatVal& operator =(const FloatNum& n);
00447     FloatVal& operator =(const FloatVal& v);
00448 
00450     void assign(FloatNum const &l, FloatNum const &u);
00452 
00454 
00455 
00456     FloatNum min(void) const;
00458     FloatNum max(void) const;
00460     FloatNum size(void) const;
00462     FloatNum med(void) const;
00464 
00466 
00467 
00468     bool tight(void) const;
00470     bool singleton(void) const;
00472     bool in(FloatNum n) const;
00474     bool zero_in(void) const;
00476 
00478 
00479 
00480     static FloatVal hull(FloatNum x, FloatNum y);
00482     static FloatVal pi_half(void);
00484     static FloatVal pi(void);
00486     static FloatVal pi_twice(void);
00488 
00490 
00491 
00492     FloatVal& operator +=(const FloatNum& n);
00494     FloatVal& operator -=(const FloatNum& n);
00496     FloatVal& operator *=(const FloatNum& n);
00498     FloatVal& operator /=(const FloatNum& n);
00500     FloatVal& operator +=(const FloatVal& v);
00502     FloatVal& operator -=(const FloatVal& v);
00504     FloatVal& operator *=(const FloatVal& v);
00506     FloatVal& operator /=(const FloatVal& v);
00508   };
00509 
00514   FloatVal operator +(const FloatVal& x);
00519   FloatVal operator -(const FloatVal& x);
00520 
00525   FloatVal operator +(const FloatVal& x, const FloatVal& y);
00530   FloatVal operator +(const FloatVal& x, const FloatNum& y);
00535   FloatVal operator +(const FloatNum& x, const FloatVal& y);
00540   FloatVal operator -(const FloatVal& x, const FloatVal& y);
00545   FloatVal operator -(const FloatVal& x, const FloatNum& y);
00550   FloatVal operator -(const FloatNum& x, const FloatVal& y);
00555   FloatVal operator *(const FloatVal& x, const FloatVal& y);
00560   FloatVal operator *(const FloatVal& x, const FloatNum& y);
00565   FloatVal operator *(const FloatNum& x, const FloatVal& y);
00570   FloatVal operator /(const FloatVal& x, const FloatVal& y);
00575   FloatVal operator /(const FloatVal& x, const FloatNum& y);
00580   FloatVal operator /(const FloatNum& r, const FloatVal& x);
00581 
00586   bool operator <(const FloatVal& x, const FloatVal& y);
00591   bool operator <(const FloatVal& x, const FloatNum& y);
00596   bool operator <(const FloatNum& x, const FloatVal& y);
00597 
00602   bool operator <=(const FloatVal& x, const FloatVal& y);
00607   bool operator <=(const FloatVal& x, const FloatNum& y);
00612   bool operator <=(const FloatNum& x, const FloatVal& y);
00613 
00618   bool operator >(const FloatVal& x, const FloatVal& y);
00623   bool operator >(const FloatVal& x, const FloatNum& y);
00628   bool operator >(const FloatNum& x, const FloatVal& y);
00629 
00634   bool operator >=(const FloatVal& x, const FloatVal& y);
00639   bool operator >=(const FloatVal& x, const FloatNum& y);
00644   bool operator >=(const FloatNum& x, const FloatVal& y);
00649   bool operator ==(const FloatVal& x, const FloatVal& y);
00654   bool operator ==(const FloatVal& x, const FloatNum& y);
00659   bool operator ==(const FloatNum& x, const FloatVal& y);
00660 
00665   bool operator !=(const FloatVal& x, const FloatVal& y);
00670   bool operator !=(const FloatVal& x, const FloatNum& y);
00675   bool operator !=(const FloatNum& x, const FloatVal& y);
00676 
00681   template<class Char, class Traits>
00682   std::basic_ostream<Char,Traits>&
00683   operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
00684 
00689   FloatVal abs(const FloatVal& x);
00694   FloatVal sqrt(const FloatVal& x);
00699   FloatVal sqr(const FloatVal& x);
00704   FloatVal pow(const FloatVal& x, int n);
00709   FloatVal nroot(const FloatVal& x, int n);
00710 
00715   FloatVal max(const FloatVal& x, const FloatVal& y);
00720   FloatVal max(const FloatVal& x, const FloatNum& y);
00725   FloatVal max(const FloatNum& x, const FloatVal& y);
00730   FloatVal min(const FloatVal& x, const FloatVal& y);
00735   FloatVal min(const FloatVal& x, const FloatNum& y);
00740   FloatVal min(const FloatNum& x, const FloatVal& y);
00741 
00742 #ifdef GECODE_HAS_MPFR
00743   /* transcendental functions: exp, log */
00748   FloatVal exp(const FloatVal& x);
00753   FloatVal log(const FloatVal& x);
00754 
00759   FloatVal fmod(const FloatVal& x, const FloatVal& y);
00764   FloatVal fmod(const FloatVal& x, const FloatNum& y);
00769   FloatVal fmod(const FloatNum& x, const FloatVal& y);
00770 
00775   FloatVal sin(const FloatVal& x);
00780   FloatVal cos(const FloatVal& x);
00785   FloatVal tan(const FloatVal& x);
00790   FloatVal asin(const FloatVal& x);
00795   FloatVal acos(const FloatVal& x);
00800   FloatVal atan(const FloatVal& x);
00801 
00806   FloatVal sinh(const FloatVal& x);
00811   FloatVal cosh(const FloatVal& x);
00816   FloatVal tanh(const FloatVal& x);
00821   FloatVal asinh(const FloatVal& x);
00826   FloatVal acosh(const FloatVal& x);
00831   FloatVal atanh(const FloatVal& x);
00832 
00833 #endif
00834 
00835 }
00836 
00837 #include <gecode/float/val.hpp>
00838 
00839 namespace Gecode { namespace Float {
00840 
00846   namespace Limits {
00848     const FloatNum max = std::numeric_limits<FloatNum>::max();
00850     const FloatNum min = -max;
00852     bool valid(const FloatVal& n);
00854     void check(const FloatVal& n, const char* l);
00855   }
00856 
00857 }}
00858 
00859 #include <gecode/float/limits.hpp>
00860 
00861 #include <gecode/float/var-imp.hpp>
00862 
00863 namespace Gecode {
00864 
00865   namespace Float {
00866     class FloatView;
00867   }
00868 
00874   class FloatVar : public VarImpVar<Float::FloatVarImp> {
00875     friend class FloatVarArray;
00876     friend class FloatVarArgs;
00877   private:
00878     using VarImpVar<Float::FloatVarImp>::x;
00885     void _init(Space& home, FloatNum min, FloatNum max);
00886   public:
00888 
00889 
00890     FloatVar(void);
00892     FloatVar(const FloatVar& y);
00894     FloatVar(const Float::FloatView& y);
00906     GECODE_FLOAT_EXPORT FloatVar(Space& home, FloatNum min, FloatNum max);
00908 
00910 
00911 
00912     FloatVal domain(void) const;
00914     FloatNum min(void) const;
00916     FloatNum max(void) const;
00918     FloatNum med(void) const;
00920     FloatNum size(void) const;
00928     FloatVal val(void) const;
00929 
00931 
00933 
00934 
00935     bool in(const FloatVal& n) const;
00937   };
00938 
00943   template<class Char, class Traits>
00944   std::basic_ostream<Char,Traits>&
00945   operator <<(std::basic_ostream<Char,Traits>& os, const FloatVar& x);
00946 }
00947 
00948 #include <gecode/float/view.hpp>
00949 #include <gecode/float/array-traits.hpp>
00950 
00951 namespace Gecode {
00952 
00954   class FloatValArgs : public ArgArray<FloatVal> {
00955   public:
00957 
00958 
00959     FloatValArgs(void);
00961     explicit FloatValArgs(int n);
00963     FloatValArgs(const SharedArray<FloatVal>& x);
00965     FloatValArgs(const std::vector<FloatVal>& x);
00967     template<class InputIterator>
00968     FloatValArgs(InputIterator first, InputIterator last);
00970     FloatValArgs(int n, const FloatVal* e);
00972     FloatValArgs(const ArgArray<FloatVal>& a);
00973 
00975     GECODE_FLOAT_EXPORT
00976     static FloatValArgs create(int n, FloatVal start, int inc=1);
00978   };
00979 
00981   class FloatVarArgs : public VarArgArray<FloatVar> {
00982   public:
00984 
00985 
00986     FloatVarArgs(void) {}
00988     explicit FloatVarArgs(int n) : VarArgArray<FloatVar>(n) {}
00990     FloatVarArgs(const FloatVarArgs& a) : VarArgArray<FloatVar>(a) {}
00992     FloatVarArgs(const VarArray<FloatVar>& a) : VarArgArray<FloatVar>(a) {}
00994     FloatVarArgs(const std::vector<FloatVar>& a) : VarArgArray<FloatVar>(a) {}
00996     template<class InputIterator>
00997     FloatVarArgs(InputIterator first, InputIterator last)
00998     : VarArgArray<FloatVar>(first,last) {}
01010     GECODE_FLOAT_EXPORT
01011     FloatVarArgs(Space& home, int n, FloatNum min, FloatNum max);
01013   };
01015 
01031   class FloatVarArray : public VarArray<FloatVar> {
01032   public:
01034 
01035 
01036     FloatVarArray(void);
01038     FloatVarArray(Space& home, int n);
01040     FloatVarArray(const FloatVarArray& a);
01042     FloatVarArray(Space& home, const FloatVarArgs& a);
01054     GECODE_FLOAT_EXPORT
01055     FloatVarArray(Space& home, int n, FloatNum min, FloatNum max);
01057   };
01058 
01059 }
01060 
01061 #include <gecode/float/array.hpp>
01062 
01063 namespace Gecode {
01064 
01069   enum FloatRelType {
01070     FRT_EQ, 
01071     FRT_NQ, 
01072     FRT_LQ, 
01073     FRT_LE, 
01074     FRT_GQ, 
01075     FRT_GR 
01076   };
01077 
01085 
01086   GECODE_FLOAT_EXPORT void
01087   dom(Home home, FloatVar x, FloatVal n);
01089   GECODE_FLOAT_EXPORT void
01090   dom(Home home, const FloatVarArgs& x, FloatVal n);
01092   GECODE_FLOAT_EXPORT void
01093   dom(Home home, FloatVar x, FloatNum l, FloatNum m);
01095   GECODE_FLOAT_EXPORT void
01096   dom(Home home, const FloatVarArgs& x, FloatNum l, FloatNum u);
01098   GECODE_FLOAT_EXPORT void
01099   dom(Home home, FloatVar x, FloatVal n, Reify r);
01101   GECODE_FLOAT_EXPORT void
01102   dom(Home home, FloatVar x, FloatNum l, FloatNum u, Reify r);
01104   GECODE_FLOAT_EXPORT void
01105   dom(Home home, FloatVar x, FloatVar d);
01107   GECODE_FLOAT_EXPORT void
01108   dom(Home home, const FloatVarArgs& x, const FloatVarArgs& d);
01110 
01119   GECODE_FLOAT_EXPORT void
01120   rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1);
01124   GECODE_FLOAT_EXPORT void
01125   rel(Home home, FloatVar x, FloatRelType frt, FloatVal c);
01129   GECODE_FLOAT_EXPORT void
01130   rel(Home home, FloatVar x, FloatRelType frt, FloatVal c, Reify r);
01134   GECODE_FLOAT_EXPORT void
01135   rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1, Reify r);
01139   GECODE_FLOAT_EXPORT void
01140   rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c);
01144   GECODE_FLOAT_EXPORT void
01145   rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVar y);
01152   GECODE_FLOAT_EXPORT void
01153   ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z);
01154 
01155 }
01156 
01157 
01158 namespace Gecode {
01159 
01168   GECODE_FLOAT_EXPORT void
01169   min(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01173   GECODE_FLOAT_EXPORT void
01174   min(Home home, const FloatVarArgs& x, FloatVar y);
01177   GECODE_FLOAT_EXPORT void
01178   max(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01182   GECODE_FLOAT_EXPORT void
01183   max(Home home, const FloatVarArgs& x, FloatVar y);
01184 
01187   GECODE_FLOAT_EXPORT void
01188   abs(Home home, FloatVar x0, FloatVar x1);
01189 
01192   GECODE_FLOAT_EXPORT void
01193   mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01194 
01197   GECODE_FLOAT_EXPORT void
01198   sqr(Home home, FloatVar x0, FloatVar x1);
01199 
01202   GECODE_FLOAT_EXPORT void
01203   sqrt(Home home, FloatVar x0, FloatVar x1);
01204 
01207   GECODE_FLOAT_EXPORT void
01208   pow(Home home, FloatVar x0, int n, FloatVar x1);
01209 
01212   GECODE_FLOAT_EXPORT void
01213   nroot(Home home, FloatVar x0, int n, FloatVar x1);
01214 
01217   GECODE_FLOAT_EXPORT void
01218   div(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
01219 #ifdef GECODE_HAS_MPFR
01220 
01222   GECODE_FLOAT_EXPORT void
01223   exp(Home home, FloatVar x0, FloatVar x1);
01226   GECODE_FLOAT_EXPORT void
01227   log(Home home, FloatVar x0, FloatVar x1);
01230   GECODE_FLOAT_EXPORT void
01231   pow(Home home, FloatNum base, FloatVar x0, FloatVar x1);
01234   GECODE_FLOAT_EXPORT void
01235   log(Home home, FloatNum base, FloatVar x0, FloatVar x1);
01238   GECODE_FLOAT_EXPORT void
01239   asin(Home home, FloatVar x0, FloatVar x1);
01242   GECODE_FLOAT_EXPORT void
01243   sin(Home home, FloatVar x0, FloatVar x1);
01246   GECODE_FLOAT_EXPORT void
01247   acos(Home home, FloatVar x0, FloatVar x1);
01250   GECODE_FLOAT_EXPORT void
01251   cos(Home home, FloatVar x0, FloatVar x1);
01254   GECODE_FLOAT_EXPORT void
01255   atan(Home home, FloatVar x0, FloatVar x1);
01258   GECODE_FLOAT_EXPORT void
01259   tan(Home home, FloatVar x0, FloatVar x1);
01261 #endif
01262 
01270   GECODE_FLOAT_EXPORT void
01271   linear(Home home, const FloatVarArgs& x,
01272          FloatRelType frt, FloatVal c);
01276   GECODE_FLOAT_EXPORT void
01277   linear(Home home, const FloatVarArgs& x,
01278          FloatRelType frt, FloatVar y);
01282   GECODE_FLOAT_EXPORT void
01283   linear(Home home, const FloatVarArgs& x,
01284          FloatRelType frt, FloatVal c, Reify r);
01288   GECODE_FLOAT_EXPORT void
01289   linear(Home home, const FloatVarArgs& x,
01290          FloatRelType frt, FloatVar y, Reify r);
01297   GECODE_FLOAT_EXPORT void
01298   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01299          FloatRelType frt, FloatVal c);
01306   GECODE_FLOAT_EXPORT void
01307   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01308          FloatRelType frt, FloatVar y);
01315   GECODE_FLOAT_EXPORT void
01316   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01317          FloatRelType frt, FloatVal c, Reify r);
01324   GECODE_FLOAT_EXPORT void
01325   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
01326          FloatRelType frt, FloatVar y, Reify r);
01327 
01328 
01334 
01335   GECODE_FLOAT_EXPORT void
01336   channel(Home home, FloatVar x0, IntVar x1);
01338   void
01339   channel(Home home, IntVar x0, FloatVar x1);
01341   GECODE_FLOAT_EXPORT void
01342   channel(Home home, FloatVar x0, BoolVar x1);
01344   void
01345   channel(Home home, BoolVar x0, FloatVar x1);
01347 
01348 }
01349 
01350 #include <gecode/float/channel.hpp>
01351 
01352 namespace Gecode {
01353 
01362 
01363   GECODE_FLOAT_EXPORT void
01364   wait(Home home, FloatVar x, std::function<void(Space& home)> c);
01366   GECODE_FLOAT_EXPORT void
01367   wait(Home home, const FloatVarArgs& x, std::function<void(Space& home)> c);
01369 
01370 }
01371 
01372 namespace Gecode {
01373 
01387   typedef std::function<bool(const Space& home, FloatVar x, int i)>
01388     FloatBranchFilter;
01389 
01400   typedef std::function<double(const Space& home, FloatVar x, int i)>
01401     FloatBranchMerit;
01402 
01408   class FloatNumBranch {
01409   public:
01411     FloatNum n;
01413     bool l;
01414   };
01415 
01426   typedef std::function<FloatNumBranch(const Space& home, FloatVar x, int i)>
01427     FloatBranchVal;
01428 
01440   typedef std::function<void(Space& home, unsigned int a,
01441                              FloatVar x, int i, FloatNumBranch nl)>
01442     FloatBranchCommit;
01443 
01444 }
01445 
01446 #include <gecode/float/branch/traits.hpp>
01447 
01448 namespace Gecode {
01449 
01455   class FloatAFC : public AFC {
01456   public:
01464     FloatAFC(void);
01466     FloatAFC(const FloatAFC& a);
01468     FloatAFC& operator =(const FloatAFC& a);
01470     FloatAFC(Home home, const FloatVarArgs& x, double d=1.0);
01478     void init(Home home, const FloatVarArgs& x, double d=1.0);
01479   };
01480 
01481 }
01482 
01483 #include <gecode/float/branch/afc.hpp>
01484 
01485 namespace Gecode {
01486 
01492   class FloatAction : public Action {
01493   public:
01501     FloatAction(void);
01503     FloatAction(const FloatAction& a);
01505     FloatAction& operator =(const FloatAction& a);
01514     GECODE_FLOAT_EXPORT
01515     FloatAction(Home home, const FloatVarArgs& x, double d=1.0,
01516                   FloatBranchMerit bm=nullptr);
01528     GECODE_FLOAT_EXPORT void
01529     init(Home home, const FloatVarArgs& x, double d=1.0,
01530          FloatBranchMerit bm=nullptr);
01531   };
01532 
01533 }
01534 
01535 #include <gecode/float/branch/action.hpp>
01536 
01537 namespace Gecode {
01538 
01544   class FloatCHB : public CHB {
01545   public:
01553     FloatCHB(void);
01555     FloatCHB(const FloatCHB& chb);
01557     FloatCHB& operator =(const FloatCHB& chb);
01566     GECODE_FLOAT_EXPORT
01567     FloatCHB(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
01579     GECODE_FLOAT_EXPORT void
01580     init(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
01581   };
01582 
01583 }
01584 
01585 #include <gecode/float/branch/chb.hpp>
01586 
01587 namespace Gecode {
01588 
01590   typedef std::function<void(const Space &home, const Brancher& b,
01591                              unsigned int a,
01592                              FloatVar x, int i, const FloatNumBranch& n,
01593                              std::ostream& o)>
01594     FloatVarValPrint;
01595 
01596 }
01597 
01598 namespace Gecode {
01599 
01605   class FloatVarBranch : public VarBranch<FloatVar> {
01606   public:
01608     enum Select {
01609       SEL_NONE = 0,        
01610       SEL_RND,             
01611       SEL_MERIT_MIN,       
01612       SEL_MERIT_MAX,       
01613       SEL_DEGREE_MIN,      
01614       SEL_DEGREE_MAX,      
01615       SEL_AFC_MIN,         
01616       SEL_AFC_MAX,         
01617       SEL_ACTION_MIN,      
01618       SEL_ACTION_MAX,      
01619       SEL_CHB_MIN,         
01620       SEL_CHB_MAX,         
01621       SEL_MIN_MIN,         
01622       SEL_MIN_MAX,         
01623       SEL_MAX_MIN,         
01624       SEL_MAX_MAX,         
01625       SEL_SIZE_MIN,        
01626       SEL_SIZE_MAX,        
01627       SEL_DEGREE_SIZE_MIN, 
01628       SEL_DEGREE_SIZE_MAX, 
01629       SEL_AFC_SIZE_MIN,    
01630       SEL_AFC_SIZE_MAX,    
01631       SEL_ACTION_SIZE_MIN, 
01632       SEL_ACTION_SIZE_MAX, 
01633       SEL_CHB_SIZE_MIN,    
01634       SEL_CHB_SIZE_MAX     
01635     };
01636   protected:
01638     Select s;
01639   public:
01641     FloatVarBranch(void);
01643     FloatVarBranch(Rnd r);
01645     FloatVarBranch(Select s, BranchTbl t);
01647     FloatVarBranch(Select s, double, BranchTbl t);
01649     FloatVarBranch(Select s, FloatAFC a, BranchTbl t);
01651     FloatVarBranch(Select s, FloatAction a, BranchTbl t);
01653     FloatVarBranch(Select s, FloatCHB c, BranchTbl t);
01655     FloatVarBranch(Select s, FloatBranchMerit mf, BranchTbl t);
01657     Select select(void) const;
01659     void expand(Home home, const FloatVarArgs& x);
01660   };
01661 
01662 
01668 
01669   FloatVarBranch FLOAT_VAR_NONE(void);
01671   FloatVarBranch FLOAT_VAR_RND(Rnd r);
01673   FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl=nullptr);
01675   FloatVarBranch FLOAT_VAR_MERIT_MAX(FloatBranchMerit bm, BranchTbl tbl=nullptr);
01677   FloatVarBranch FLOAT_VAR_DEGREE_MIN(BranchTbl tbl=nullptr);
01679   FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr);
01681   FloatVarBranch FLOAT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
01683   FloatVarBranch FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl=nullptr);
01685   FloatVarBranch FLOAT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
01687   FloatVarBranch FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl=nullptr);
01689   FloatVarBranch FLOAT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
01691   FloatVarBranch FLOAT_VAR_ACTION_MIN(FloatAction a, BranchTbl tbl=nullptr);
01693   FloatVarBranch FLOAT_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
01695   FloatVarBranch FLOAT_VAR_ACTION_MAX(FloatAction a, BranchTbl tbl=nullptr);
01697   FloatVarBranch FLOAT_VAR_CHB_MIN(BranchTbl tbl=nullptr);
01699   FloatVarBranch FLOAT_VAR_CHB_MIN(FloatCHB a, BranchTbl tbl=nullptr);
01701   FloatVarBranch FLOAT_VAR_CHB_MAX(BranchTbl tbl=nullptr);
01703   FloatVarBranch FLOAT_VAR_CHB_MAX(FloatCHB a, BranchTbl tbl=nullptr);
01705   FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl=nullptr);
01707   FloatVarBranch FLOAT_VAR_MIN_MAX(BranchTbl tbl=nullptr);
01709   FloatVarBranch FLOAT_VAR_MAX_MIN(BranchTbl tbl=nullptr);
01711   FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl=nullptr);
01713   FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl=nullptr);
01715   FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl=nullptr);
01717   FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr);
01719   FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr);
01721   FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01723   FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl=nullptr);
01725   FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01727   FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl=nullptr);
01729   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01731   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(FloatAction a, BranchTbl tbl=nullptr);
01733   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01735   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(FloatAction a, BranchTbl tbl=nullptr);
01737   FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr);
01739   FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(FloatCHB c, BranchTbl tbl=nullptr);
01741   FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr);
01743   FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(FloatCHB a, BranchTbl tbl=nullptr);
01745 
01746 }
01747 
01748 #include <gecode/float/branch/var.hpp>
01749 
01750 namespace Gecode {
01751 
01757   class FloatValBranch : public ValBranch<FloatVar> {
01758   public:
01760     enum Select {
01761       SEL_SPLIT_MIN, 
01762       SEL_SPLIT_MAX, 
01763       SEL_SPLIT_RND,  
01764       SEL_VAL_COMMIT  
01765     };
01766   protected:
01768     Select s;
01769   public:
01771     FloatValBranch(Select s = SEL_SPLIT_MIN);
01773     FloatValBranch(Rnd r);
01775     FloatValBranch(FloatBranchVal v, FloatBranchCommit c);
01777     Select select(void) const;
01778   };
01779 
01785 
01786   FloatValBranch FLOAT_VAL_SPLIT_MIN(void);
01788   FloatValBranch FLOAT_VAL_SPLIT_MAX(void);
01790   FloatValBranch FLOAT_VAL_SPLIT_RND(Rnd r);
01797   FloatValBranch FLOAT_VAL(FloatBranchVal v, FloatBranchCommit c=nullptr);
01799 
01800 }
01801 
01802 #include <gecode/float/branch/val.hpp>
01803 
01804 namespace Gecode {
01805 
01811   class FloatAssign : public ValBranch<FloatVar> {
01812   public:
01814     enum Select {
01815       SEL_MIN,       
01816       SEL_MAX,       
01817       SEL_RND,       
01818       SEL_VAL_COMMIT 
01819     };
01820   protected:
01822     Select s;
01823   public:
01825     FloatAssign(Select s = SEL_MIN);
01827     FloatAssign(Rnd r);
01829     FloatAssign(FloatBranchVal v, FloatBranchCommit c);
01831     Select select(void) const;
01832   };
01833 
01839 
01840   FloatAssign FLOAT_ASSIGN_MIN(void);
01842   FloatAssign FLOAT_ASSIGN_MAX(void);
01844   FloatAssign FLOAT_ASSIGN_RND(Rnd r);
01850   FloatAssign FLOAT_ASSIGN(FloatBranchVal v, FloatBranchCommit c=nullptr);
01852 
01853 }
01854 
01855 #include <gecode/float/branch/assign.hpp>
01856 
01857 namespace Gecode {
01858 
01864   GECODE_FLOAT_EXPORT void
01865   branch(Home home, const FloatVarArgs& x,
01866          FloatVarBranch vars, FloatValBranch vals,
01867          FloatBranchFilter bf=nullptr,
01868          FloatVarValPrint vvp=nullptr);
01874   GECODE_FLOAT_EXPORT void
01875   branch(Home home, const FloatVarArgs& x,
01876          TieBreak<FloatVarBranch> vars, FloatValBranch vals,
01877          FloatBranchFilter bf=nullptr,
01878          FloatVarValPrint vvp=nullptr);
01884   GECODE_FLOAT_EXPORT void
01885   branch(Home home, FloatVar x, FloatValBranch vals,
01886          FloatVarValPrint vvp=nullptr);
01887 
01893   GECODE_FLOAT_EXPORT void
01894   assign(Home home, const FloatVarArgs& x, FloatAssign vals,
01895          FloatBranchFilter bf=nullptr,
01896          FloatVarValPrint vvp=nullptr);
01902   GECODE_FLOAT_EXPORT void
01903   assign(Home home, FloatVar x, FloatAssign vals,
01904          FloatVarValPrint vvp=nullptr);
01906 
01907 }
01908 
01909 namespace Gecode {
01910 
01911   /*
01912    * \brief Relaxed assignment of variables in \a x from values in \a sx
01913    *
01914    * The variables in \a x are assigned values from the assigned variables
01915    * in the solution \a sx with a relaxation probability \a p. That is,
01916    * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
01917    * assigned a value from \a sx.
01918    *
01919    * The random numbers are generated from the generator \a r. At least
01920    * one variable will not be assigned: in case the relaxation attempt
01921    * would suggest that all variables should be assigned, a single
01922    * variable will be selected randomly to remain unassigned.
01923    *
01924    * Throws an exception of type Float::ArgumentSizeMismatch, if \a x and
01925    * \a sx are of different size.
01926    *
01927    * Throws an exception of type Float::OutOfLimits, if \a p is not between
01928    * \a 0.0 and \a 1.0.
01929    *
01930    * \ingroup TaskModeFloat
01931    */
01932   GECODE_FLOAT_EXPORT void
01933   relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx,
01934         Rnd r, double p);
01935 
01936 }
01937 
01938 #include <gecode/float/trace/trace-view.hpp>
01939 
01940 namespace Gecode {
01941 
01951   class FloatTraceDelta {
01952   protected:
01954     Float::FloatView n;
01956     const Delta& d;
01957   public:
01959 
01960 
01961     FloatTraceDelta(Float::FloatTraceView o, Float::FloatView n,
01962                     const Delta& d);
01964 
01965 
01966 
01967     FloatNum min(void) const;
01969     FloatNum max(void) const;
01971   };
01972 
01973 }
01974 
01975 #include <gecode/float/trace/delta.hpp>
01976 
01977 #include <gecode/float/trace/traits.hpp>
01978 
01979 namespace Gecode {
01980 
01985   typedef ViewTracer<Float::FloatView> FloatTracer;
01990   typedef ViewTraceRecorder<Float::FloatView> FloatTraceRecorder;
01991 
01996   class GECODE_FLOAT_EXPORT StdFloatTracer : public FloatTracer {
01997   protected:
01999     std::ostream& os;
02000   public:
02002     StdFloatTracer(std::ostream& os0 = std::cerr);
02004     virtual void init(const Space& home, const FloatTraceRecorder& t);
02006     virtual void prune(const Space& home, const FloatTraceRecorder& t,
02007                        const ViewTraceInfo& vti, int i, FloatTraceDelta& d);
02009     virtual void fix(const Space& home, const FloatTraceRecorder& t);
02011     virtual void fail(const Space& home, const FloatTraceRecorder& t);
02013     virtual void done(const Space& home, const FloatTraceRecorder& t);
02015     static StdFloatTracer def;
02016   };
02017 
02018 
02023   GECODE_FLOAT_EXPORT void
02024   trace(Home home, const FloatVarArgs& x,
02025         TraceFilter tf,
02026         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
02027         FloatTracer& t = StdFloatTracer::def);
02032   void
02033   trace(Home home, const FloatVarArgs& x,
02034         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
02035         FloatTracer& t = StdFloatTracer::def);
02036 
02037 }
02038 
02039 #include <gecode/float/trace.hpp>
02040 
02041 #endif
02042 
02043 // IFDEF: GECODE_HAS_FLOAT_VARS
02044 // STATISTICS: float-post
02045