multiple_shooting_variable_grid.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
25 #ifndef SRC_OPTIMAL_CONTROL_INCLUDE_CORBO_OPTIMAL_CONTROL_STRUCTURED_OCP_DISCRETIZATION_GRIDS_MULTIPLE_SHOOTING_VARIABLE_GRID_H_
26 #define SRC_OPTIMAL_CONTROL_INCLUDE_CORBO_OPTIMAL_CONTROL_STRUCTURED_OCP_DISCRETIZATION_GRIDS_MULTIPLE_SHOOTING_VARIABLE_GRID_H_
27 
29 
30 #include <memory>
31 
32 namespace corbo {
33 
35 {
36  public:
37  using Ptr = std::shared_ptr<MultipleShootingVariableGrid>;
38  using UPtr = std::unique_ptr<MultipleShootingVariableGrid>;
39 
41 
42  MultipleShootingVariableGrid() = default;
43  virtual ~MultipleShootingVariableGrid() = default;
44 
46  DiscretizationGridInterface::Ptr getInstance() const override { return std::make_shared<MultipleShootingVariableGrid>(); }
47 
50 
51  void setDtBounds(double dt_lb, double dt_ub);
52  void setNmin(int n_min) { _n_min = n_min; }
54  void setGridAdaptTimeBasedSingleStep(int n_max, double dt_hyst_ratio = 0.1);
55  void setGridAdaptTimeBasedAggressiveEstimate(int n_max, double dt_hyst_ratio = 0.1);
57 
58 #ifdef MESSAGE_SUPPORT
59  void fromMessage(const messages::MultipleShootingVariableGrid& message, std::stringstream* issues);
60  void toMessage(messages::MultipleShootingVariableGrid& message) const;
61 
62  void fromMessage(const messages::DiscretizationGrid& message, std::stringstream* issues) override
63  {
64  fromMessage(message.multiple_shooting_variable_grid(), issues);
65  }
66  void toMessage(messages::DiscretizationGrid& message) const override { toMessage(*message.mutable_multiple_shooting_variable_grid()); }
67 #endif
68 
69  protected:
70  bool isMovingHorizonWarmStartActive() const override { return false; }
71  bool isGridAdaptActive() const override { return true; }
72  bool isDtFixedIntended() const override { return false; }
73 
74  bool adaptGrid(bool new_run, NlpFunctions& nlp_fun) override;
78 
79  // auto resize stuff
81  int _n_max = 1000;
82  double _dt_hyst_ratio = 0.1;
83  int _n_min = 2;
84  bool _adapt_first_iter = false;
85 };
86 
88 
89 } // namespace corbo
90 
91 #endif // SRC_OPTIMAL_CONTROL_INCLUDE_CORBO_OPTIMAL_CONTROL_STRUCTURED_OCP_DISCRETIZATION_GRIDS_MULTIPLE_SHOOTING_VARIABLE_GRID_H_
Generic factory object.
Definition: factory.h:68
std::unique_ptr< DiscretizationGridInterface > UPtr
static Factory< DiscretizationGridInterface > & getFactory()
Get access to the associated factory.
#define FACTORY_REGISTER_DISCRETIZATION_GRID(type)
bool adaptGridTimeBasedAggressiveEstimate(NlpFunctions &nlp_fun)
void setGridAdaptTimeBasedAggressiveEstimate(int n_max, double dt_hyst_ratio=0.1)
virtual ~MultipleShootingVariableGrid()=default
static Factory & instance()
< Retrieve static instance of the factory
Definition: factory.h:72
std::shared_ptr< DiscretizationGridInterface > Ptr
bool adaptGrid(bool new_run, NlpFunctions &nlp_fun) override
void setGridAdaptTimeBasedSingleStep(int n_max, double dt_hyst_ratio=0.1)
DiscretizationGridInterface::Ptr getInstance() const override
Return a newly created shared instance of the implemented class.


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:07:05