aGrUM  0.16.0
linearApproximationPolicy.h
Go to the documentation of this file.
1 
30 #ifndef GUM_LINEAR_APPROXIMATION_POLICY_H
31 #define GUM_LINEAR_APPROXIMATION_POLICY_H
32 
33 #include <agrum/agrum.h>
35 #include <typeinfo>
36 
37 namespace gum {
38 
54  template < typename GUM_SCALAR >
56  : public virtual ApproximationPolicy< GUM_SCALAR > {
57  public:
58  // ===========================================================================
60  // ===========================================================================
62 
71  LinearApproximationPolicy(GUM_SCALAR low = (GUM_SCALAR)0.0,
72  GUM_SCALAR high = (GUM_SCALAR)1.0,
73  GUM_SCALAR eps = (GUM_SCALAR)0.1);
74 
80 
82 
83  // ===========================================================================
85  // ===========================================================================
87 
93  GUM_SCALAR fromExact(const GUM_SCALAR& value) const;
94 
100 
107 
114 
120 
126 
132 
142  GUM_SCALAR safeFromExact(const GUM_SCALAR& value);
143 
151  Idx encode(const GUM_SCALAR& value) const;
152 
159  GUM_SCALAR decode(Idx representation) const;
160 
165  virtual void setEpsilon(const GUM_SCALAR& e);
166 
173  virtual void setLimits(const GUM_SCALAR& newLowLimit,
174  const GUM_SCALAR& newHighLimit);
175 
181  virtual void setLowLimit(const GUM_SCALAR& newLowLimit);
182 
187  const GUM_SCALAR& lowLimit() const;
188 
194  virtual void setHighLimit(const GUM_SCALAR& newHighLimit);
195 
200  const GUM_SCALAR& highLimit() const;
202 
203  protected:
205  GUM_SCALAR _lowLimit;
206 
208  GUM_SCALAR _highLimit;
209 
211  GUM_SCALAR _epsilon;
212 
222  Idx __encode(const GUM_SCALAR& value) const;
223 
229  GUM_SCALAR __decode(const GUM_SCALAR& representation) const;
230 
234  void _computeNbInterval();
235 
238  };
239 } // namespace gum
240 
241 
242 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
243 extern template class gum::LinearApproximationPolicy< double >;
244 #endif
245 
246 
247 // Always inline template classes implementation.
249 
250 #endif /* GUM_LINEAR_APPROXIMATION_POLICY_H */
void combineSub(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using substraction with the given gum::ApproximationPolicy.
virtual void setEpsilon(const GUM_SCALAR &e)
Sets approximation factor.
Idx __encode(const GUM_SCALAR &value) const
Concretely computes the approximate representation.
GUM_SCALAR _lowLimit
Lowest value possible.
void combineDiv(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using division with the given gum::ApproximationPolicy.
GUM_SCALAR _epsilon
Approximation factor.
void combineMin(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using min with the given gum::ApproximationPolicy.
virtual void setLimits(const GUM_SCALAR &newLowLimit, const GUM_SCALAR &newHighLimit)
Set bounds in a whole.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
const GUM_SCALAR & highLimit() const
Gets Highest possible value.
GUM_SCALAR __decode(const GUM_SCALAR &representation) const
Concretely computes the approximate value from representation.
Idx encode(const GUM_SCALAR &value) const
Encode a given value into its approximation representation.
GUM_SCALAR _highLimit
Highest value possible.
Idx _nbInterval
The number of interval.
virtual void setHighLimit(const GUM_SCALAR &newHighLimit)
Sets Highest possible value.
const GUM_SCALAR & lowLimit() const
Gets lowest possible value.
LinearApproximationPolicy(GUM_SCALAR low=(GUM_SCALAR) 0.0, GUM_SCALAR high=(GUM_SCALAR) 1.0, GUM_SCALAR eps=(GUM_SCALAR) 0.1)
Default constructor.
void combineMult(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using multiplication with the given gum::ApproximationPolicy.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size Idx
Type for indexes.
Definition: types.h:53
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Class implementing linear approximation policy (meaning possible value are split out in interval)...
GUM_SCALAR decode(Idx representation) const
Convert approximation representation to value.
GUM_SCALAR safeFromExact(const GUM_SCALAR &value)
Convert value to his approximation.
void combineMax(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using max with the given gum::ApproximationPolicy.
Mother class for all approximation policy classes.
virtual void setLowLimit(const GUM_SCALAR &newLowLimit)
Sets lowest possible value.
void combineAdd(const ApproximationPolicy< GUM_SCALAR > *ap)
Combine using addition with the given gum::ApproximationPolicy.
GUM_SCALAR fromExact(const GUM_SCALAR &value) const
Convert value to his approximation.
void _computeNbInterval()
Get the number of interval.