hpp-manipulation  4.12.0
Classes for manipulation planning.
statistics.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-manipulation.
5 // hpp-manipulation is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-manipulation is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-manipulation. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #ifndef HPP_MANIPULATION_GRAPH_STATISTICS_HH
19 # define HPP_MANIPULATION_GRAPH_STATISTICS_HH
20 
21 # include <hpp/util/debug.hh>
22 
23 # include <hpp/statistics/bin.hh>
24 
26 # include "hpp/manipulation/fwd.hh"
30 
31 namespace hpp {
32  namespace manipulation {
33  namespace graph {
36  class HPP_MANIPULATION_DLLAPI LeafBin : public ::hpp::statistics::Bin
37  {
38  public :
39  typedef ::hpp::statistics::Bin Parent;
40  typedef std::list <RoadmapNodePtr_t> RoadmapNodes_t;
41 
42  LeafBin(const vector_t& v, value_type* threshold_);
43 
44  void push_back(const RoadmapNodePtr_t& n);
45 
46  bool operator<(const LeafBin& rhs) const;
47 
48  bool operator==(const LeafBin& rhs) const;
49 
50  const vector_t& value () const;
51 
52  std::ostream& print (std::ostream& os) const;
53 
55 
56  const RoadmapNodes_t& nodes () const;
57 
58  private:
59  vector_t value_;
60 
61  RoadmapNodes_t nodes_;
62 
63  value_type* thr_;
64 
65  std::ostream& printValue (std::ostream& os) const;
66  };
67 
70  class HPP_MANIPULATION_DLLLOCAL NodeBin : public ::hpp::statistics::Bin
71  {
72  public :
73  typedef ::hpp::statistics::Bin Parent;
74  NodeBin(const StatePtr_t& n);
75 
76  void push_back(const RoadmapNodePtr_t& n);
77 
78  bool operator<(const NodeBin& rhs) const;
79 
80  bool operator==(const NodeBin& rhs) const;
81 
82  const StatePtr_t& state () const;
83 
84  std::ostream& print (std::ostream& os) const;
85 
86  private:
87  StatePtr_t state_;
88 
89  typedef std::list <RoadmapNodePtr_t> RoadmapNodes_t;
90  RoadmapNodes_t roadmapNodes_;
91 
92  std::ostream& printValue (std::ostream& os) const;
93  };
94 
96  {
97  public:
98  virtual ~Histogram () {};
99 
100  virtual void add (const RoadmapNodePtr_t& node) = 0;
101 
102  virtual HistogramPtr_t clone () const = 0;
103 
104  virtual void clear () = 0;
105  };
106 
115  {
116  public:
118  bool contains (ConfigurationIn_t q) const;
121 
126 
127  private:
128  // condition_ contains the constraints defining the submanifold
129  // containing all the leaf.
130  // parametrizer_ contains the constraints providing a parametrization
131  // of the foliation.
132  ConstraintSetPtr_t condition_, parametrizer_;
133  };
134 
135  class HPP_MANIPULATION_DLLAPI LeafHistogram : public ::hpp::statistics::Statistics < LeafBin >
136  , public Histogram
137  {
138  public:
139  typedef ::hpp::statistics::Statistics < LeafBin > Parent;
140 
142 
144  void add (const RoadmapNodePtr_t& n);
145 
146  std::ostream& print (std::ostream& os) const;
147 
148  virtual HistogramPtr_t clone () const;
149 
150  statistics::DiscreteDistribution < RoadmapNodePtr_t > getDistribOutOfConnectedComponent (
151  const core::ConnectedComponentPtr_t& cc) const;
152 
153  statistics::DiscreteDistribution < RoadmapNodePtr_t > getDistrib () const;
154 
155  void clear () { Parent::clear(); }
156 
157  const Foliation& foliation () const {
158  return f_;
159  }
160 
161  protected:
167 
168  private:
169  Foliation f_;
170 
172  value_type threshold_;
173  };
174 
175  class HPP_MANIPULATION_DLLLOCAL StateHistogram : public ::hpp::statistics::Statistics < NodeBin >
176  , public Histogram
177  {
178  public:
179  typedef ::hpp::statistics::Statistics < NodeBin > Parent;
184 
186  void add (const RoadmapNodePtr_t& n);
187 
188  std::ostream& print (std::ostream& os) const;
189 
191 
192  virtual HistogramPtr_t clone () const;
193 
194  void clear () { Parent::clear(); }
195 
196  private:
198  graph::GraphPtr_t graph_;
199  };
201  typedef shared_ptr <StateHistogram> NodeHistogramPtr_t;
202  } // namespace graph
203  } // namespace manipulation
204 } // namespace hpp
205 
206 #endif // HPP_MANIPULATION_GRAPH_STATISTICS_HH
Definition: roadmap-node.hh:33
Definition: statistics.hh:115
void parametrizer(const ConstraintSetPtr_t p)
vector_t parameter(ConfigurationIn_t q) const
Whether the configuration is the submanifold $\mathcal{M}$.
ConstraintSetPtr_t condition() const
void condition(const ConstraintSetPtr_t c)
bool contains(ConfigurationIn_t q) const
Whether the configuration is the submanifold $\mathcal{M}$.
ConstraintSetPtr_t parametrizer() const
Definition: statistics.hh:96
virtual void add(const RoadmapNodePtr_t &node)=0
virtual ~Histogram()
Definition: statistics.hh:98
virtual HistogramPtr_t clone() const =0
Definition: statistics.hh:37
LeafBin(const vector_t &v, value_type *threshold_)
std::ostream & print(std::ostream &os) const
std::list< RoadmapNodePtr_t > RoadmapNodes_t
Definition: statistics.hh:40
::hpp::statistics::Bin Parent
Definition: statistics.hh:39
bool operator==(const LeafBin &rhs) const
const vector_t & value() const
bool operator<(const LeafBin &rhs) const
void push_back(const RoadmapNodePtr_t &n)
unsigned int numberOfObsOutOfConnectedComponent(const core::ConnectedComponentPtr_t &cc) const
const RoadmapNodes_t & nodes() const
Definition: statistics.hh:137
void clear()
Definition: statistics.hh:155
::hpp::statistics::Statistics< LeafBin > Parent
Definition: statistics.hh:139
const Foliation & foliation() const
Definition: statistics.hh:157
static LeafHistogramPtr_t create(const Foliation f)
statistics::DiscreteDistribution< RoadmapNodePtr_t > getDistribOutOfConnectedComponent(const core::ConnectedComponentPtr_t &cc) const
void add(const RoadmapNodePtr_t &n)
Insert an occurence of a value in the histogram.
virtual HistogramPtr_t clone() const
statistics::DiscreteDistribution< RoadmapNodePtr_t > getDistrib() const
std::ostream & print(std::ostream &os) const
Definition: statistics.hh:71
NodeBin(const StatePtr_t &n)
bool operator==(const NodeBin &rhs) const
std::ostream & print(std::ostream &os) const
void push_back(const RoadmapNodePtr_t &n)
bool operator<(const NodeBin &rhs) const
const StatePtr_t & state() const
::hpp::statistics::Bin Parent
Definition: statistics.hh:73
Definition: statistics.hh:177
const graph::GraphPtr_t & constraintGraph() const
virtual HistogramPtr_t clone() const
void clear()
Definition: statistics.hh:194
StateHistogram(const graph::GraphPtr_t &graph)
std::ostream & print(std::ostream &os) const
void add(const RoadmapNodePtr_t &n)
Insert an occurence of a value in the histogram.
::hpp::statistics::Statistics< NodeBin > Parent
Definition: statistics.hh:179
#define HPP_MANIPULATION_DLLLOCAL
Definition: config.hh:49
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:64
shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:35
shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
StateHistogram NodeHistogram HPP_MANIPULATION_DEPRECATED
Definition: statistics.hh:200
shared_ptr< StateHistogram > NodeHistogramPtr_t
Definition: statistics.hh:201
shared_ptr< Histogram > HistogramPtr_t
Definition: fwd.hh:58
shared_ptr< LeafHistogram > LeafHistogramPtr_t
Definition: fwd.hh:61
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:115
shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:63
core::value_type value_type
Definition: fwd.hh:82
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:38
core::vector_t vector_t
Definition: fwd.hh:85
std::vector< RoadmapNodePtr_t > RoadmapNodes_t
Definition: fwd.hh:61
Definition: main.hh:1