11 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
16 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
22 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
29 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
36 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
42 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
47 std::cout <<
"Starting to load analytical cost function from file " << filename << std::endl;
52 boost::property_tree::ptree pt;
53 boost::property_tree::read_info(filename, pt);
55 std::string currentTerm;
58 std::cout <<
"=============================================" << std::endl;
59 currentTerm =
"term" + std::to_string(i);
60 std::string termKind = pt.get<std::string>(currentTerm +
".kind");
61 boost::algorithm::to_lower(termKind);
62 int currentTermType = pt.get<
int>(currentTerm +
".type");
66 termName = pt.get<std::string>(currentTerm +
".name");
68 std::cout <<
"Trying to add " + termName +
" as term" << std::endl;
69 }
catch (boost::property_tree::ptree_bad_path err)
74 std::cout <<
"Name field for " + currentTerm +
" does not exist" << std::endl;
78 std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR>> term;
84 throw std::runtime_error(
"Term type \"" + termKind +
"\" not supported");
88 addTerm(filename, currentTerm, currentTermType, term,
this, verbose);
90 currentTerm =
"term" + std::to_string(++i);
91 }
while (pt.find(currentTerm) != pt.not_found());
94 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
100 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
106 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
113 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
120 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
127 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
134 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
141 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
148 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
155 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
162 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
169 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
control_vector_t controlDerivativeIntermediate() override
Computes intermediate-cost first-order derivative with respect to control.
Definition: CostFunctionAnalytical-impl.hpp:136
std::vector< std::shared_ptr< TermBase< STATE_DIM, CONTROL_DIM, SCALAR > > > intermediateCostAnalytical_
Definition: CostFunctionQuadratic.hpp:238
control_state_matrix_t stateControlDerivativeIntermediateBase()
evaluate intermediate analytical control mixed state control derivatives
Definition: CostFunctionQuadratic-impl.hpp:473
control_matrix_t controlSecondDerivativeIntermediateBase()
evaluate intermediate analytical control second derivatives
Definition: CostFunctionQuadratic-impl.hpp:440
SCALAR evaluateIntermediateBase()
evaluate intermediate analytical cost terms
Definition: CostFunctionQuadratic-impl.hpp:310
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
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
state_vector_t stateDerivativeTerminalBase()
evaluate terminal analytical state derivatives
Definition: CostFunctionQuadratic-impl.hpp:361
Describes a cost function with a quadratic approximation, i.e. one that can compute first and second ...
Definition: CostFunctionQuadratic.hpp:29
state_matrix_t stateSecondDerivativeIntermediateBase()
evaluate intermediate analytical state second derivatives
Definition: CostFunctionQuadratic-impl.hpp:374
control_state_matrix_t stateControlDerivativeIntermediate() override
Computes intermediate-cost derivative with respect to state and control.
Definition: CostFunctionAnalytical-impl.hpp:164
control_vector_t controlDerivativeIntermediateBase()
evaluate intermediate analytical control derivatives
Definition: CostFunctionQuadratic-impl.hpp:407
SCALAR evaluateIntermediate() override
evaluate intermediate costs
Definition: CostFunctionAnalytical-impl.hpp:95
CppAD::AD< CppAD::cg::CG< double > > SCALAR
control_vector_t controlDerivativeTerminalBase()
evaluate terminal analytical control derivatives
Definition: CostFunctionQuadratic-impl.hpp:426
state_matrix_t stateSecondDerivativeTerminalBase()
evaluate terminal analytical state second derivatives
Definition: CostFunctionQuadratic-impl.hpp:393
state_vector_t stateDerivativeIntermediateBase()
evaluate intermediate analytical state derivatives
Definition: CostFunctionQuadratic-impl.hpp:341
void addTerm(const std::string &filename, std::string ¤tTerm, int currentTermType, TERM_PTR term, costFuncType *costFunc, bool verbose=false)
Definition: utilities.hpp:81
SCALAR evaluateTerminalBase()
evaluate terminal analytical cost terms
Definition: CostFunctionQuadratic-impl.hpp:328
SCALAR evaluateTerminal() override
evaluate terminal costs
Definition: CostFunctionAnalytical-impl.hpp:101
for i
Definition: mpc_unittest_plotting.m:14
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_matrix_t controlSecondDerivativeTerminalBase()
evaluate terminal analytical control second derivatives
Definition: CostFunctionQuadratic-impl.hpp:459
control_state_matrix_t stateControlDerivativeTerminalBase()
evaluate terminal analytical control mixed state control derivatives
Definition: CostFunctionQuadratic-impl.hpp:492
std::vector< std::shared_ptr< TermBase< STATE_DIM, CONTROL_DIM, SCALAR > > > finalCostAnalytical_
Definition: CostFunctionQuadratic.hpp:241
#define CT_LOADABLE_TERMS(SCALAR_EVAL, SCALAR)
Definition: TermLoadMacros.hpp: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