13 #include <boost/property_tree/ptree.hpp> 14 #include <boost/property_tree/info_parser.hpp> 15 #include <boost/algorithm/string.hpp> 36 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR =
double>
37 class CostFunctionAD :
public CostFunctionQuadratic<STATE_DIM, CONTROL_DIM, SCALAR>
40 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42 typedef core::DerivativesCppadJIT<STATE_DIM + CONTROL_DIM + 1, 1>
JacCG;
43 typedef typename JacCG::CG_SCALAR CGScalar;
44 typedef Eigen::Matrix<CGScalar, 1, 1> MatrixCg;
46 typedef Eigen::Matrix<SCALAR, STATE_DIM, STATE_DIM>
state_matrix_t;
48 typedef Eigen::Matrix<SCALAR, CONTROL_DIM, STATE_DIM> control_state_matrix_t;
52 typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> VectorXs;
53 typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> MatrixXs;
65 CostFunctionAD(
const std::string& filename,
bool verbose =
false);
71 CostFunctionAD<STATE_DIM, CONTROL_DIM, SCALAR>* clone()
const override;
77 CostFunctionAD(
const CostFunctionAD& arg);
83 virtual ~CostFunctionAD();
90 virtual void initialize()
override;
101 void addIntermediateADTerm(std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>> term,
102 bool verbose =
false)
override;
113 void addFinalADTerm(std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>> term,
114 bool verbose =
false)
override;
116 void setCurrentStateAndControl(
const state_vector_t&
x,
const control_vector_t&
u,
const SCALAR&
t = 0.0)
override;
118 void loadFromConfigFile(
const std::string& filename,
bool verbose =
false)
override;
120 SCALAR evaluateIntermediate()
override;
121 SCALAR evaluateTerminal()
override;
123 state_vector_t stateDerivativeIntermediate()
override;
124 state_vector_t stateDerivativeTerminal()
override;
126 control_vector_t controlDerivativeIntermediate()
override;
127 control_vector_t controlDerivativeTerminal()
override;
129 state_matrix_t stateSecondDerivativeIntermediate()
override;
130 state_matrix_t stateSecondDerivativeTerminal()
override;
132 control_matrix_t controlSecondDerivativeIntermediate()
override;
133 control_matrix_t controlSecondDerivativeTerminal()
override;
135 control_state_matrix_t stateControlDerivativeIntermediate()
override;
136 control_state_matrix_t stateControlDerivativeTerminal()
override;
138 std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>> getIntermediateADTermById(
const size_t id);
140 std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>> getFinalADTermById(
const size_t id);
142 std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>> getIntermediateADTermByName(
143 const std::string& name);
145 std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>> getFinalADTermByName(
const std::string& name);
149 MatrixCg evaluateIntermediateCg(
const Eigen::Matrix<CGScalar, STATE_DIM + CONTROL_DIM + 1, 1>& stateInputTime);
150 MatrixCg evaluateTerminalCg(
const Eigen::Matrix<CGScalar, STATE_DIM + CONTROL_DIM + 1, 1>& stateInputTime);
153 Eigen::Matrix<SCALAR, STATE_DIM + CONTROL_DIM + 1, 1> stateControlTime_;
156 std::vector<std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>>> intermediateTerms_;
158 std::vector<std::shared_ptr<TermBase<STATE_DIM, CONTROL_DIM, SCALAR, CGScalar>>> finalTerms_;
161 std::shared_ptr<JacCG> intermediateCostCodegen_;
162 std::shared_ptr<JacCG> finalCostCodegen_;
165 typename JacCG::FUN_TYPE_CG intermediateFun_;
166 typename JacCG::FUN_TYPE_CG finalFun_;
Eigen::Matrix< double, nControls, nControls > control_matrix_t
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
Eigen::Matrix< double, nControls, 1 > control_vector_t
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
CppAD::AD< CppAD::cg::CG< double > > SCALAR
ct::core::DerivativesCppadCG< state_dim, control_dim > JacCG
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
Eigen::Matrix< double, nStates, nStates > state_matrix_t
Eigen::Matrix< double, nStates, 1 > state_vector_t
const bool verbose
Definition: ConstraintComparison.h:18