robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
sto_cost_function.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_STO_COST_FUNCTION_HPP_
2#define ROBOTOC_STO_COST_FUNCTION_HPP_
3
4#include <vector>
5#include <memory>
6#include <unordered_map>
7
8#include "Eigen/Core"
9
14
15
16namespace robotoc {
17
25public:
27 = std::shared_ptr<STOCostFunctionComponentBase>;
28
33
37 ~STOCostFunction() = default;
38
43
48
52 STOCostFunction(STOCostFunction&&) noexcept = default;
53
57 STOCostFunction& operator=(STOCostFunction&&) noexcept = default;
58
65 bool exist(const std::string& name) const;
66
73 void add(const std::string& name, const STOCostFunctionComponentBasePtr& cost);
74
80 void erase(const std::string& name);
81
88 STOCostFunctionComponentBasePtr get(const std::string& name) const;
89
93 void clear();
94
100 double evalCost(const TimeDiscretization& time_discretization) const;
101
108 double linearizeCost(const TimeDiscretization& time_discretization,
109 Eigen::VectorXd& lt) const;
110
119 double quadratizeCost(const TimeDiscretization& time_discretization,
120 Eigen::VectorXd& lt, Eigen::MatrixXd& Qtt) const;
121
122private:
123 std::vector<STOCostFunctionComponentBasePtr> costs_;
124 std::unordered_map<std::string, size_t> cost_names_;
125
126};
127
128} // namespace robotoc
129
130#endif // ROBOTOC_STO_COST_FUNCTION_HPP_
Stack of the cost function of the switching time optimization (STO) problem. Composed by cost functio...
Definition: sto_cost_function.hpp:24
STOCostFunction(const STOCostFunction &)=default
Default copy constructor.
void clear()
Clear cost function by removing all components.
double evalCost(const TimeDiscretization &time_discretization) const
Computes the cost on the switching times.
STOCostFunction()
Default constructor.
double linearizeCost(const TimeDiscretization &time_discretization, Eigen::VectorXd &lt) const
Computes the cost and its derivative on the switching times.
double quadratizeCost(const TimeDiscretization &time_discretization, Eigen::VectorXd &lt, Eigen::MatrixXd &Qtt) const
Computes the cost and its derivative on the switching times.
STOCostFunctionComponentBasePtr get(const std::string &name) const
Gets a STO cost function component. If a component of the specified name does not exist,...
std::shared_ptr< STOCostFunctionComponentBase > STOCostFunctionComponentBasePtr
Definition: sto_cost_function.hpp:27
void add(const std::string &name, const STOCostFunctionComponentBasePtr &cost)
Adds a STO cost function component. If a component of the same name exists, throws an exeption.
STOCostFunction(STOCostFunction &&) noexcept=default
Default move constructor.
void erase(const std::string &name)
Erases a STO cost function component. If a component of the specified name does not exist,...
STOCostFunction & operator=(const STOCostFunction &)=default
Default copy operator.
~STOCostFunction()=default
Default destructor.
bool exist(const std::string &name) const
Checks if thsi has a STO cost function component of the specified name.
Time discretization of the optimal control problem.
Definition: time_discretization.hpp:20
Definition: constraint_component_base.hpp:17