- 3.0.2 optimal control module.
CostFunctionAnalytical.hpp
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include <boost/property_tree/ptree.hpp>
9 #include <boost/property_tree/info_parser.hpp>
10 #include <boost/algorithm/string.hpp>
11 
13 #include "utility/utilities.hpp"
14 
15 #include "term/TermLoadMacros.hpp"
16 
17 
18 namespace ct {
19 namespace optcon {
20 
30 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
31 class CostFunctionAnalytical : public CostFunctionQuadratic<STATE_DIM, CONTROL_DIM, SCALAR>
32 {
33 public:
34  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
35 
36  typedef Eigen::Matrix<SCALAR, STATE_DIM, STATE_DIM> state_matrix_t;
37  typedef Eigen::Matrix<SCALAR, CONTROL_DIM, CONTROL_DIM> control_matrix_t;
38  typedef Eigen::Matrix<SCALAR, CONTROL_DIM, STATE_DIM> control_state_matrix_t;
39 
42 
47 
58  CostFunctionAnalytical(const std::string& filename, bool verbose = false);
59 
65 
70 
71  SCALAR evaluateIntermediate() override;
72  SCALAR evaluateTerminal() override;
73 
74  state_vector_t stateDerivativeIntermediate() override;
75  state_vector_t stateDerivativeTerminal() override;
76 
77  state_matrix_t stateSecondDerivativeIntermediate() override;
78  state_matrix_t stateSecondDerivativeTerminal() override;
79 
80  control_vector_t controlDerivativeIntermediate() override;
81  control_vector_t controlDerivativeTerminal() override;
82 
83  control_matrix_t controlSecondDerivativeIntermediate() override;
84  control_matrix_t controlSecondDerivativeTerminal() override;
85 
86  control_state_matrix_t stateControlDerivativeIntermediate() override;
87  control_state_matrix_t stateControlDerivativeTerminal() override;
88 
89  void loadFromConfigFile(const std::string& filename, bool verbose = false) override;
90 
91 private:
92 };
93 
94 } // namespace optcon
95 } // namespace ct
control_vector_t controlDerivativeIntermediate() override
Computes intermediate-cost first-order derivative with respect to control.
Definition: CostFunctionAnalytical-impl.hpp:136
state_vector_t stateDerivativeTerminal() override
Definition: CostFunctionAnalytical-impl.hpp:115
CostFunctionAnalytical()
Basic constructor.
Definition: CostFunctionAnalytical-impl.hpp:12
state_matrix_t stateSecondDerivativeTerminal() override
Computes final-cost second-order derivative with respect to state.
Definition: CostFunctionAnalytical-impl.hpp:129
core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: CostFunctionAnalytical.hpp:40
void loadFromConfigFile(const std::string &filename, bool verbose=false) override
Loads cost function from config file.
Definition: CostFunctionAnalytical-impl.hpp:43
A cost function which contains only terms that have analytical derivatives.
Definition: CostFunctionAnalytical.hpp:31
control_state_matrix_t stateControlDerivativeTerminal() override
Computes final-cost derivative with respect to state and control.
Definition: CostFunctionAnalytical-impl.hpp:171
core::ControlVector< CONTROL_DIM, SCALAR > control_vector_t
Definition: CostFunctionAnalytical.hpp:41
Describes a cost function with a quadratic approximation, i.e. one that can compute first and second ...
Definition: CostFunctionQuadratic.hpp:29
control_state_matrix_t stateControlDerivativeIntermediate() override
Computes intermediate-cost derivative with respect to state and control.
Definition: CostFunctionAnalytical-impl.hpp:164
SCALAR evaluateIntermediate() override
evaluate intermediate costs
Definition: CostFunctionAnalytical-impl.hpp:95
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Matrix< SCALAR, STATE_DIM, STATE_DIM > state_matrix_t
Definition: CostFunctionAnalytical.hpp:36
CppAD::AD< CppAD::cg::CG< double > > SCALAR
SCALAR evaluateTerminal() override
evaluate terminal costs
Definition: CostFunctionAnalytical-impl.hpp:101
Eigen::Matrix< SCALAR, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: CostFunctionAnalytical.hpp:38
Eigen::Matrix< SCALAR, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: CostFunctionAnalytical.hpp:37
state_matrix_t stateSecondDerivativeIntermediate() override
Computes intermediate-cost second-order derivative with respect to state.
Definition: CostFunctionAnalytical-impl.hpp:122
control_matrix_t controlSecondDerivativeIntermediate() override
Computes intermediate-cost second-order derivative with respect to input.
Definition: CostFunctionAnalytical-impl.hpp:150
CostFunctionAnalytical< STATE_DIM, CONTROL_DIM, SCALAR > * clone() const override
Definition: CostFunctionAnalytical-impl.hpp:30
control_matrix_t controlSecondDerivativeTerminal() override
Computes final-cost second-order derivative with respect to input.
Definition: CostFunctionAnalytical-impl.hpp:157
~CostFunctionAnalytical()
Definition: CostFunctionAnalytical-impl.hpp:37
const bool verbose
Definition: ConstraintComparison.h:18
control_vector_t controlDerivativeTerminal() override
Computes terminal-cost first-order derivative with respect to control.
Definition: CostFunctionAnalytical-impl.hpp:143
state_vector_t stateDerivativeIntermediate() override
Computes intermediate-cost first-order derivative with respect to state.
Definition: CostFunctionAnalytical-impl.hpp:108