codac  1.5.7
codac_TubePolynomialSynthesis.h
1 
11 #ifndef __CODAC_TUBEPOLYNOMIALSYNTHESIS_H__
12 #define __CODAC_TUBEPOLYNOMIALSYNTHESIS_H__
13 
14 #include <map>
15 #include <array>
16 #include <vector>
17 #include "codac_VIBesFigTube.h"
18 #include "codac_Interval.h"
19 #include "codac_Tube.h"
20 #include "codac_Trajectory.h"
21 
22 #define POLYNOMIAL_ORDER 2
23 
24 namespace codac
25 {
26  struct Polynomial
27  {
28  // Form: ax² + bx + c + offset = 0
29  std::array<double,POLYNOMIAL_ORDER+1> coeff;
30  double offset = 0.;
31 
32  Interval f(const Interval& t) const
33  {
34  Interval x = offset;
35  for(int i = 0 ; i < POLYNOMIAL_ORDER+1 ; i++)
36  x += coeff[i]*pow(t,i);
37  return x;
38  }
39  };
40 
41  struct PolynomialFactoredForm
42  {
43  // Form: c(x-a)² + b + offset = 0
44  double a, b, c;
45  double offset = 0.;
46 
47  Interval f(const Interval& t) const
48  {
49  return c*sqr(t-a) + b + offset;
50  }
51  };
52 
53  class VIBesFigTube;
54 
55  class TubePolynomialTreeSynthesis
56  {
57  public:
58 
59  TubePolynomialTreeSynthesis(const Tube& x, const Interval& tdomain, bool upper_bound, double eps, VIBesFigTube& m_fig);
60  ~TubePolynomialTreeSynthesis();
61  Interval operator()(const Interval& t) const;
62 
63 
64  protected:
65 
66  Polynomial polyfit(const std::vector<double> &t, const std::vector<double> &v) const;
67  void get_bounds(const Interval& tdomain, bool upper_bound, std::vector<double>& t, std::vector<double>& v) const;
68  Trajectory traj_from_polynom(const PolynomialFactoredForm& p) const;
69  PolynomialFactoredForm polynomial_factoredform(bool upper_bound) const;
70 
71 
72  protected:
73 
74  const Tube& m_tube_ref;
75  const Interval m_tdomain;
76  bool m_upper_bound;
77  PolynomialFactoredForm m_p;
78  Interval m_codomain;
79  TubePolynomialTreeSynthesis *m_left = nullptr, *m_right = nullptr;
80  VIBesFigTube& m_fig;
81  };
82 
83  class TubePolynomialSynthesis
84  {
85  public:
86 
87  TubePolynomialSynthesis(const Tube& x, double eps);
88  ~TubePolynomialSynthesis();
89  Interval operator()(const Interval& t) const;
90 
91 
92  protected:
93 
94  VIBesFigTube *m_fig;
95  std::pair<TubePolynomialTreeSynthesis,TubePolynomialTreeSynthesis> m_trees;
96  };
97 }
98 
99 #endif
FixPoint of a separator The fixpoint of a separator is computed by calling the "::"separate function ...
Definition: codac_capd_helpers.h:9
const Trajectory pow(const Trajectory &x, int p)
const Trajectory sqr(const Trajectory &x)