1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  *  Main authors:
4  *     Christian Schulte <schulte@gecode.org>
5  *     Guido Tack <tack@gecode.org>
6  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
7  *
8  *  Copyright:
9  *     Christian Schulte, 2002
10  *     Guido Tack, 2004
11  *     Vincent Barichard, 2012
12  *
13  *  This file is part of Gecode, the generic constraint
14  *  development environment:
15  *     http://www.gecode.org
16  *
17  *  Permission is hereby granted, free of charge, to any person obtaining
18  *  a copy of this software and associated documentation files (the
19  *  "Software"), to deal in the Software without restriction, including
20  *  without limitation the rights to use, copy, modify, merge, publish,
21  *  distribute, sublicense, and/or sell copies of the Software, and to
22  *  permit persons to whom the Software is furnished to do so, subject to
23  *  the following conditions:
24  *
25  *  The above copyright notice and this permission notice shall be
26  *  included in all copies or substantial portions of the Software.
27  *
28  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef GECODE_FLOAT_HH
39 #define GECODE_FLOAT_HH
40 
41 #include <climits>
42 #include <cfloat>
43 #include <iostream>
44 
45 #include <functional>
46 
47 #include <gecode/kernel.hh>
48 #include <gecode/int.hh>
49 
50 /*
51  * Configure linking
52  *
53  */
54 #if !defined(GECODE_STATIC_LIBS) && \
55     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
56 
57 #ifdef GECODE_BUILD_FLOAT
58 #define GECODE_FLOAT_EXPORT __declspec( dllexport )
59 #else
60 #define GECODE_FLOAT_EXPORT __declspec( dllimport )
61 #endif
62 
63 #else
64 
65 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
66 #define GECODE_FLOAT_EXPORT __attribute__ ((visibility("default")))
67 #else
68 #define GECODE_FLOAT_EXPORT
69 #endif
70 
71 #endif
72 
73 // Configure auto-linking
74 #ifndef GECODE_BUILD_FLOAT
75 #define GECODE_LIBRARY_NAME "Float"
76 #include <gecode/support/auto-link.hpp>
77 #endif
78 
79 // Include interval implementation
80 #include <gecode/third-party/boost/numeric/interval.hpp>
81 
82 /**
83  * \namespace Gecode::Float
84  * \brief Floating point numbers
85  *
86  * The Gecode::Float namespace contains all functionality required
87  * to program propagators and branchers for floating point numbers.
88  * In addition, all propagators and branchers for floating point
89  * numbers provided by %Gecode are contained as nested namespaces.
90  *
91  */
92 
93 #include <gecode/float/exception.hpp>
94 
95 #include <gecode/float/nextafter.hpp>
96 
97 namespace Gecode {
98 
99   /**
100    * \brief Floating point number base type
101    *
102    * This type defines the interval bounds used for representing floating
103    * point values.
104    * \ingroup TaskModelFloatVars
105    */
106   typedef double FloatNum;
107 
108   /// Return lower bound of \f$\pi/2\f$
109   FloatNum pi_half_lower(void);
110   /// Return upper bound of \f$\pi/2\f$
111   FloatNum pi_half_upper(void);
112   /// Return lower bound of \f$\pi\f$
113   FloatNum pi_lower(void);
114   /// Return upper bound of \f$\pi\f$
115   FloatNum pi_upper(void);
116   /// Return lower bound of \f$2\pi\f$
117   FloatNum pi_twice_lower(void);
118   /// Return upper bound of \f$2\pi\f$
119   FloatNum pi_twice_upper(void);
120 
121   // Forward declaration
122   class FloatVal;
123 
124 }
125 
126 #include <gecode/float/num.hpp>
127 
128 namespace Gecode { namespace Float {
129 
130 
131 #if defined(_MSC_VER) && (defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP > 0)))
132 
133   /*
134    * This is used for the MSVC compiler for x64 or x86 with SSE enabled.
135    *
136    */
137   /// Rounding Base class (safe version)
138   typedef gecode_boost::numeric::interval_lib::save_state< gecode_boost::numeric::interval_lib::rounded_arith_std<FloatNum> >
139 	RoundingBase;
140 
141 #else
142 
143   /// Rounding Base class (optimized version)
144   typedef gecode_boost::numeric::interval_lib::rounded_arith_opp<FloatNum>
145     RoundingBase;
146 
147 #endif
148 
149   /**
150    * \brief Floating point rounding policy
151    *
152    * \ingroup TaskModelFloatVars
153    */
154   class Rounding : public RoundingBase {
155   public:
156     /// \name Constructor and destructor
157     //@{
158     /// Default constructor (configures full rounding mode)
159     Rounding(void);
160     /// Destructor (restores previous rounding mode)
161     ~Rounding(void);
162     //@}
163 
164     /// \name Arithmetic operations
165     //@{
166     /// Return lower bound of \a x plus \a y (domain: \f$ [-\infty;+\infty][-\infty;+\infty]\f$)
167     FloatNum add_down(FloatNum x, FloatNum y);
168     /// Return upper bound of \a x plus \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
169     FloatNum add_up  (FloatNum x, FloatNum y);
170     /// Return lower bound of \a x minus \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
171     FloatNum sub_down(FloatNum x, FloatNum y);
172     /// Return upper bound of \a x minus \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
173     FloatNum sub_up  (FloatNum x, FloatNum y);
174     /// Return lower bound of \a x times \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
175     FloatNum mul_down(FloatNum x, FloatNum y);
176     /// Return upper bound of \a x times \a y (domain: \f$ [-\infty;+\infty] [-\infty;+\infty]\f$)
177     FloatNum mul_up  (FloatNum x, FloatNum y);
178     /// Return lower bound of \a x divided by \a y (domain: \f$ [-\infty;+\infty] ([-\infty;+\infty]-{0})   \f$)
179     FloatNum div_down(FloatNum x, FloatNum y);
180     /// Return upper bound of \a x divided \a y (domain: \f$ [-\infty;+\infty] ([-\infty;+\infty]-{0})\f$)
181     FloatNum div_up  (FloatNum x, FloatNum y);
182     /// Return lower bound of square root of \a x (domain: \f$ ]0;+\infty]   \f$)
183     FloatNum sqrt_down(FloatNum x);
184     /// Return upper bound of square root of \a x (domain: \f$ ]0;+\infty]\f$)
185     FloatNum sqrt_up  (FloatNum x);
186     //@}
187 
188     /// \name Miscellaneous operations
189     //@{
190     /// Return median of \a x and \a y (domain: \f$ [-\infty;+\infty][-\infty;+\infty]\f$)
191     FloatNum median(FloatNum x, FloatNum y);
192     /// Return next downward-rounded integer of \a x (domain: \f$ [-\infty;+\infty]\f$)
193     FloatNum int_down(FloatNum x);
194     /// Return next upward-rounded integer of \a x (domain: \f$ [-\infty;+\infty] \f$)
195     FloatNum int_up  (FloatNum x);
196     //@}
197 
198 #ifdef GECODE_HAS_MPFR
199     /// \name Exponential functions
200     //@{
201     /// Return lower bound of exponential of \a x (domain: \f$ [-\infty;+\infty]\f$)
202     GECODE_FLOAT_EXPORT FloatNum exp_down(FloatNum x);
203     /// Return upper bound of exponential of \a x (domain: \f$ [-\infty;+\infty]\f$)
204     GECODE_FLOAT_EXPORT FloatNum exp_up  (FloatNum x);
205     /// Return lower bound of logarithm of \a x (domain: \f$ ]0;+\infty]\f$)
206     GECODE_FLOAT_EXPORT FloatNum log_down(FloatNum x);
207     /// Return upper bound of logarithm of \a x (domain: \f$ ]0;+\infty]\f$)
208     GECODE_FLOAT_EXPORT FloatNum log_up  (FloatNum x);
209     //@}
210 
211     /// \name Trigonometric functions
212     //@{
213     /// Return lower bound of sine of \a x (domain: \f$ [0;2\pi]\f$)
214     GECODE_FLOAT_EXPORT FloatNum sin_down(FloatNum x);
215     /// Return upper bound of sine of \a x (domain: \f$ [0;2\pi]\f$)
216     GECODE_FLOAT_EXPORT FloatNum sin_up  (FloatNum x);
217     /// Return lower bound of cosine of \a x (domain: \f$ [0;2\pi]\f$)
218     GECODE_FLOAT_EXPORT FloatNum cos_down(FloatNum x);
219     /// Return upper bound of cosine of \a x (domain: \f$ [0;2\pi]\f$)
220     GECODE_FLOAT_EXPORT FloatNum cos_up  (FloatNum x);
221     /// Return lower bound of tangent of \a x (domain: \f$ ]-\pi/2;\pi/2[\f$)
222     GECODE_FLOAT_EXPORT FloatNum tan_down(FloatNum x);
223     /// Return upper bound of tangent of \a x (domain: \f$ ]-\pi/2;\pi/2[\f$)
224     GECODE_FLOAT_EXPORT FloatNum tan_up  (FloatNum x);
225     //@}
226 
227     /// \name Inverse trigonometric functions
228     //@{
229     /// Return lower bound of arcsine of \a x (domain: \f$ [-1;1]\f$)
230     GECODE_FLOAT_EXPORT FloatNum asin_down(FloatNum x);
231     /// Return upper bound of arcsine of \a x (domain: \f$ [-1;1]\f$)
232     GECODE_FLOAT_EXPORT FloatNum asin_up  (FloatNum x);
233     /// Return lower bound of arccosine of \a x (domain: \f$ [-1;1]\f$)
234     GECODE_FLOAT_EXPORT FloatNum acos_down(FloatNum x);
235     /// Return upper bound of arccossine of \a x (domain: \f$ [-1;1]\f$)
236     GECODE_FLOAT_EXPORT FloatNum acos_up  (FloatNum x);
237     /// Return lower bound of arctangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
238     GECODE_FLOAT_EXPORT FloatNum atan_down(FloatNum x);
239     /// Return upper bound of arctangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
240     GECODE_FLOAT_EXPORT FloatNum atan_up  (FloatNum x);
241     //@}
242 
243     /// \name Hyperbolic functions
244     //@{
245     /// Return lower bound of hyperbolic sine of \a x (domain: \f$ [-\infty;+\infty]\f$)
246     GECODE_FLOAT_EXPORT FloatNum sinh_down(FloatNum x);
247     /// Return upper bound of hyperbolic sine of \a x (domain: \f$ [-\infty;+\infty]\f$)
248     GECODE_FLOAT_EXPORT FloatNum sinh_up  (FloatNum x);
249     /// Return lower bound of hyperbolic cosine of \a x (domain: \f$ [-\infty;+\infty]\f$)
250     GECODE_FLOAT_EXPORT FloatNum cosh_down(FloatNum x);
251     /// Return upper bound of hyperbolic cosine of \a x (domain: \f$ [-\infty;+\infty]\f$)
252     GECODE_FLOAT_EXPORT FloatNum cosh_up  (FloatNum x);
253     /// Return lower bound of hyperbolic tangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
254     GECODE_FLOAT_EXPORT FloatNum tanh_down(FloatNum x);
255     /// Return upper bound of hyperbolic tangent of \a x (domain: \f$ [-\infty;+\infty]\f$)
256     GECODE_FLOAT_EXPORT FloatNum tanh_up  (FloatNum x);
257     //@}
258 
259     /// \name Inverse hyperbolic functions
260     //@{
261     /// Return lower bound of hyperbolic arcsine of \a x (domain: \f$ [-\infty;+\infty]\f$)
262     GECODE_FLOAT_EXPORT FloatNum asinh_down(FloatNum x);
263     /// Return upper bound of hyperbolic arcsine of \a x (domain: \f$ [-\infty;+\infty]\f$)
264     GECODE_FLOAT_EXPORT FloatNum asinh_up  (FloatNum x);
265     /// Return lower bound of hyperbolic arccosine of \a x (domain: \f$ [1;+\infty]\f$)
266     GECODE_FLOAT_EXPORT FloatNum acosh_down(FloatNum x);
267     /// Return upper bound of hyperbolic arccosine of \a x (domain: \f$ [1;+\infty]\f$)
268     GECODE_FLOAT_EXPORT FloatNum acosh_up  (FloatNum x);
269     /// Return lower bound of hyperbolic arctangent of \a x (domain: \f$ [-1;1]\f$)
270     GECODE_FLOAT_EXPORT FloatNum atanh_down(FloatNum x);
271     /// Return upper bound of hyperbolic arctangent of \a x (domain: \f$ [-1;1]\f$)
272     GECODE_FLOAT_EXPORT FloatNum atanh_up  (FloatNum x);
273     //@}
274 #endif
275   };
276 
277 }}
278 
279 #include <gecode/float/rounding.hpp>
280 
281 namespace Gecode { namespace Float {
282 
283   /**
284    * \brief Test whether \a x is a subset of \a y
285    * \relates Gecode::FloatVal
286    */
287   bool subset(const FloatVal& x, const FloatVal& y);
288   /**
289    * \brief Test whether \a x is a proper subset of \a y
290    * \relates Gecode::FloatVal
291    */
292   bool proper_subset(const FloatVal& x, const FloatVal& y);
293   /**
294    * \brief Test whether \a x and \a y overlap
295    * \relates Gecode::FloatVal
296    */
297   bool overlap(const FloatVal& x, const FloatVal& y);
298 
299   /**
300    * \brief Return intersection of \a x and \a y
301    * \relates Gecode::FloatVal
302    */
303   FloatVal intersect(const FloatVal& x, const FloatVal& y);
304   /**
305    * \brief Return hull of \a x and \a y
306    * \relates Gecode::FloatVal
307    */
308   FloatVal hull(const FloatVal& x, const FloatVal& y);
309   /**
310    * \brief Return hull of \a x and \a y
311    * \relates Gecode::FloatVal
312    */
313   FloatVal hull(const FloatVal& x, const FloatNum& y);
314   /**
315    * \brief Return hull of \a x and \a y
316    * \relates Gecode::FloatVal
317    */
318   FloatVal hull(const FloatNum& x, const FloatVal& y);
319   /**
320    * \brief Return hull of \a x and \a y
321    * \relates Gecode::FloatVal
322    */
323   FloatVal hull(const FloatNum& x, const FloatNum& y);
324 
325 }}
326 
327 namespace Gecode {
328 
329   /**
330    * \brief Float value type
331    *
332    * \ingroup TaskModelFloatVars
333    */
334   class FloatVal {
335     friend FloatVal operator +(const FloatVal& x);
336     friend FloatVal operator -(const FloatVal& x);
337     friend FloatVal operator +(const FloatVal& x, const FloatVal& y);
338     friend FloatVal operator +(const FloatVal& x, const FloatNum& y);
339     friend FloatVal operator +(const FloatNum& x, const FloatVal& y);
340     friend FloatVal operator -(const FloatVal& x, const FloatVal& y);
341     friend FloatVal operator -(const FloatVal& x, const FloatNum& y);
342     friend FloatVal operator -(const FloatNum& x, const FloatVal& y);
343     friend FloatVal operator *(const FloatVal& x, const FloatVal& y);
344     friend FloatVal operator *(const FloatVal& x, const FloatNum& y);
345     friend FloatVal operator *(const FloatNum& x, const FloatVal& y);
346     friend FloatVal operator /(const FloatVal& x, const FloatVal& y);
347     friend FloatVal operator /(const FloatVal& x, const FloatNum& y);
348     friend FloatVal operator /(const FloatNum& x, const FloatVal& y);
349 
350     friend bool operator <(const FloatVal& x, const FloatVal& y);
351     friend bool operator <(const FloatVal& x, const FloatNum& y);
352     friend bool operator <(const FloatNum& x, const FloatVal& y);
353     friend bool operator <=(const FloatVal& x, const FloatVal& y);
354     friend bool operator <=(const FloatVal& x, const FloatNum& y);
355     friend bool operator <=(const FloatNum& x, const FloatVal& y);
356     friend bool operator >(const FloatVal& x, const FloatVal& y);
357     friend bool operator >(const FloatVal& x, const FloatNum& y);
358     friend bool operator >(const FloatNum& x, const FloatVal& y);
359     friend bool operator >=(const FloatVal& x, const FloatVal& y);
360     friend bool operator >=(const FloatVal& x, const FloatNum& y);
361     friend bool operator >=(const FloatNum& x, const FloatVal& y);
362     friend bool operator ==(const FloatVal& x, const FloatVal& y);
363     friend bool operator ==(const FloatVal& x, const FloatNum& y);
364     friend bool operator ==(const FloatNum& x, const FloatVal& y);
365     friend bool operator !=(const FloatVal& x, const FloatVal& y);
366     friend bool operator !=(const FloatVal& x, const FloatNum& y);
367     friend bool operator !=(const FloatNum& x, const FloatVal& y);
368 
369     template<class Char, class Traits>
370     friend std::basic_ostream<Char,Traits>&
371     operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
372 
373     friend FloatVal abs(const FloatVal& x);
374     friend FloatVal sqrt(const FloatVal& x);
375     friend FloatVal sqr(const FloatVal& x);
376     friend FloatVal pow(const FloatVal& x, int n);
377     friend FloatVal nroot(const FloatVal& x, int n);
378 
379     friend FloatVal max(const FloatVal& x, const FloatVal& y);
380     friend FloatVal max(const FloatVal& x, const FloatNum& y);
381     friend FloatVal max(const FloatNum& x, const FloatVal& y);
382     friend FloatVal min(const FloatVal& x, const FloatVal& y);
383     friend FloatVal min(const FloatVal& x, const FloatNum& y);
384     friend FloatVal min(const FloatNum& x, const FloatVal& y);
385 
386 #ifdef GECODE_HAS_MPFR
387     friend FloatVal exp(const FloatVal& x);
388     friend FloatVal log(const FloatVal& x);
389     friend FloatVal fmod(const FloatVal& x, const FloatVal& y);
390     friend FloatVal fmod(const FloatVal& x, const FloatNum& y);
391     friend FloatVal fmod(const FloatNum& x, const FloatVal& y);
392     friend FloatVal sin(const FloatVal& x);
393     friend FloatVal cos(const FloatVal& x);
394     friend FloatVal tan(const FloatVal& x);
395     friend FloatVal asin(const FloatVal& x);
396     friend FloatVal acos(const FloatVal& x);
397     friend FloatVal atan(const FloatVal& x);
398     friend FloatVal sinh(const FloatVal& x);
399     friend FloatVal cosh(const FloatVal& x);
400     friend FloatVal tanh(const FloatVal& x);
401     friend FloatVal asinh(const FloatVal& x);
402     friend FloatVal acosh(const FloatVal& x);
403     friend FloatVal atanh(const FloatVal& x);
404 #endif
405 
406     friend bool Float::subset(const FloatVal& x, const FloatVal& y);
407     friend bool Float::proper_subset(const FloatVal& x, const FloatVal& y);
408     friend bool Float::overlap(const FloatVal& x, const FloatVal& y);
409     friend FloatVal Float::intersect(const FloatVal& x, const FloatVal& y);
410     friend FloatVal Float::hull(const FloatVal& x, const FloatVal& y);
411     friend FloatVal Float::hull(const FloatVal& x, const FloatNum& y);
412     friend FloatVal Float::hull(const FloatNum& x, const FloatVal& y);
413     friend FloatVal Float::hull(const FloatNum& x, const FloatNum& y);
414   protected:
415     /// Used rounding policies
416     typedef gecode_boost::numeric::interval_lib::save_state<Float::Rounding> R;
417     /// Used checking policy
418     typedef gecode_boost::numeric::interval_lib::checking_strict<FloatNum> P;
419     /// Implementation type for float value
420     typedef gecode_boost::numeric::interval
421       <FloatNum,
422        gecode_boost::numeric::interval_lib::policies<R, P> >
423     FloatValImpType;
424     /// Implementation of float value
425     FloatValImpType x;
426     /// Initialize from implementation \a i
427     explicit FloatVal(const FloatValImpType& i);
428   public:
429     /// \name Constructors and initialization
430     //@{
431     /// Default constructor
432     FloatVal(void);
433     /// Initialize with float number \a n
434     FloatVal(const FloatNum& n);
435     /// Initialize with lower bound \a l and upper bound \a u
436     FloatVal(const FloatNum& l, const FloatNum& u);
437     /// Copy constructor
438     FloatVal(const FloatVal& v);
439 
440     /// Assignment operator
441     FloatVal& operator =(const FloatNum& n);
442     /// Assignment operator
443     FloatVal& operator =(const FloatVal& v);
444 
445     /// Assign lower bound \a l and upper bound \a u
446     void assign(FloatNum const &l, FloatNum const &u);
447     //@}
448 
449     /// \name Value access
450     //@{
451     /// Return lower bound
452     FloatNum min(void) const;
453     /// Return upper bound
454     FloatNum max(void) const;
455     /// Return size of float value (distance between maximum and minimum)
456     FloatNum size(void) const;
457     /// Return median of float value
458     FloatNum med(void) const;
459     //@}
460 
461     /// \name Value tests
462     //@{
463     /// Test whether float is tight
464     bool tight(void) const;
465     /// Test whether float is a singleton
466     bool singleton(void) const;
467     /// Test whether \a n is included
468     bool in(FloatNum n) const;
469     /// Test whether zero is included
470     bool zero_in(void) const;
471     //@}
472 
473     /// \name Float value construction
474     //@{
475     /// Return hull of \a x and \a y
476     static FloatVal hull(FloatNum x, FloatNum y);
477     /// Return \f$\pi/2\f$
478     static FloatVal pi_half(void);
479     /// Return lower bound of \f$\pi\f$
480     static FloatVal pi(void);
481     /// Return \f$2\pi\f$
482     static FloatVal pi_twice(void);
483     //@}
484 
485     /// \name Update operators
486     //@{
487     /// Increment by \a n
488     FloatVal& operator +=(const FloatNum& n);
489     /// Subtract by \a n
490     FloatVal& operator -=(const FloatNum& n);
491     /// Multiply by \a n
492     FloatVal& operator *=(const FloatNum& n);
493     /// Divide by \a n
494     FloatVal& operator /=(const FloatNum& n);
495     /// Increment by \a v
496     FloatVal& operator +=(const FloatVal& v);
497     /// Subtract by \a v
498     FloatVal& operator -=(const FloatVal& v);
499     /// Multiply by \a v
500     FloatVal& operator *=(const FloatVal& v);
501     /// Divide by \a v
502     FloatVal& operator /=(const FloatVal& v);
503     //@}
504   };
505 
506   /**
507    * \brief Arithmetic operator
508    * \relates Gecode::FloatVal
509    */
510   FloatVal operator +(const FloatVal& x);
511   /**
512    * \brief Arithmetic operator
513    * \relates Gecode::FloatVal
514    */
515   FloatVal operator -(const FloatVal& x);
516 
517   /**
518    * \brief Arithmetic operator
519    * \relates Gecode::FloatVal
520    */
521   FloatVal operator +(const FloatVal& x, const FloatVal& y);
522   /**
523    * \brief Arithmetic operator
524    * \relates Gecode::FloatVal
525    */
526   FloatVal operator +(const FloatVal& x, const FloatNum& y);
527   /**
528    * \brief Arithmetic operator
529    * \relates Gecode::FloatVal
530    */
531   FloatVal operator +(const FloatNum& x, const FloatVal& y);
532   /**
533    * \brief Arithmetic operator
534    * \relates Gecode::FloatVal
535    */
536   FloatVal operator -(const FloatVal& x, const FloatVal& y);
537   /**
538    * \brief Arithmetic operator
539    * \relates Gecode::FloatVal
540    */
541   FloatVal operator -(const FloatVal& x, const FloatNum& y);
542   /**
543    * \brief Arithmetic operator
544    * \relates Gecode::FloatVal
545    */
546   FloatVal operator -(const FloatNum& x, const FloatVal& y);
547   /**
548    * \brief Arithmetic operator
549    * \relates Gecode::FloatVal
550    */
551   FloatVal operator *(const FloatVal& x, const FloatVal& y);
552   /**
553    * \brief Arithmetic operator
554    * \relates Gecode::FloatVal
555    */
556   FloatVal operator *(const FloatVal& x, const FloatNum& y);
557   /**
558    * \brief Arithmetic operator
559    * \relates Gecode::FloatVal
560    */
561   FloatVal operator *(const FloatNum& x, const FloatVal& y);
562   /**
563    * \brief Arithmetic operator
564    * \relates Gecode::FloatVal
565    */
566   FloatVal operator /(const FloatVal& x, const FloatVal& y);
567   /**
568    * \brief Arithmetic operator
569    * \relates Gecode::FloatVal
570    */
571   FloatVal operator /(const FloatVal& x, const FloatNum& y);
572   /**
573    * \brief Arithmetic operator
574    * \relates Gecode::FloatVal
575    */
576   FloatVal operator /(const FloatNum& r, const FloatVal& x);
577 
578   /**
579    * \brief Comparison operator
580    * \relates Gecode::FloatVal
581    */
582   bool operator <(const FloatVal& x, const FloatVal& y);
583   /**
584    * \brief Comparison operator
585    * \relates Gecode::FloatVal
586    */
587   bool operator <(const FloatVal& x, const FloatNum& y);
588   /**
589    * \brief Comparison operator
590    * \relates Gecode::FloatVal
591    */
592   bool operator <(const FloatNum& x, const FloatVal& y);
593 
594   /**
595    * \brief Comparison operator
596    * \relates Gecode::FloatVal
597    */
598   bool operator <=(const FloatVal& x, const FloatVal& y);
599   /**
600    * \brief Comparison operator
601    * \relates Gecode::FloatVal
602    */
603   bool operator <=(const FloatVal& x, const FloatNum& y);
604   /**
605    * \brief Comparison operator
606    * \relates Gecode::FloatVal
607    */
608   bool operator <=(const FloatNum& x, const FloatVal& y);
609 
610   /**
611    * \brief Comparison operator
612    * \relates Gecode::FloatVal
613    */
614   bool operator >(const FloatVal& x, const FloatVal& y);
615   /**
616    * \brief Comparison operator
617    * \relates Gecode::FloatVal
618    */
619   bool operator >(const FloatVal& x, const FloatNum& y);
620   /**
621    * \brief Comparison operator
622    * \relates Gecode::FloatVal
623    */
624   bool operator >(const FloatNum& x, const FloatVal& y);
625 
626   /**
627    * \brief Comparison operator
628    * \relates Gecode::FloatVal
629    */
630   bool operator >=(const FloatVal& x, const FloatVal& y);
631   /**
632    * \brief Comparison operator
633    * \relates Gecode::FloatVal
634    */
635   bool operator >=(const FloatVal& x, const FloatNum& y);
636   /**
637    * \brief Comparison operator
638    * \relates Gecode::FloatVal
639    */
640   bool operator >=(const FloatNum& x, const FloatVal& y);
641   /**
642    * \brief Comparison operator
643    * \relates Gecode::FloatVal
644    */
645   bool operator ==(const FloatVal& x, const FloatVal& y);
646   /**
647    * \brief Comparison operator
648    * \relates Gecode::FloatVal
649    */
650   bool operator ==(const FloatVal& x, const FloatNum& y);
651   /**
652    * \brief Comparison operator
653    * \relates Gecode::FloatVal
654    */
655   bool operator ==(const FloatNum& x, const FloatVal& y);
656 
657   /**
658    * \brief Comparison operator
659    * \relates Gecode::FloatVal
660    */
661   bool operator !=(const FloatVal& x, const FloatVal& y);
662   /**
663    * \brief Comparison operator
664    * \relates Gecode::FloatVal
665    */
666   bool operator !=(const FloatVal& x, const FloatNum& y);
667   /**
668    * \brief Comparison operator
669    * \relates Gecode::FloatVal
670    */
671   bool operator !=(const FloatNum& x, const FloatVal& y);
672 
673   /**
674    * \brief Print float value \a x
675    * \relates Gecode::FloatVal
676    */
677   template<class Char, class Traits>
678   std::basic_ostream<Char,Traits>&
679   operator <<(std::basic_ostream<Char,Traits>& os, const FloatVal& x);
680 
681   /**
682    * \brief Return absolute value of \a x
683    * \relates Gecode::FloatVal
684    */
685   FloatVal abs(const FloatVal& x);
686   /**
687    * \brief Return square root of \a x
688    * \relates Gecode::FloatVal
689    */
690   FloatVal sqrt(const FloatVal& x);
691   /**
692    * \brief Return square of \a x
693    * \relates Gecode::FloatVal
694    */
695   FloatVal sqr(const FloatVal& x);
696   /**
697    * \brief Return \a n -th power of \a x
698    * \relates Gecode::FloatVal
699    */
700   FloatVal pow(const FloatVal& x, int n);
701   /**
702    * \brief Return \a n -th root of \a x
703    * \relates Gecode::FloatVal
704    */
705   FloatVal nroot(const FloatVal& x, int n);
706 
707   /**
708    * \brief Return maximum of \a x and \a y
709    * \relates Gecode::FloatVal
710    */
711   FloatVal max(const FloatVal& x, const FloatVal& y);
712   /**
713    * \brief Return maximum of \a x and \a y
714    * \relates Gecode::FloatVal
715    */
716   FloatVal max(const FloatVal& x, const FloatNum& y);
717   /**
718    * \brief Return maximum of \a x and \a y
719    * \relates Gecode::FloatVal
720    */
721   FloatVal max(const FloatNum& x, const FloatVal& y);
722   /**
723    * \brief Return minimum of \a x and \a y
724    * \relates Gecode::FloatVal
725    */
726   FloatVal min(const FloatVal& x, const FloatVal& y);
727   /**
728    * \brief Return minimum of \a x and \a y
729    * \relates Gecode::FloatVal
730    */
731   FloatVal min(const FloatVal& x, const FloatNum& y);
732   /**
733    * \brief Return minimum of \a x and \a y
734    * \relates Gecode::FloatVal
735    */
736   FloatVal min(const FloatNum& x, const FloatVal& y);
737 
738 #ifdef GECODE_HAS_MPFR
739   /* transcendental functions: exp, log */
740   /**
741    * \brief Return exponential of \a x
742    * \relates Gecode::FloatVal
743    */
744   FloatVal exp(const FloatVal& x);
745   /**
746    * \brief Return logarithm of \a x
747    * \relates Gecode::FloatVal
748    */
749   FloatVal log(const FloatVal& x);
750 
751   /**
752    * \brief Trigonometric function argument reduction
753    * \relates Gecode::FloatVal
754    */
755   FloatVal fmod(const FloatVal& x, const FloatVal& y);
756   /**
757    * \brief  Trigonometric function argument reduction
758    * \relates Gecode::FloatVal
759    */
760   FloatVal fmod(const FloatVal& x, const FloatNum& y);
761   /**
762    * \brief  Trigonometric function argument reduction
763    * \relates Gecode::FloatVal
764    */
765   FloatVal fmod(const FloatNum& x, const FloatVal& y);
766 
767   /**
768    * \brief Return sine of \a x
769    * \relates Gecode::FloatVal
770    */
771   FloatVal sin(const FloatVal& x);
772   /**
773    * \brief  Return cosine of \a x
774    * \relates Gecode::FloatVal
775    */
776   FloatVal cos(const FloatVal& x);
777   /**
778    * \brief  Return tangent of \a x
779    * \relates Gecode::FloatVal
780    */
781   FloatVal tan(const FloatVal& x);
782   /**
783    * \brief  Return arcsine of \a x
784    * \relates Gecode::FloatVal
785    */
786   FloatVal asin(const FloatVal& x);
787   /**
788    * \brief  Return arccosine of \a x
789    * \relates Gecode::FloatVal
790    */
791   FloatVal acos(const FloatVal& x);
792   /**
793    * \brief  Return arctangent of \a x
794    * \relates Gecode::FloatVal
795    */
796   FloatVal atan(const FloatVal& x);
797 
798   /**
799    * \brief  Return hyperbolic of \a x
800    * \relates Gecode::FloatVal
801    */
802   FloatVal sinh(const FloatVal& x);
803   /**
804    * \brief  Return hyperbolic of \a x
805    * \relates Gecode::FloatVal
806    */
807   FloatVal cosh(const FloatVal& x);
808   /**
809    * \brief  Return hyperbolic of \a x
810    * \relates Gecode::FloatVal
811    */
812   FloatVal tanh(const FloatVal& x);
813   /**
814    * \brief  Return hyperbolic of \a x
815    * \relates Gecode::FloatVal
816    */
817   FloatVal asinh(const FloatVal& x);
818   /**
819    * \brief  Return hyperbolic of \a x
820    * \relates Gecode::FloatVal
821    */
822   FloatVal acosh(const FloatVal& x);
823   /**
824    * \brief  Return hyperbolic of \a x
825    * \relates Gecode::FloatVal
826    */
827   FloatVal atanh(const FloatVal& x);
828 
829 #endif
830 
831 }
832 
833 #include <gecode/float/val.hpp>
834 
835 namespace Gecode { namespace Float {
836 
837   /**
838    * \brief Numerical limits for floating point variables
839    *
840    * \ingroup TaskModelFloatVars
841    */
842   namespace Limits {
843     /// Largest allowed float value
844     const FloatNum max = std::numeric_limits<FloatNum>::max();
845     /// Smallest allowed float value
846     const FloatNum min = -max;
847     /// Return whether float \a n is a valid number
848     bool valid(const FloatVal& n);
849     /// Check whether float \a n is a valid number, otherwise throw out of limits exception with information \a l
850     void check(const FloatVal& n, const char* l);
851   }
852 
853 }}
854 
855 #include <gecode/float/limits.hpp>
856 
857 #include <gecode/float/var-imp.hpp>
858 
859 namespace Gecode {
860 
861   namespace Float {
862     class FloatView;
863   }
864 
865   /**
866    * \brief Float variables
867    *
868    * \ingroup TaskModelFloatVars
869    */
870   class FloatVar : public VarImpVar<Float::FloatVarImp> {
871     friend class FloatVarArray;
872     friend class FloatVarArgs;
873   private:
874     using VarImpVar<Float::FloatVarImp>::x;
875     /**
876      * \brief Initialize variable with range domain
877      *
878      * The variable is created with a domain ranging from \a min
879      * to \a max. No exceptions are thrown.
880      */
881     void _init(Space& home, FloatNum min, FloatNum max);
882   public:
883     /// \name Constructors and initialization
884     //@{
885     /// Default constructor
886     FloatVar(void);
887     /// Initialize from float variable \a y
888     FloatVar(const FloatVar& y);
889     /// Initialize from float view \a y
890     FloatVar(const Float::FloatView& y);
891     /**
892      * \brief Initialize variable with range domain
893      *
894      * The variable is created with a domain ranging from \a min
895      * to \a max. The following exceptions might be thrown:
896      *  - If \a min is greater than \a max, an exception of type
897      *    Gecode::Float::VariableEmptyDomain is thrown.
898      *  - If \a min or \a max exceed the limits for floats as defined
899      *    in Gecode::Float::Limits, an exception of type
900      *    Gecode::Float::OutOfLimits is thrown.
901      */
902     GECODE_FLOAT_EXPORT FloatVar(Space& home, FloatNum min, FloatNum max);
903     //@}
904 
905     /// \name Value access
906     //@{
907     /// Return domain
908     FloatVal domain(void) const;
909     /// Return minimum of domain
910     FloatNum min(void) const;
911     /// Return maximum of domain
912     FloatNum max(void) const;
913     /// Return median of domain
914     FloatNum med(void) const;
915     /// Return size of domain (distance between maximum and minimum)
916     FloatNum size(void) const;
917     /**
918      * \brief Return assigned value
919      *
920      * Throws an exception of type Float::ValOfUnassignedVar if variable
921      * is not yet assigned.
922      *
923      */
924     FloatVal val(void) const;
925 
926     //@}
927 
928     /// \name Domain tests
929     //@{
930     /// Test whether \a n is contained in domain
931     bool in(const FloatVal& n) const;
932     //@}
933   };
934 
935   /**
936    * \brief Print float variable \a x
937    * \relates Gecode::FloatVar
938    */
939   template<class Char, class Traits>
940   std::basic_ostream<Char,Traits>&
941   operator <<(std::basic_ostream<Char,Traits>& os, const FloatVar& x);
942 }
943 
944 #include <gecode/float/view.hpp>
945 #include <gecode/float/array-traits.hpp>
946 
947 namespace Gecode {
948 
949   /// Passing float arguments
950   class FloatValArgs : public ArgArray<FloatVal> {
951   public:
952     /// \name Constructors and initialization
953     //@{
954     /// Allocate empty array
955     FloatValArgs(void);
956     /// Allocate array with \a n elements
957     explicit FloatValArgs(int n);
958     /// Allocate array and copy elements from \a x
959     FloatValArgs(const SharedArray<FloatVal>& x);
960     /// Allocate array and copy elements from \a x
961     FloatValArgs(const std::vector<FloatVal>& x);
962     /// Allocate array and copy elements from \a x
963     FloatValArgs(std::initializer_list<FloatVal> x);
964     /// Allocate array and copy elements from \a first to \a last
965     template<class InputIterator>
966     FloatValArgs(InputIterator first, InputIterator last);
967     /// Allocate array with \a n elements and initialize with elements from array \a e
968     FloatValArgs(int n, const FloatVal* e);
969     /// Initialize from primitive argument array \a a (copy elements)
970     FloatValArgs(const ArgArray<FloatVal>& a);
971 
972     /// Allocate array with \a n elements such that for all \f$0\leq i<n: x_i=\text{start}+i\cdot\text{inc}\f$
973     GECODE_FLOAT_EXPORT
974     static FloatValArgs create(int n, FloatVal start, int inc=1);
975     //@}
976   };
977 
978   /// \brief Passing float variables
979   class FloatVarArgs : public VarArgArray<FloatVar> {
980   public:
981     /// \name Constructors and initialization
982     //@{
983     /// Allocate empty array
984     FloatVarArgs(void);
985     /// Allocate array with \a n elements
986     explicit FloatVarArgs(int n);
987     /// Initialize from variable argument array \a a (copy elements)
988     FloatVarArgs(const FloatVarArgs& a);
989     /// Initialize from variable array \a a (copy elements)
990     FloatVarArgs(const VarArray<FloatVar>& a);
991     /// Initialize from vector \a a
992     FloatVarArgs(const std::vector<FloatVar>& a);
993     /// Initialize from list \a a
994     FloatVarArgs(std::initializer_list<FloatVar> a);
995     /// Initialize from InputIterator \a first and \a last
996     template<class InputIterator>
997     FloatVarArgs(InputIterator first, InputIterator last);
998     /**
999      * \brief Initialize array with \a n new variables
1000      *
1001      * The variables are created with a domain ranging from \a min
1002      * to \a max. The following execptions might be thrown:
1003      *  - If \a min is greater than \a max, an exception of type
1004      *    Gecode::Float::VariableEmptyDomain is thrown.
1005      *  - If \a min or \a max exceed the limits for floats as defined
1006      *    in Gecode::Float::Limits, an exception of type
1007      *    Gecode::Float::OutOfLimits is thrown.
1008      */
1009     GECODE_FLOAT_EXPORT
1010     FloatVarArgs(Space& home, int n, FloatNum min, FloatNum max);
1011     //@}
1012   };
1013   //@}
1014 
1015   /**
1016    * \defgroup TaskModelFloatVarArrays Variable arrays
1017    *
1018    * Variable arrays can store variables. They are typically used
1019    * for storing the variables being part of a solution (script). However,
1020    * they can also be used for temporary purposes (even though
1021    * memory is not reclaimed until the space it is created for
1022    * is deleted).
1023    * \ingroup TaskModelFloat
1024    */
1025 
1026   /**
1027    * \brief Float variable array
1028    * \ingroup TaskModelFloatVarArrays
1029    */
1030   class FloatVarArray : public VarArray<FloatVar> {
1031   public:
1032     /// \name Creation and initialization
1033     //@{
1034     /// Default constructor (array of size 0)
1035     FloatVarArray(void);
1036     /// Allocate array for \a n float variables (variables are uninitialized)
1037     FloatVarArray(Space& home, int n);
1038     /// Initialize from float variable array \a a (share elements)
1039     FloatVarArray(const FloatVarArray& a);
1040     /// Initialize from float variable argument array \a a (copy elements)
1041     FloatVarArray(Space& home, const FloatVarArgs& a);
1042     /**
1043      * \brief Initialize array with \a n new variables
1044      *
1045      * The variables are created with a domain ranging from \a min
1046      * to \a max. The following execptions might be thrown:
1047      *  - If \a min is greater than \a max, an exception of type
1048      *    Gecode::Float::VariableEmptyDomain is thrown.
1049      *  - If \a min or \a max exceed the limits for floats as defined
1050      *    in Gecode::Float::Limits, an exception of type
1051      *    Gecode::Float::OutOfLimits is thrown.
1052      */
1053     GECODE_FLOAT_EXPORT
1054     FloatVarArray(Space& home, int n, FloatNum min, FloatNum max);
1055     //@}
1056   };
1057 
1058 }
1059 
1060 #include <gecode/float/array.hpp>
1061 
1062 namespace Gecode {
1063 
1064   /**
1065    * \brief Relation types for floats
1066    * \ingroup TaskModelFloat
1067    */
1068   enum FloatRelType {
1069     FRT_EQ, ///< Equality (\f$=\f$)
1070     FRT_NQ, ///< Disequality (\f$\neq\f$)
1071     FRT_LQ, ///< Less or equal (\f$\leq\f$)
1072     FRT_LE, ///< Less (\f$<\f$)
1073     FRT_GQ, ///< Greater or equal (\f$\geq\f$)
1074     FRT_GR ///< Greater (\f$>\f$)
1075   };
1076 
1077   /**
1078    * \defgroup TaskModelFloatDomain Domain constraints
1079    * \ingroup TaskModelFloat
1080    *
1081    */
1082 
1083   //@{
1084   /// Propagates \f$x=n\f$
1085   GECODE_FLOAT_EXPORT void
1086   dom(Home home, FloatVar x, FloatVal n);
1087   /// Propagates \f$ x_i=n\f$ for all \f$0\leq i<|x|\f$
1088   GECODE_FLOAT_EXPORT void
1089   dom(Home home, const FloatVarArgs& x, FloatVal n);
1090   /// Propagates \f$ l\leq x\leq u\f$
1091   GECODE_FLOAT_EXPORT void
1092   dom(Home home, FloatVar x, FloatNum l, FloatNum m);
1093   /// Propagates \f$ l\leq x_i\leq u\f$ for all \f$0\leq i<|x|\f$
1094   GECODE_FLOAT_EXPORT void
1095   dom(Home home, const FloatVarArgs& x, FloatNum l, FloatNum u);
1096   /// Post domain consistent propagator for \f$ (x=n) \equiv r\f$
1097   GECODE_FLOAT_EXPORT void
1098   dom(Home home, FloatVar x, FloatVal n, Reify r);
1099   /// Post domain consistent propagator for \f$ (l\leq x \leq u) \equiv r\f$
1100   GECODE_FLOAT_EXPORT void
1101   dom(Home home, FloatVar x, FloatNum l, FloatNum u, Reify r);
1102   /// Constrain domain of \a x according to domain of \a d
1103   GECODE_FLOAT_EXPORT void
1104   dom(Home home, FloatVar x, FloatVar d);
1105   /// Constrain domain of \f$ x_i \f$ according to domain of \f$ d_i \f$ for all \f$0\leq i<|x|\f$
1106   GECODE_FLOAT_EXPORT void
1107   dom(Home home, const FloatVarArgs& x, const FloatVarArgs& d);
1108   //@}
1109 
1110   /**
1111    * \defgroup TaskModelFloatRelFloat Simple relation constraints over float variables
1112    * \ingroup TaskModelFloat
1113    */
1114   /** \brief Post propagator for \f$ x_0 \sim_{frt} x_1\f$
1115    *
1116    * \ingroup TaskModelFloatRelFloat
1117    */
1118   GECODE_FLOAT_EXPORT void
1119   rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1);
1120   /** \brief Propagates \f$ x \sim_{frt} c\f$
1121    * \ingroup TaskModelFloatRelFloat
1122    */
1123   GECODE_FLOAT_EXPORT void
1124   rel(Home home, FloatVar x, FloatRelType frt, FloatVal c);
1125   /** \brief Post propagator for \f$(x \sim_{frt} c)\equiv r\f$
1126    * \ingroup TaskModelFloatRelFloat
1127    */
1128   GECODE_FLOAT_EXPORT void
1129   rel(Home home, FloatVar x, FloatRelType frt, FloatVal c, Reify r);
1130   /** \brief Post propagator for \f$(x_0 \sim_{frt} x_1)\equiv r\f$
1131    * \ingroup TaskModelFloatRelFloat
1132    */
1133   GECODE_FLOAT_EXPORT void
1134   rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1, Reify r);
1135   /** \brief Propagates \f$ x_i \sim_{frt} c \f$ for all \f$0\leq i<|x|\f$
1136    * \ingroup TaskModelFloatRelFloat
1137    */
1138   GECODE_FLOAT_EXPORT void
1139   rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVal c);
1140   /** \brief Propagates \f$ x_i \sim_{frt} y \f$ for all \f$0\leq i<|x|\f$
1141    * \ingroup TaskModelFloatRelFloat
1142    */
1143   GECODE_FLOAT_EXPORT void
1144   rel(Home home, const FloatVarArgs& x, FloatRelType frt, FloatVar y);
1145   /** \brief Post propagator for if-then-else constraint
1146    *
1147    * Posts propagator for \f$ z = b ? x : y \f$
1148    *
1149    * \ingroup TaskModelFloatRelFloat
1150    */
1151   GECODE_FLOAT_EXPORT void
1152   ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z);
1153 
1154 }
1155 
1156 
1157 namespace Gecode {
1158 
1159   /**
1160    * \defgroup TaskModelFloatArith Arithmetic constraints
1161    * \ingroup TaskModelFloat
1162    */
1163 
1164   //@{
1165   /** \brief Post propagator for \f$ \min\{x_0,x_1\}=x_2\f$
1166    */
1167   GECODE_FLOAT_EXPORT void
1168   min(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
1169   /** \brief Post propagator for \f$ \min x=y\f$
1170    * If \a x is empty, an exception of type Float::TooFewArguments is thrown.
1171    */
1172   GECODE_FLOAT_EXPORT void
1173   min(Home home, const FloatVarArgs& x, FloatVar y);
1174   /** \brief Post propagator for \f$ \max\{x_0,x_1\}=x_2\f$
1175    */
1176   GECODE_FLOAT_EXPORT void
1177   max(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
1178   /** \brief Post propagator for \f$ \max x=y\f$
1179    * If \a x is empty, an exception of type Float::TooFewArguments is thrown.
1180    */
1181   GECODE_FLOAT_EXPORT void
1182   max(Home home, const FloatVarArgs& x, FloatVar y);
1183 
1184   /** \brief Post propagator for \f$ |x_0|=x_1\f$
1185    */
1186   GECODE_FLOAT_EXPORT void
1187   abs(Home home, FloatVar x0, FloatVar x1);
1188 
1189   /** \brief Post propagator for \f$x_0\cdot x_1=x_2\f$
1190    */
1191   GECODE_FLOAT_EXPORT void
1192   mult(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
1193 
1194   /** \brief Post propagator for \f$x_0\cdot x_0=x_1\f$
1195    */
1196   GECODE_FLOAT_EXPORT void
1197   sqr(Home home, FloatVar x0, FloatVar x1);
1198 
1199   /** \brief Post propagator for \f$\sqrt{x_0}=x_1\f$
1200    */
1201   GECODE_FLOAT_EXPORT void
1202   sqrt(Home home, FloatVar x0, FloatVar x1);
1203 
1204   /** \brief Post propagator for \f${x_0}^{n}=x_1\f$ for $n\geq 0$
1205    */
1206   GECODE_FLOAT_EXPORT void
1207   pow(Home home, FloatVar x0, int n, FloatVar x1);
1208 
1209   /** \brief Post propagator for \f${x_0}^{1/n}=x_1\f$ for $n\geq 0$
1210    */
1211   GECODE_FLOAT_EXPORT void
1212   nroot(Home home, FloatVar x0, int n, FloatVar x1);
1213 
1214   /** \brief Post propagator for \f$x_0\ \mathrm{div}\ x_1=x_2\f$
1215    */
1216   GECODE_FLOAT_EXPORT void
1217   div(Home home, FloatVar x0, FloatVar x1, FloatVar x2);
1218 #ifdef GECODE_HAS_MPFR
1219   /** \brief Post propagator for \f$ \mathrm{exp}(x_0)=x_1\f$
1220    */
1221   GECODE_FLOAT_EXPORT void
1222   exp(Home home, FloatVar x0, FloatVar x1);
1223   /** \brief Post propagator for \f$ \mathrm{log}_e(x_0)=x_1\f$
1224    */
1225   GECODE_FLOAT_EXPORT void
1226   log(Home home, FloatVar x0, FloatVar x1);
1227   /** \brief Post propagator for \f$ \mathit{base}^{x_0}=x_1\f$
1228    */
1229   GECODE_FLOAT_EXPORT void
1230   pow(Home home, FloatNum base, FloatVar x0, FloatVar x1);
1231   /** \brief Post propagator for \f$ \mathrm{log}_{\mathit{base}}(x_0)=x_1\f$
1232    */
1233   GECODE_FLOAT_EXPORT void
1234   log(Home home, FloatNum base, FloatVar x0, FloatVar x1);
1235   /** \brief Post propagator for \f$ \mathrm{asin}(x_0)=x_1\f$
1236    */
1237   GECODE_FLOAT_EXPORT void
1238   asin(Home home, FloatVar x0, FloatVar x1);
1239   /** \brief Post propagator for \f$ \mathrm{sin}(x_0)=x_1\f$
1240    */
1241   GECODE_FLOAT_EXPORT void
1242   sin(Home home, FloatVar x0, FloatVar x1);
1243   /** \brief Post propagator for \f$ \mathrm{acos}(x_0)=x_1\f$
1244    */
1245   GECODE_FLOAT_EXPORT void
1246   acos(Home home, FloatVar x0, FloatVar x1);
1247   /** \brief Post propagator for \f$ \mathrm{cos}(x_0)=x_1\f$
1248    */
1249   GECODE_FLOAT_EXPORT void
1250   cos(Home home, FloatVar x0, FloatVar x1);
1251   /** \brief Post propagator for \f$ \mathrm{atan}(x_0)=x_1\f$
1252    */
1253   GECODE_FLOAT_EXPORT void
1254   atan(Home home, FloatVar x0, FloatVar x1);
1255   /** \brief Post propagator for \f$ \mathrm{tan}(x_0)=x_1\f$
1256    */
1257   GECODE_FLOAT_EXPORT void
1258   tan(Home home, FloatVar x0, FloatVar x1);
1259   //@}
1260 #endif
1261 
1262   /**
1263    * \defgroup TaskModelFloatLI Linear constraints over float variables
1264    * \ingroup TaskModelFloat
1265    */
1266   /** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}x_i\sim_{frt} c\f$
1267    *
1268    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1269    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1270    * \li Throws an exception of type Float::ValueMixedSign, if a
1271    *     coefficient has mixed signs (that is, the lower bound is strictly
1272    *     negative and the upper bound is strictly positive).
1273    *
1274    * \ingroup TaskModelFloatLI
1275    */
1276   GECODE_FLOAT_EXPORT void
1277   linear(Home home, const FloatVarArgs& x,
1278          FloatRelType frt, FloatVal c);
1279   /** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}x_i\sim_{frt} y\f$
1280    * \ingroup TaskModelFloatLI
1281    *
1282    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1283    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1284    * \li Throws an exception of type Float::ValueMixedSign, if a
1285    *     coefficient has mixed signs (that is, the lower bound is strictly
1286    *     negative and the upper bound is strictly positive).
1287    *
1288    */
1289   GECODE_FLOAT_EXPORT void
1290   linear(Home home, const FloatVarArgs& x,
1291          FloatRelType frt, FloatVar y);
1292   /** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i\sim_{frt} c\right)\equiv r\f$
1293    *
1294    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1295    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1296    * \li Throws an exception of type Float::ValueMixedSign, if a
1297    *     coefficient has mixed signs (that is, the lower bound is strictly
1298    *     negative and the upper bound is strictly positive).
1299    *
1300    * \ingroup TaskModelFloatLI
1301    */
1302   GECODE_FLOAT_EXPORT void
1303   linear(Home home, const FloatVarArgs& x,
1304          FloatRelType frt, FloatVal c, Reify r);
1305   /** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}x_i\sim_{frt} y\right)\equiv r\f$
1306    *
1307    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1308    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1309    * \li Throws an exception of type Float::ValueMixedSign, if a
1310    *     coefficient has mixed signs (that is, the lower bound is strictly
1311    *     negative and the upper bound is strictly positive).
1312    *
1313    * \ingroup TaskModelFloatLI
1314    */
1315   GECODE_FLOAT_EXPORT void
1316   linear(Home home, const FloatVarArgs& x,
1317          FloatRelType frt, FloatVar y, Reify r);
1318   /** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} c\f$
1319    *
1320    * \li Throws an exception of type Float::ArgumentSizeMismatch, if
1321    *     \a a and \a x are of different size.
1322    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1323    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1324    * \li Throws an exception of type Float::ValueMixedSign, if a
1325    *     coefficient has mixed signs (that is, the lower bound is strictly
1326    *     negative and the upper bound is strictly positive).
1327    *
1328    * \ingroup TaskModelFloatLI
1329    */
1330   GECODE_FLOAT_EXPORT void
1331   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
1332          FloatRelType frt, FloatVal c);
1333   /** \brief Post propagator for \f$\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} y\f$
1334    *
1335    *
1336    * \li Throws an exception of type Float::ArgumentSizeMismatch, if
1337    *     \a a and \a x are of different size.
1338    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1339    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1340    * \li Throws an exception of type Float::ValueMixedSign, if a
1341    *     coefficient has mixed signs (that is, the lower bound is strictly
1342    *     negative and the upper bound is strictly positive).
1343    *
1344    * \ingroup TaskModelFloatLI
1345    */
1346   GECODE_FLOAT_EXPORT void
1347   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
1348          FloatRelType frt, FloatVar y);
1349   /** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} c\right)\equiv r\f$
1350    *
1351    *
1352    * \li Throws an exception of type Float::ArgumentSizeMismatch, if
1353    *     \a a and \a x are of different size.
1354    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1355    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1356    * \li Throws an exception of type Float::ValueMixedSign, if a
1357    *     coefficient has mixed signs (that is, the lower bound is strictly
1358    *     negative and the upper bound is strictly positive).
1359    *
1360    * \ingroup TaskModelFloatLI
1361    */
1362   GECODE_FLOAT_EXPORT void
1363   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
1364          FloatRelType frt, FloatVal c, Reify r);
1365   /** \brief Post propagator for \f$\left(\sum_{i=0}^{|x|-1}a_i\cdot x_i\sim_{frt} y\right)\equiv r\f$
1366    *
1367    *
1368    * \li Throws an exception of type Float::ArgumentSizeMismatch, if
1369    *     \a a and \a x are of different size.
1370    * \li Throws an exception of type Float::OutOfLimits, if the variables,
1371    *     coefficients, or \a c exceed the limits as defined in Float::Limits.
1372    * \li Throws an exception of type Float::ValueMixedSign, if a
1373    *     coefficient has mixed signs (that is, the lower bound is strictly
1374    *     negative and the upper bound is strictly positive).
1375    *
1376    * \ingroup TaskModelFloatLI
1377    */
1378   GECODE_FLOAT_EXPORT void
1379   linear(Home home, const FloatValArgs& a, const FloatVarArgs& x,
1380          FloatRelType frt, FloatVar y, Reify r);
1381 
1382 
1383   /**
1384    * \defgroup TaskModelFloatChannel Channel constraints
1385    * \ingroup TaskModelFloat
1386    */
1387   //@{
1388   /// Post propagator for channeling a float and an integer variable \f$ x_0 = x_1\f$
1389   GECODE_FLOAT_EXPORT void
1390   channel(Home home, FloatVar x0, IntVar x1);
1391   /// Post propagator for channeling a float and an integer variable \f$ x_0 = x_1\f$
1392   void
1393   channel(Home home, IntVar x0, FloatVar x1);
1394   /// Post propagator for channeling a float and a Boolean variable \f$ x_0 = x_1\f$
1395   GECODE_FLOAT_EXPORT void
1396   channel(Home home, FloatVar x0, BoolVar x1);
1397   /// Post propagator for channeling a float and a Boolean variable \f$ x_0 = x_1\f$
1398   void
1399   channel(Home home, BoolVar x0, FloatVar x1);
1400   //@}
1401 
1402 }
1403 
1404 #include <gecode/float/channel.hpp>
1405 
1406 namespace Gecode {
1407 
1408   /**
1409    * \defgroup TaskModelFloatExec Synchronized execution
1410    * \ingroup TaskModelFloat
1411    *
1412    * Synchronized execution executes a function or a static member function
1413    * when a certain event happends.
1414    */
1415   //@{
1416   /// Execute \a c when \a x becomes assigned
1417   GECODE_FLOAT_EXPORT void
1418   wait(Home home, FloatVar x, std::function<void(Space& home)> c);
1419   /// Execute \a c when all variables in \a x become assigned
1420   GECODE_FLOAT_EXPORT void
1421   wait(Home home, const FloatVarArgs& x, std::function<void(Space& home)> c);
1422   //@}
1423 
1424 }
1425 
1426 namespace Gecode {
1427 
1428   /**
1429    * \defgroup TaskModelFloatBranch Branching on float variables
1430    * \ingroup TaskModelFloat
1431    */
1432 
1433   /**
1434    * \brief Branch filter function type for float variables
1435    *
1436    * The variable \a x is considered for selection and \a i refers to the
1437    * variable's position in the original array passed to the brancher.
1438    *
1439    * \ingroup TaskModelFloatBranch
1440    */
1441   typedef std::function<bool(const Space& home, FloatVar x, int i)>
1442     FloatBranchFilter;
1443 
1444   /**
1445    * \brief Branch merit function type for float variables
1446    *
1447    * The function must return a merit value for the variable
1448    * \a x.
1449    * The value \a i refers to the variable's position in the original array
1450    * passed to the brancher.
1451    *
1452    * \ingroup TaskModelFloatBranch
1453    */
1454   typedef std::function<double(const Space& home, FloatVar x, int i)>
1455     FloatBranchMerit;
1456 
1457   /**
1458    * \brief Value description class for branching
1459    *
1460    * \ingroup TaskModelFloatBranch
1461    */
1462   class FloatNumBranch {
1463   public:
1464     /// The middle value for branching
1465     FloatNum n;
1466     /// Whether to try the lower or upper half first
1467     bool l;
1468   };
1469 
1470   /**
1471    * \brief Branch value function type for float variables
1472    *
1473    * Returns a value for the variable \a x that is to be used in the
1474    * corresponding branch commit function. The integer \a i refers
1475    * to the variable's position in the original array passed to the
1476    * brancher.
1477    *
1478    * \ingroup TaskModelFloatBranch
1479    */
1480   typedef std::function<FloatNumBranch(const Space& home, FloatVar x, int i)>
1481     FloatBranchVal;
1482 
1483   /**
1484    * \brief Branch commit function type for float variables
1485    *
1486    * The function must post a constraint on the variable \a x which
1487    * corresponds to the alternative \a a.  The integer \a i refers
1488    * to the variable's position in the original array passed to the
1489    * brancher. The value \a nl is the value description
1490    * computed by the corresponding branch value function.
1491    *
1492    * \ingroup TaskModelFloatBranch
1493    */
1494   typedef std::function<void(Space& home, unsigned int a,
1495                              FloatVar x, int i, FloatNumBranch nl)>
1496     FloatBranchCommit;
1497 
1498 }
1499 
1500 #include <gecode/float/branch/traits.hpp>
1501 
1502 namespace Gecode {
1503 
1504   /**
1505    * \brief Recording AFC information for float variables
1506    *
1507    * \ingroup TaskModelFloatBranch
1508    */
1509   class FloatAFC : public AFC {
1510   public:
1511     /**
1512      * \brief Construct as not yet initialized
1513      *
1514      * The only member functions that can be used on a constructed but not
1515      * yet initialized AFC storage is init or the assignment operator.
1516      *
1517      */
1518     FloatAFC(void);
1519     /// Copy constructor
1520     FloatAFC(const FloatAFC& a);
1521     /// Assignment operator
1522     FloatAFC& operator =(const FloatAFC& a);
1523     /**
1524      * \brief Initialize for float variables \a x and decay factor \a d
1525      *
1526      * If several AFC objects are created for a space or its clones,
1527      * the AFC values are shared between spaces. If the values should
1528      * not be shared, \a share should be false.
1529      */
1530     FloatAFC(Home home, const FloatVarArgs& x, double d=1.0, bool share=true);
1531     /**
1532      * \brief Initialize for float variables \a x with decay factor \a d
1533      *
1534      * This member function can only be used once and only if the
1535      * AFC storage has been constructed with the default constructor.
1536      *
1537      * If several AFC objects are created for a space or its clones,
1538      * the AFC values are shared between spaces. If the values should
1539      * not be shared, \a share should be false.
1540      */
1541     void init(Home home, const FloatVarArgs& x, double d=1.0, bool share=true);
1542   };
1543 
1544 }
1545 
1546 #include <gecode/float/branch/afc.hpp>
1547 
1548 namespace Gecode {
1549 
1550   /**
1551    * \brief Recording actions for float variables
1552    *
1553    * \ingroup TaskModelFloatBranch
1554    */
1555   class FloatAction : public Action {
1556   public:
1557     /**
1558      * \brief Construct as not yet initialized
1559      *
1560      * The only member functions that can be used on a constructed but not
1561      * yet initialized action storage is init or the assignment operator.
1562      *
1563      */
1564     FloatAction(void);
1565     /// Copy constructor
1566     FloatAction(const FloatAction& a);
1567     /// Assignment operator
1568     FloatAction& operator =(const FloatAction& a);
1569     /**
1570      * \brief Initialize for float variables \a x with decay factor \a d
1571      *
1572      * Counts propagation if \a p is true and failure if \a f is true.
1573      *
1574      * If the branch merit function \a bm is different from nullptr, the
1575      * action for each variable is initialized with the merit returned
1576      * by \a bm.
1577      *
1578      */
1579     GECODE_FLOAT_EXPORT
1580     FloatAction(Home home, const FloatVarArgs& x, double d=1.0,
1581                 bool p=true, bool f=true,
1582                 FloatBranchMerit bm=nullptr);
1583     /**
1584      * \brief Initialize for float variables \a x with decay factor \a d
1585      *
1586      * Counts propagation if \a p is true and failure if \a f is true.
1587      *
1588      * If the branch merit function \a bm is different from nullptr, the
1589      * action for each variable is initialized with the merit returned
1590      * by \a bm.
1591      *
1592      * This member function can only be used once and only if the
1593      * action storage has been constructed with the default constructor.
1594      *
1595      */
1596     GECODE_FLOAT_EXPORT void
1597     init(Home home, const FloatVarArgs& x, double d=1.0,
1598          bool p=true, bool f=true,
1599          FloatBranchMerit bm=nullptr);
1600   };
1601 
1602 }
1603 
1604 #include <gecode/float/branch/action.hpp>
1605 
1606 namespace Gecode {
1607 
1608   /**
1609    * \brief Recording CHB for float variables
1610    *
1611    * \ingroup TaskModelFloatBranch
1612    */
1613   class FloatCHB : public CHB {
1614   public:
1615     /**
1616      * \brief Construct as not yet initialized
1617      *
1618      * The only member functions that can be used on a constructed but not
1619      * yet initialized CHB storage is init or the assignment operator.
1620      *
1621      */
1622     FloatCHB(void);
1623     /// Copy constructor
1624     FloatCHB(const FloatCHB& chb);
1625     /// Assignment operator
1626     FloatCHB& operator =(const FloatCHB& chb);
1627    /**
1628      * \brief Initialize for float variables \a x
1629      *
1630      * If the branch merit function \a bm is different from nullptr, the
1631      * action for each variable is initialized with the merit returned
1632      * by \a bm.
1633      *
1634      */
1635     GECODE_FLOAT_EXPORT
1636     FloatCHB(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
1637    /**
1638      * \brief Initialize for float variables \a x
1639      *
1640      * If the branch merit function \a bm is different from nullptr, the
1641      * action for each variable is initialized with the merit returned
1642      * by \a bm.
1643      *
1644      * This member function can only be used once and only if the
1645      * action storage has been constructed with the default constructor.
1646      *
1647      */
1648     GECODE_FLOAT_EXPORT void
1649     init(Home home, const FloatVarArgs& x, FloatBranchMerit bm=nullptr);
1650   };
1651 
1652 }
1653 
1654 #include <gecode/float/branch/chb.hpp>
1655 
1656 namespace Gecode {
1657 
1658   /// Function type for explaining branching alternatives for float variables
1659   typedef std::function<void(const Space &home, const Brancher& b,
1660                              unsigned int a,
1661                              FloatVar x, int i, const FloatNumBranch& n,
1662                              std::ostream& o)>
1663     FloatVarValPrint;
1664 
1665 }
1666 
1667 namespace Gecode {
1668 
1669   /**
1670    * \brief Which variable to select for branching
1671    *
1672    * \ingroup TaskModelFloatBranch
1673    */
1674   class FloatVarBranch : public VarBranch<FloatVar> {
1675   public:
1676     /// Which variable selection
1677     enum Select {
1678       SEL_NONE = 0,        ///< First unassigned
1679       SEL_RND,             ///< Random (uniform, for tie breaking)
1680       SEL_MERIT_MIN,       ///< With least merit
1681       SEL_MERIT_MAX,       ///< With highest merit
1682       SEL_DEGREE_MIN,      ///< With smallest degree
1683       SEL_DEGREE_MAX,      ///< With largest degree
1684       SEL_AFC_MIN,         ///< With smallest accumulated failure count
1685       SEL_AFC_MAX,         ///< With largest accumulated failure count
1686       SEL_ACTION_MIN,      ///< With lowest action
1687       SEL_ACTION_MAX,      ///< With highest action
1688       SEL_CHB_MIN,         ///< With lowest CHB Q-score
1689       SEL_CHB_MAX,         ///< With highest CHB Q-score
1690       SEL_MIN_MIN,         ///< With smallest min
1691       SEL_MIN_MAX,         ///< With largest min
1692       SEL_MAX_MIN,         ///< With smallest max
1693       SEL_MAX_MAX,         ///< With largest max
1694       SEL_SIZE_MIN,        ///< With smallest domain size
1695       SEL_SIZE_MAX,        ///< With largest domain size
1696       SEL_DEGREE_SIZE_MIN, ///< With smallest degree divided by domain size
1697       SEL_DEGREE_SIZE_MAX, ///< With largest degree divided by domain size
1698       SEL_AFC_SIZE_MIN,    ///< With smallest accumulated failure count divided by domain size
1699       SEL_AFC_SIZE_MAX,    ///< With largest accumulated failure count divided by domain size
1700       SEL_ACTION_SIZE_MIN, ///< With smallest action divided by domain size
1701       SEL_ACTION_SIZE_MAX, ///< With largest action divided by domain size
1702       SEL_CHB_SIZE_MIN,    ///< With smallest CHB Q-score divided by domain size
1703       SEL_CHB_SIZE_MAX     ///< With largest CHB Q-score divided by domain size
1704     };
1705   protected:
1706     /// Which variable to select
1707     Select s;
1708   public:
1709     /// Initialize with strategy SEL_NONE
1710     FloatVarBranch(void);
1711     /// Initialize with random number generator \a r
1712     FloatVarBranch(Rnd r);
1713     /// Initialize with selection strategy \a s and tie-break limit function \a t
1714     FloatVarBranch(Select s, BranchTbl t);
1715     /// Initialize with selection strategy \a s, decay factor \a d, and tie-break limit function \a t
1716     FloatVarBranch(Select s, double, BranchTbl t);
1717     /// Initialize with selection strategy \a s, AFC \a a, and tie-break limit function \a t
1718     FloatVarBranch(Select s, FloatAFC a, BranchTbl t);
1719     /// Initialize with selection strategy \a s, action \a a, and tie-break limit function \a t
1720     FloatVarBranch(Select s, FloatAction a, BranchTbl t);
1721     /// Initialize with selection strategy \a s, CHB \a c, and tie-break limit function \a t
1722     FloatVarBranch(Select s, FloatCHB c, BranchTbl t);
1723     /// Initialize with selection strategy \a s, branch merit function \a mf, and tie-break limit function \a t
1724     FloatVarBranch(Select s, FloatBranchMerit mf, BranchTbl t);
1725     /// Return selection strategy
1726     Select select(void) const;
1727     /// Expand AFC, action, and CHB
1728     void expand(Home home, const FloatVarArgs& x);
1729   };
1730 
1731 
1732   /**
1733    * \defgroup TaskModelFloatBranchVar Variable selection for float variables
1734    * \ingroup TaskModelFloatBranch
1735    */
1736   //@{
1737   /// Select first unassigned variable
1738   FloatVarBranch FLOAT_VAR_NONE(void);
1739   /// Select random variable (uniform distribution, for tie breaking)
1740   FloatVarBranch FLOAT_VAR_RND(Rnd r);
1741   /// Select variable with least merit according to branch merit function \a bm
1742   FloatVarBranch FLOAT_VAR_MERIT_MIN(FloatBranchMerit bm, BranchTbl tbl=nullptr);
1743   /// Select variable with highest merit according to branch merit function \a bm
1744   FloatVarBranch FLOAT_VAR_MERIT_MAX(FloatBranchMerit bm, BranchTbl tbl=nullptr);
1745   /// Select variable with smallest degree
1746   FloatVarBranch FLOAT_VAR_DEGREE_MIN(BranchTbl tbl=nullptr);
1747   /// Select variable with largest degree
1748   FloatVarBranch FLOAT_VAR_DEGREE_MAX(BranchTbl tbl=nullptr);
1749   /// Select variable with smallest accumulated failure count with decay factor \a d
1750   FloatVarBranch FLOAT_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
1751   /// Select variable with smallest accumulated failure count
1752   FloatVarBranch FLOAT_VAR_AFC_MIN(FloatAFC a, BranchTbl tbl=nullptr);
1753   /// Select variable with largest accumulated failure count with decay factor \a d
1754   FloatVarBranch FLOAT_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
1755   /// Select variable with largest accumulated failure count
1756   FloatVarBranch FLOAT_VAR_AFC_MAX(FloatAFC a, BranchTbl tbl=nullptr);
1757   /// Select variable with lowest action with decay factor \a d
1758   FloatVarBranch FLOAT_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
1759   /// Select variable with lowest action
1760   FloatVarBranch FLOAT_VAR_ACTION_MIN(FloatAction a, BranchTbl tbl=nullptr);
1761   /// Select variable with highest action with decay factor \a d
1762   FloatVarBranch FLOAT_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
1763   /// Select variable with highest action
1764   FloatVarBranch FLOAT_VAR_ACTION_MAX(FloatAction a, BranchTbl tbl=nullptr);
1765   /// Select variable with lowest CHB Q-score
1766   FloatVarBranch FLOAT_VAR_CHB_MIN(BranchTbl tbl=nullptr);
1767   /// Select variable with lowest CHB Q-score
1768   FloatVarBranch FLOAT_VAR_CHB_MIN(FloatCHB a, BranchTbl tbl=nullptr);
1769   /// Select variable with highest CHB Q-score
1770   FloatVarBranch FLOAT_VAR_CHB_MAX(BranchTbl tbl=nullptr);
1771   /// Select variable with highest CHB Q-score
1772   FloatVarBranch FLOAT_VAR_CHB_MAX(FloatCHB a, BranchTbl tbl=nullptr);
1773   /// Select variable with smallest min
1774   FloatVarBranch FLOAT_VAR_MIN_MIN(BranchTbl tbl=nullptr);
1775   /// Select variable with largest min
1776   FloatVarBranch FLOAT_VAR_MIN_MAX(BranchTbl tbl=nullptr);
1777   /// Select variable with smallest max
1778   FloatVarBranch FLOAT_VAR_MAX_MIN(BranchTbl tbl=nullptr);
1779   /// Select variable with largest max
1780   FloatVarBranch FLOAT_VAR_MAX_MAX(BranchTbl tbl=nullptr);
1781   /// Select variable with smallest domain size
1782   FloatVarBranch FLOAT_VAR_SIZE_MIN(BranchTbl tbl=nullptr);
1783   /// Select variable with largest domain size
1784   FloatVarBranch FLOAT_VAR_SIZE_MAX(BranchTbl tbl=nullptr);
1785   /// Select variable with smallest degree divided by domain size
1786   FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr);
1787   /// Select variable with largest degree divided by domain size
1788   FloatVarBranch FLOAT_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr);
1789   /// Select variable with smalllest accumulated failure count  divided by domain size with decay factor \a d
1790   FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1791   /// Select variable with smallest accumulated failure count divided by domain size
1792   FloatVarBranch FLOAT_VAR_AFC_SIZE_MIN(FloatAFC a, BranchTbl tbl=nullptr);
1793   /// Select variable with largest accumulated failure count  divided by domain size with decay factor \a d
1794   FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1795   /// Select variable with largest accumulated failure count divided by domain size
1796   FloatVarBranch FLOAT_VAR_AFC_SIZE_MAX(FloatAFC a, BranchTbl tbl=nullptr);
1797   /// Select variable with smallest action divided by domain size with decay factor \a d
1798   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
1799   /// Select variable with smallest action divided by domain size
1800   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MIN(FloatAction a, BranchTbl tbl=nullptr);
1801   /// Select variable with largest action divided by domain size with decay factor \a d
1802   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
1803   /// Select variable with largest action divided by domain size
1804   FloatVarBranch FLOAT_VAR_ACTION_SIZE_MAX(FloatAction a, BranchTbl tbl=nullptr);
1805   /// Select variable with smallest CHB Q-score divided by domain size
1806   FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr);
1807   /// Select variable with smallest CHB Q-score divided by domain size
1808   FloatVarBranch FLOAT_VAR_CHB_SIZE_MIN(FloatCHB c, BranchTbl tbl=nullptr);
1809   /// Select variable with largest CHB Q-score divided by domain size
1810   FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr);
1811   /// Select variable with largest CHB Q-score divided by domain size
1812   FloatVarBranch FLOAT_VAR_CHB_SIZE_MAX(FloatCHB a, BranchTbl tbl=nullptr);
1813   //@}
1814 
1815 }
1816 
1817 #include <gecode/float/branch/var.hpp>
1818 
1819 namespace Gecode {
1820 
1821   /**
1822    * \brief Which values to select for branching first
1823    *
1824    * \ingroup TaskModelFloatBranch
1825    */
1826   class FloatValBranch : public ValBranch<FloatVar> {
1827   public:
1828     /// Which value selection
1829     enum Select {
1830       SEL_SPLIT_MIN, ///< Select values not greater than mean of smallest and largest value
1831       SEL_SPLIT_MAX, ///< Select values greater than mean of smallest and largest value
1832       SEL_SPLIT_RND,  ///< Select values randomly which are not greater or not smaller than mean of largest and smallest value
1833       SEL_VAL_COMMIT  ///< Select value according to user-defined functions
1834     };
1835   protected:
1836     /// Which value to select
1837     Select s;
1838   public:
1839     /// Initialize with selection strategy \a s
1840     FloatValBranch(Select s = SEL_SPLIT_MIN);
1841     /// Initialize with random number generator \a r
1842     FloatValBranch(Rnd r);
1843     /// Initialize with value function \a f and commit function \a c
1844     FloatValBranch(FloatBranchVal v, FloatBranchCommit c);
1845     /// Return selection strategy
1846     Select select(void) const;
1847   };
1848 
1849   /**
1850    * \defgroup TaskModelFloatBranchVal Value selection for float variables
1851    * \ingroup TaskModelFloatBranch
1852    */
1853   //@{
1854   /// Select values not greater than mean of smallest and largest value
1855   FloatValBranch FLOAT_VAL_SPLIT_MIN(void);
1856   /// Select values greater than mean of smallest and largest value
1857   FloatValBranch FLOAT_VAL_SPLIT_MAX(void);
1858   /// Select values randomly which are not greater or not smaller than mean of largest and smallest value
1859   FloatValBranch FLOAT_VAL_SPLIT_RND(Rnd r);
1860   /**
1861    * Select value as defined by the value function \a v and commit function \a c
1862    * The default commit function posts the constraint that the float variable
1863    * \a x must be less or equal than the value \a n for the first
1864    * alternative and that \a x must be greater or equal than \a n otherwise.
1865    */
1866   FloatValBranch FLOAT_VAL(FloatBranchVal v, FloatBranchCommit c=nullptr);
1867   //@}
1868 
1869 }
1870 
1871 #include <gecode/float/branch/val.hpp>
1872 
1873 namespace Gecode {
1874 
1875   /**
1876    * \brief Which values to select for assignment
1877    *
1878    * \ingroup TaskModelFloatBranch
1879    */
1880   class FloatAssign : public ValBranch<FloatVar> {
1881   public:
1882     /// Which value selection
1883     enum Select {
1884       SEL_MIN,       ///< Select median value of the lower part
1885       SEL_MAX,       ///< Select median value of the upper part
1886       SEL_RND,       ///< Select median value of a randomly chosen part
1887       SEL_VAL_COMMIT ///< Select value according to user-defined functions
1888     };
1889   protected:
1890     /// Which value to select
1891     Select s;
1892   public:
1893     /// Initialize with selection strategy \a s
1894     FloatAssign(Select s = SEL_MIN);
1895     /// Initialize with random number generator \a r
1896     FloatAssign(Rnd r);
1897     /// Initialize with value function \a f and commit function \a c
1898     FloatAssign(FloatBranchVal v, FloatBranchCommit c);
1899     /// Return selection strategy
1900     Select select(void) const;
1901   };
1902 
1903   /**
1904    * \defgroup TaskModelFloatBranchAssign Value selection for assigning float variables
1905    * \ingroup TaskModelFloatBranch
1906    */
1907   //@{
1908   /// Select median value of the lower part
1909   FloatAssign FLOAT_ASSIGN_MIN(void);
1910   /// Select median value of the upper part
1911   FloatAssign FLOAT_ASSIGN_MAX(void);
1912   /// Select median value of a randomly chosen part
1913   FloatAssign FLOAT_ASSIGN_RND(Rnd r);
1914   /**
1915    * Select value as defined by the value function \a v and commit function \a c
1916    * The default commit function posts the constraint that the float variable
1917    * \a x must be less or equal than the value \a n.
1918    */
1919   FloatAssign FLOAT_ASSIGN(FloatBranchVal v, FloatBranchCommit c=nullptr);
1920   //@}
1921 
1922 }
1923 
1924 #include <gecode/float/branch/assign.hpp>
1925 
1926 namespace Gecode {
1927 
1928   /**
1929    * \brief Branch over \a x with variable selection \a vars and value selection \a vals
1930    *
1931    * \ingroup TaskModelFloatBranch
1932    */
1933   GECODE_FLOAT_EXPORT void
1934   branch(Home home, const FloatVarArgs& x,
1935          FloatVarBranch vars, FloatValBranch vals,
1936          FloatBranchFilter bf=nullptr,
1937          FloatVarValPrint vvp=nullptr);
1938   /**
1939    * \brief Branch over \a x with tie-breaking variable selection \a vars and value selection \a vals
1940    *
1941    * \ingroup TaskModelFloatBranch
1942    */
1943   GECODE_FLOAT_EXPORT void
1944   branch(Home home, const FloatVarArgs& x,
1945          TieBreak<FloatVarBranch> vars, FloatValBranch vals,
1946          FloatBranchFilter bf=nullptr,
1947          FloatVarValPrint vvp=nullptr);
1948   /**
1949    * \brief Branch over \a x with value selection \a vals
1950    *
1951    * \ingroup TaskModelFloatBranch
1952    */
1953   GECODE_FLOAT_EXPORT void
1954   branch(Home home, FloatVar x, FloatValBranch vals,
1955          FloatVarValPrint vvp=nullptr);
1956 
1957   /**
1958    * \brief Assign all \a x with variable selection \a vars and value selection \a vals
1959    *
1960    * \ingroup TaskModelFloatBranch
1961    */
1962   GECODE_FLOAT_EXPORT void
1963   assign(Home home, const FloatVarArgs& x,
1964          FloatVarBranch vars, FloatAssign vals,
1965          FloatBranchFilter bf=nullptr,
1966          FloatVarValPrint vvp=nullptr);
1967   /**
1968    * \brief Assign all \a x with tie-breaking variable selection \a vars and value selection \a vals
1969    *
1970    * \ingroup TaskModelFloatBranch
1971    */
1972   GECODE_FLOAT_EXPORT void
1973   assign(Home home, const FloatVarArgs& x,
1974          TieBreak<FloatVarBranch> vars, FloatAssign vals,
1975          FloatBranchFilter bf=nullptr,
1976          FloatVarValPrint vvp=nullptr);
1977   /**
1978    * \brief Assign \a x with value selection \a vals
1979    *
1980    * \ingroup TaskModelFloatBranch
1981    */
1982   GECODE_FLOAT_EXPORT void
1983   assign(Home home, FloatVar x, FloatAssign vals,
1984          FloatVarValPrint vvp=nullptr);
1985 
1986 }
1987 
1988 namespace Gecode {
1989 
1990   /**
1991    * \brief Branch over \a x with value selection \a vals
1992    *
1993    * \ingroup TaskModelFloatBranch
1994    */
1995   void
1996   branch(Home home, const FloatVarArgs& x, FloatValBranch vals,
1997          FloatBranchFilter bf=nullptr,
1998          FloatVarValPrint vvp=nullptr);
1999   /**
2000    * \brief Assign all \a x with value selection \a vals
2001    *
2002    * \ingroup TaskModelFloatBranch
2003    */
2004   void
2005   assign(Home home, const FloatVarArgs& x, FloatAssign vals,
2006          FloatBranchFilter bf=nullptr,
2007          FloatVarValPrint vvp=nullptr);
2008 
2009 }
2010 
2011 #include <gecode/float/branch.hpp>
2012 
2013 namespace Gecode {
2014 
2015   /*
2016    * \brief Relaxed assignment of variables in \a x from values in \a sx
2017    *
2018    * The variables in \a x are assigned values from the assigned variables
2019    * in the solution \a sx with a relaxation probability \a p. That is,
2020    * if \f$p=0.1\f$ approximately 10% of the variables in \a x will be
2021    * assigned a value from \a sx.
2022    *
2023    * The random numbers are generated from the generator \a r. At least
2024    * one variable will not be assigned: in case the relaxation attempt
2025    * would suggest that all variables should be assigned, a single
2026    * variable will be selected randomly to remain unassigned.
2027    *
2028    * Throws an exception of type Float::ArgumentSizeMismatch, if \a x and
2029    * \a sx are of different size.
2030    *
2031    * Throws an exception of type Float::OutOfLimits, if \a p is not between
2032    * \a 0.0 and \a 1.0.
2033    *
2034    * \ingroup TaskModeFloat
2035    */
2036   GECODE_FLOAT_EXPORT void
2037   relax(Home home, const FloatVarArgs& x, const FloatVarArgs& sx,
2038         Rnd r, double p);
2039 
2040 }
2041 
2042 #include <gecode/float/trace/trace-view.hpp>
2043 
2044 namespace Gecode {
2045 
2046   /**
2047    * \defgroup TaskFloatTrace Tracing for float variables
2048    * \ingroup TaskTrace
2049    */
2050 
2051   /**
2052    * \brief Trace delta information for float variables
2053    * \ingroup TaskFloatTrace
2054    */
2055   class FloatTraceDelta {
2056   protected:
2057     /// New view
2058     Float::FloatView n;
2059     /// Delta information
2060     const Delta& d;
2061   public:
2062     /// \name Constructor
2063     //@{
2064     /// Initialize with old trace view \a o, new view \a n, and delta \a d
2065     FloatTraceDelta(Float::FloatTraceView o, Float::FloatView n,
2066                     const Delta& d);
2067     //@}
2068     /// \name Access
2069     //@{
2070     /// Return minimum
2071     FloatNum min(void) const;
2072     /// Return maximum
2073     FloatNum max(void) const;
2074     //@}
2075   };
2076 
2077 }
2078 
2079 #include <gecode/float/trace/delta.hpp>
2080 
2081 #include <gecode/float/trace/traits.hpp>
2082 
2083 namespace Gecode {
2084 
2085   /**
2086    * \brief Tracer for float variables
2087    * \ingroup TaskFloatTrace
2088    */
2089   typedef ViewTracer<Float::FloatView> FloatTracer;
2090   /**
2091    * \brief Trace recorder for float variables
2092    * \ingroup TaskFloatTrace
2093    */
2094   typedef ViewTraceRecorder<Float::FloatView> FloatTraceRecorder;
2095 
2096   /**
2097    * \brief Standard float variable tracer
2098    * \ingroup TaskFloatTrace
2099    */
2100   class GECODE_FLOAT_EXPORT StdFloatTracer : public FloatTracer {
2101   protected:
2102     /// Output stream to use
2103     std::ostream& os;
2104   public:
2105     /// Initialize with output stream \a os0
2106     StdFloatTracer(std::ostream& os0 = std::cerr);
2107     /// Print init information
2108     virtual void init(const Space& home, const FloatTraceRecorder& t);
2109     /// Print prune information
2110     virtual void prune(const Space& home, const FloatTraceRecorder& t,
2111                        const ViewTraceInfo& vti, int i, FloatTraceDelta& d);
2112     /// Print fixpoint information
2113     virtual void fix(const Space& home, const FloatTraceRecorder& t);
2114     /// Print failure information
2115     virtual void fail(const Space& home, const FloatTraceRecorder& t);
2116     /// Print that trace recorder is done
2117     virtual void done(const Space& home, const FloatTraceRecorder& t);
2118     /// Default tracer (printing to std::cerr)
2119     static StdFloatTracer def;
2120   };
2121 
2122 
2123   /**
2124    * \brief Create a tracer for float variables
2125    * \ingroup TaskFloatTrace
2126    */
2127   GECODE_FLOAT_EXPORT void
2128   trace(Home home, const FloatVarArgs& x,
2129         TraceFilter tf,
2130         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
2131         FloatTracer& t = StdFloatTracer::def);
2132   /**
2133    * \brief Create a tracer for float variables
2134    * \ingroup TaskFloatTrace
2135    */
2136   void
2137   trace(Home home, const FloatVarArgs& x,
2138         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
2139         FloatTracer& t = StdFloatTracer::def);
2140 
2141 }
2142 
2143 #include <gecode/float/trace.hpp>
2144 
2145 #endif
2146 
2147 // IFDEF: GECODE_HAS_FLOAT_VARS
2148 // STATISTICS: float-post
2149 
2150