11 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
17 const SCALAR_EVAL alpha)
18 : a_(a), x_ref_(x_ref), b_(b), u_ref_(u_ref), alphaSquared_(alpha * alpha)
22 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
33 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
41 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
46 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
48 const Eigen::Matrix<SCALAR, STATE_DIM, 1>&
x,
49 const Eigen::Matrix<SCALAR, CONTROL_DIM, 1>&
u,
52 return evalLocal<SCALAR>(
x,
u,
t);
56 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
60 ct::core::ADCGScalar
t)
62 return evalLocal<ct::core::ADCGScalar>(
x,
u,
t);
66 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
72 return (
a_.array() * (x -
x_ref_).array() *
73 ((x -
x_ref_).array().square() + Eigen::Array<SCALAR_EVAL, STATE_DIM, 1>::Ones() *
alphaSquared_)
79 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
88 (Eigen::Array<SCALAR_EVAL, STATE_DIM, 1>::Ones() *
alphaSquared_ + (x -
x_ref_).array().square())
94 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
101 return (
b_.array() * (u -
u_ref_).array() *
102 ((u -
u_ref_).array().square() + Eigen::Array<SCALAR_EVAL, CONTROL_DIM, 1>::Ones() *
alphaSquared_)
108 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
113 const SCALAR_EVAL& t)
117 (Eigen::Array<SCALAR_EVAL, CONTROL_DIM, 1>::Ones() *
alphaSquared_ + (u -
u_ref_).array().square())
123 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
128 const SCALAR_EVAL& t)
130 return control_state_matrix_t::Zero();
133 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL,
typename SCALAR>
135 const std::string& termName,
153 std::cout <<
"Reading " << termName;
154 std::cout <<
"\nRead a as a= " <<
a_.transpose();
155 std::cout <<
"\nRead x_ref as x_ref= " <<
x_ref_.transpose();
156 std::cout <<
"\nRead b as b= " <<
b_.transpose();
157 std::cout <<
"\nRead u_ref as u_ref= " <<
u_ref_.transpose();
158 std::cout <<
"\nRead alpha^2 as " <<
alphaSquared_ << std::endl;
core::ControlVector< CONTROL_DIM, SCALAR_EVAL > b_
Definition: TermSmoothAbs.hpp:89
SCALAR_EVAL alphaSquared_
Definition: TermSmoothAbs.hpp:91
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
core::ControlVector< CONTROL_DIM, SCALAR_EVAL > controlDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute derivative of this cost term w.r.t. the control input
Definition: TermSmoothAbs-impl.hpp:96
An interface for a term, supporting both analytical and auto-diff terms.
Definition: TermBase.hpp:30
core::StateVector< STATE_DIM, SCALAR_EVAL > a_
Definition: TermSmoothAbs.hpp:87
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: TermSmoothAbs.hpp:30
state_matrix_t stateSecondDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute second order derivative of this cost term w.r.t. the state
Definition: TermSmoothAbs-impl.hpp:81
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
control_matrix_t controlSecondDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute second order derivative of this cost term w.r.t. the control input
Definition: TermSmoothAbs-impl.hpp:110
CppAD::AD< CppAD::cg::CG< double > > SCALAR
TermSmoothAbs< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > * clone() const override
Deep-copy term.
Definition: TermSmoothAbs-impl.hpp:35
SCALAR evaluate(const Eigen::Matrix< SCALAR, STATE_DIM, 1 > &x, const Eigen::Matrix< SCALAR, CONTROL_DIM, 1 > &u, const SCALAR &t) override
Evaluates the term at x, u, t.
Definition: TermSmoothAbs-impl.hpp:47
void loadScalarCF(const std::string &filename, const std::string &scalarName, SCALAR &scalar, const std::string &termName="")
Definition: utilities.hpp:21
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
void loadConfigFile(const std::string &filename, const std::string &termName, bool verbose=false) override
load this term from a configuration file
Definition: TermSmoothAbs-impl.hpp:134
control_state_matrix_t stateControlDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute the cross-term derivative (state-control) of this cost function term
Definition: TermSmoothAbs-impl.hpp:125
core::ControlVector< CONTROL_DIM, SCALAR_EVAL > u_ref_
Definition: TermSmoothAbs.hpp:90
core::StateVector< STATE_DIM, SCALAR_EVAL > x_ref_
Definition: TermSmoothAbs.hpp:88
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_t
Definition: TermBase.hpp:39
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermSmoothAbs.hpp:29
const bool verbose
Definition: ConstraintComparison.h:18
void loadMatrixCF(const std::string &filename, const std::string &matrixName, Eigen::Matrix< SCALAR, ROW, COL > &matrix, const std::string &termName="")
Definition: utilities.hpp:46
core::StateVector< STATE_DIM, SCALAR_EVAL > stateDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t) override
compute derivative of this cost term w.r.t. the state
Definition: TermSmoothAbs-impl.hpp:67
A smooth absolute term of type where this calculation is performed component-wise and summed with in...
Definition: TermSmoothAbs.hpp:23
virtual ~TermSmoothAbs()
Definition: TermSmoothAbs-impl.hpp:42