9 #include <boost/algorithm/string.hpp> 29 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR_EVAL =
double,
typename SCALAR = SCALAR_EVAL>
36 std::shared_ptr<ct::core::tpl::ActivationBase<SCALAR_EVAL>>
c_i_;
50 TermBase(std::string name =
"Unnamed");
79 const Eigen::Matrix<SCALAR, CONTROL_DIM, 1>&
u,
94 ct::core::ADCGScalar
t);
107 SCALAR_EVAL
eval(
const Eigen::Matrix<SCALAR_EVAL, STATE_DIM, 1>&
x,
108 const Eigen::Matrix<SCALAR_EVAL, CONTROL_DIM, 1>&
u,
109 const SCALAR_EVAL&
t);
127 const SCALAR_EVAL&
t);
132 const SCALAR_EVAL&
t);
138 const SCALAR_EVAL&
t);
143 const SCALAR_EVAL&
t);
148 const SCALAR_EVAL&
t);
151 virtual void loadConfigFile(
const std::string& filename,
const std::string& termName,
bool verbose =
false);
163 const std::string&
getName()
const;
169 void setName(
const std::string& termName);
virtual Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > getReferenceState() const
retrieve this term's current reference state
Definition: TermBase-impl.hpp:207
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_double_t
Definition: TermBase.hpp:42
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_double_t
Definition: TermBase.hpp:44
virtual SCALAR evaluate(const Eigen::Matrix< SCALAR, STATE_DIM, 1 > &x, const Eigen::Matrix< SCALAR, CONTROL_DIM, 1 > &u, const SCALAR &t)=0
Evaluates the term at x, u, t.
void setName(const std::string &termName)
Sets the name of the term.
Definition: TermBase-impl.hpp:189
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
SCALAR_EVAL eval(const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > &x, const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, 1 > &u, const SCALAR_EVAL &t)
Gets called by the analytical costfunction. Adds time dependent activations on top of the term...
Definition: TermBase-impl.hpp:32
virtual ~TermBase()
Destructor.
Definition: TermBase-impl.hpp:26
virtual TermBase< STATE_DIM, CONTROL_DIM, SCALAR_EVAL, SCALAR > * clone() const =0
Deep-copy term.
virtual void loadConfigFile(const std::string &filename, const std::string &termName, bool verbose=false)
load this term from a configuration file
Definition: TermBase-impl.hpp:127
An interface for a term, supporting both analytical and auto-diff terms.
Definition: TermBase.hpp:30
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, STATE_DIM > control_state_matrix_t
Definition: TermBase.hpp:41
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
TermBase(std::string name="Unnamed")
Default constructor.
Definition: TermBase-impl.hpp:13
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual void updateReferenceState(const Eigen::Matrix< SCALAR_EVAL, STATE_DIM, 1 > &newRefState)
updates the reference state for this term
Definition: TermBase-impl.hpp:195
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
const std::string & getName() const
Returns the name of the term.
Definition: TermBase-impl.hpp:183
virtual 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)
compute the cross-term derivative (state-control) of this cost function term
Definition: TermBase-impl.hpp:115
std::shared_ptr< ct::core::tpl::ActivationBase< SCALAR_EVAL > > c_i_
time activations for this term
Definition: TermBase.hpp:36
SCALAR_EVAL computeActivation(SCALAR_EVAL t)
compute time activation
Definition: TermBase-impl.hpp:58
Eigen::Matrix< SCALAR_EVAL, STATE_DIM, STATE_DIM > state_matrix_t
Definition: TermBase.hpp:39
void setTimeActivation(std::shared_ptr< ct::core::tpl::ActivationBase< SCALAR_EVAL >> c_i, bool verbose=false)
set the time activation functions for this term
Definition: TermBase-impl.hpp:137
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_double_t
Definition: TermBase.hpp:43
virtual void updateReferenceControl(const Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, 1 > &newRefControl)
updates the reference control for this term
Definition: TermBase-impl.hpp:201
const bool verbose
Definition: ConstraintComparison.h:18
virtual 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)
compute derivative of this cost term w.r.t. the state
Definition: TermBase-impl.hpp:64
virtual state_matrix_t stateSecondDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t)
compute second order derivative of this cost term w.r.t. the state
Definition: TermBase-impl.hpp:77
std::string name_
a name identifier for this term
Definition: TermBase.hpp:34
void loadTimeActivation(const std::string &filename, const std::string &termName, bool verbose=false)
load the time activation functions for this term from file
Definition: TermBase-impl.hpp:147
virtual 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)
compute derivative of this cost term w.r.t. the control input
Definition: TermBase-impl.hpp:89
virtual control_matrix_t controlSecondDerivative(const core::StateVector< STATE_DIM, SCALAR_EVAL > &x, const core::ControlVector< CONTROL_DIM, SCALAR_EVAL > &u, const SCALAR_EVAL &t)
compute second order derivative of this cost term w.r.t. the control input
Definition: TermBase-impl.hpp:102
virtual bool isActiveAtTime(SCALAR_EVAL t)
Returns if term is non-zero at a specific time By default, all terms are evaluated at all times...
Definition: TermBase-impl.hpp:52
Eigen::Matrix< SCALAR_EVAL, CONTROL_DIM, CONTROL_DIM > control_matrix_t
Definition: TermBase.hpp:40