Generated on Tue Apr 18 10:21:39 2017 for Gecode by doxygen 1.6.3

linear.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: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
00015  *     $Revision: 15137 $
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_LINEAR_HH__
00043 #define __GECODE_FLOAT_LINEAR_HH__
00044 
00045 #include <gecode/int.hh>
00046 #include <gecode/float.hh>
00047 
00053 namespace Gecode { namespace Float { namespace Linear {
00054 
00060   template<class P, class N, PropCond pc>
00061   class Lin : public Propagator {
00062   protected:
00064     ViewArray<P> x;
00066     ViewArray<N> y;
00068     FloatVal c;
00069 
00071     Lin(Space& home, bool share, Lin<P,N,pc>& p);
00073     Lin(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
00074   public:
00076     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00078     virtual void reschedule(Space& home);
00080     virtual size_t dispose(Space& home);
00081   };
00082 
00088   template<class View>
00089   void bounds_p(ModEventDelta med, ViewArray<View>& x,
00090                 FloatVal& c, FloatNum& sl, FloatNum& su);
00091 
00097   template<class View>
00098   void bounds_n(ModEventDelta med, ViewArray<View>& y,
00099                 FloatVal& c, FloatNum& sl, FloatNum& su);
00100 
00109   template<class P, class N>
00110   class Eq : public Lin<P,N,PC_FLOAT_BND> {
00111   protected:
00112     using Lin<P,N,PC_FLOAT_BND>::x;
00113     using Lin<P,N,PC_FLOAT_BND>::y;
00114     using Lin<P,N,PC_FLOAT_BND>::c;
00115 
00117     Eq(Space& home, bool share, Eq& p);
00118   public:
00120     Eq(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
00122     virtual Actor* copy(Space& home, bool share);
00124     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00126     static ExecStatus
00127     post(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
00128   };
00129 
00130 
00139   template<class P, class N>
00140   class Lq : public Lin<P,N,PC_FLOAT_BND> {
00141   protected:
00142     using Lin<P,N,PC_FLOAT_BND>::x;
00143     using Lin<P,N,PC_FLOAT_BND>::y;
00144     using Lin<P,N,PC_FLOAT_BND>::c;
00145 
00147     Lq(Space& home, bool share, Lq& p);
00148   public:
00150     Lq(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
00152     virtual Actor* copy(Space& home, bool share);
00154     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00156     static ExecStatus
00157     post(Home home, ViewArray<P>& x, ViewArray<N>& y, FloatVal c);
00158   };
00159 
00160 }}}
00161 
00162 #include <gecode/float/linear/nary.hpp>
00163 
00164 namespace Gecode { namespace Float { namespace Linear {
00165 
00170   class Term {
00171   public:
00173     FloatVal a;
00175     FloatView x;
00176   };
00177 
00192   GECODE_FLOAT_EXPORT void
00193   estimate(Term* t, int n, FloatVal c, FloatNum& l, FloatNum& u);
00194 
00211   GECODE_FLOAT_EXPORT void
00212   post(Home home, Term* t, int n, FloatRelType frt, FloatVal c);
00213 
00231   GECODE_FLOAT_EXPORT void
00232   post(Home home, Term* t, int n, FloatRelType frt, FloatVal c, Reify r);
00233 
00234 }}}
00235 
00236 #endif
00237 
00238 // STATISTICS: float-prop