trajectory_optimizer.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Software License Agreement (BSD License) *
3  * Copyright (C) 2016 by Horatiu George Todoran <todorangrg@gmail.com> *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * 1. Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * 2. Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in *
13  * the documentation and/or other materials provided with the *
14  * distribution. *
15  * 3. Neither the name of the copyright holder nor the names of its *
16  * contributors may be used to endorse or promote products derived *
17  * from this software without specific prior written permission. *
18  * *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY *
29  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
30  * POSSIBILITY OF SUCH DAMAGE. *
31  ***************************************************************************/
32 
33 #ifndef TRAJECTORY_OPTIMIZER_H
34 #define TRAJECTORY_OPTIMIZER_H
35 
37 
38 #include <functional>
39 #include <memory>
40 
41 namespace tuw
42 {
43 class OptimizationState;
44 using OptimizationStateSPtr = std::shared_ptr<OptimizationState>;
45 using OptimizationStateConstSPtr = std::shared_ptr<OptimizationState const>;
46 using OptimizationStateUPtr = std::unique_ptr<OptimizationState>;
47 using OptimizationStateConstUPtr = std::unique_ptr<OptimizationState const>;
48 
49 class OptimizationState : public State
50 {
51 public:
52  OptimizationState() = default;
53 
54 public:
55  ~OptimizationState() = default;
56 
57 public:
58  OptimizationState(const OptimizationState&) = default;
59 
60 public:
62 
63 public:
65 
66 public:
68 
69 public:
70  virtual void toTrajState(TrajectorySimulator& _trajSim) = 0;
71 
72 public:
73  virtual void fromTrajState(const TrajectorySimulator& _trajSim) = 0;
74 
75 public:
76  double& value(const std::size_t& _i) override
77  {
78  return vars[_i];
79  }
80 
81 public:
82  const double& value(const std::size_t& _i) const override
83  {
84  return vars[_i];
85  }
86 
87 public:
88  size_t valueSize() const override
89  {
90  return vars.size();
91  }
92 
93 protected:
94  std::vector<double> vars;
95 
96 protected:
97  static constexpr const double valueZero = 0;
98 };
99 
100 class TrajectoryOptimizer;
101 using TrajectoryOptimizerSPtr = std::shared_ptr<TrajectoryOptimizer>;
102 using TrajectoryOptimizerConstSPtr = std::shared_ptr<TrajectoryOptimizer const>;
103 using TrajectoryOptimizerUPtr = std::unique_ptr<TrajectoryOptimizer>;
104 using TrajectoryOptimizerConstUPtr = std::unique_ptr<TrajectoryOptimizer const>;
105 
107 {
108 public:
109  enum class AccessType
110  {
111  STATE_0,
112  PARAM_CP,
113  PARAM_ARC,
114  ENUM_SIZE
115  };
116 
117  // special class member functions
118 public:
119  TrajectoryOptimizer(StateSimPtr& _stateSim, std::unique_ptr<TrajectorySimulator::CostsEvaluatorClass> _costsEvaluator,
120  OptimizationStateSPtr _optState);
121 
122 public:
123  ~TrajectoryOptimizer() = default;
124 
125 public:
126  TrajectoryOptimizer(const TrajectoryOptimizer&) = default;
127 
128 public:
130 
131 public:
133 
134 public:
136 
137 public:
138  virtual void optimize();
139 
140 public:
141  virtual void initState0ParamFuncsHValid(const size_t& _optFailCount);
142 
143 public:
144  void computeJacobian();
145 
146 public:
147  void computeJacobian1Entry(size_t _idx);
148 
149 public:
150  double& stepSize();
151 
152 public:
154 
155 public:
156  double fCache;
157 
158 public:
159  std::vector<double> hCache;
160 
161 public:
162  std::vector<double> gCache;
163 
164 private:
165  std::vector<TrajectorySimulator::LatticePointType> simulationLattice;
166 
167 private:
169 
170 private:
171  double stepSize_;
172 };
173 }
174 
175 #endif // TRAJECTORY_OPTIMIZER_H
std::shared_ptr< OptimizationState > OptimizationStateSPtr
OptimizationState & operator=(const OptimizationState &)=default
std::vector< TrajectorySimulator::LatticePointType > simulationLattice
static constexpr const double valueZero
std::unique_ptr< TrajectoryOptimizer const > TrajectoryOptimizerConstUPtr
TrajectorySimulator::LatticeVecSPtrVec partLattices
virtual void fromTrajState(const TrajectorySimulator &_trajSim)=0
virtual void toTrajState(TrajectorySimulator &_trajSim)=0
std::shared_ptr< TrajectoryOptimizer > TrajectoryOptimizerSPtr
std::vector< double > hCache
std::unique_ptr< TrajectoryOptimizer > TrajectoryOptimizerUPtr
std::vector< double > vars
std::shared_ptr< OptimizationState const > OptimizationStateConstSPtr
Generic tree-like recursive structure that allows sub-structure access as well as ordered (array-like...
Definition: state.h:135
double & value(const std::size_t &_i) override
Access state variable based on index _i.
std::shared_ptr< TrajectoryOptimizer const > TrajectoryOptimizerConstSPtr
std::unique_ptr< OptimizationState > OptimizationStateUPtr
std::vector< double > gCache
std::vector< std::shared_ptr< std::vector< LatticePoint > > > LatticeVecSPtrVec
std::shared_ptr< StateSim > StateSimPtr
size_t valueSize() const override
Size of the state variables.
std::unique_ptr< OptimizationState const > OptimizationStateConstUPtr
~OptimizationState()=default
const double & value(const std::size_t &_i) const override
Const access state variable based on index _i.
OptimizationStateSPtr optState_


tuw_control
Author(s): George Todoran
autogenerated on Mon Jun 10 2019 15:27:22