Template Class ActivationModel2NormBarrierTpl

Inheritance Relationships

Base Type

Class Documentation

template<typename _Scalar>
class ActivationModel2NormBarrierTpl : public crocoddyl::ActivationModelAbstractTpl<_Scalar>

2-norm barrier activation

This activation function describes a quadratic barrier of the 2-norm of a residual vector, i.e.,

\[\begin{split} \Bigg\{\begin{aligned} &\frac{1}{2} (d - \alpha)^2, &\textrm{if} \,\,\, d < \alpha \\ &0, &\textrm{otherwise}, \end{aligned} \end{split}\]
where \(d = \|r\|\) is the norm of the residual, \(\alpha\) the threshold distance from which the barrier is active, \(nr\) is the dimension of the residual vector.

The computation of the function and it derivatives are carried out in calc() and calcDiff(), respectively.

Public Types

typedef MathBaseTpl<Scalar> MathBase
typedef ActivationModelAbstractTpl<Scalar> Base
typedef ActivationDataAbstractTpl<Scalar> ActivationDataAbstract
typedef ActivationData2NormBarrierTpl<Scalar> Data
typedef MathBase::VectorXs VectorXs

Public Functions

inline explicit ActivationModel2NormBarrierTpl(const std::size_t nr, const Scalar alpha = Scalar(0.1), const bool true_hessian = false)

Initialize the 2-norm barrier activation model.

The default alpha value is defined as 0.1.

Parameters:
  • nr[in] Dimension of the residual vector

  • alpha[in] Threshold factor (default 0.1)

  • true_hessian[in] Boolean indicating whether to use the Gauss-Newton approximation or true Hessian in computing the derivatives (default: false)

virtual ~ActivationModel2NormBarrierTpl() = default
inline virtual void calc(const std::shared_ptr<ActivationDataAbstract> &data, const Eigen::Ref<const VectorXs> &r) override

Compute the 2-norm barrier function.

Parameters:
  • data[in] 2-norm barrier activation data

  • r[in] Residual vector \(\mathbf{r}\in\mathbb{R}^{nr}\)

inline virtual void calcDiff(const std::shared_ptr<ActivationDataAbstract> &data, const Eigen::Ref<const VectorXs> &r) override

Compute the derivatives of the 2norm-barrier function.

Parameters:
  • data[in] 2-norm barrier activation data

  • r[in] Residual vector \(\mathbf{r}\in\mathbb{R}^{nr}\)

inline virtual std::shared_ptr<ActivationDataAbstract> createData() override

Create the 2norm-barrier activation data.

Returns:

the activation data

template<typename NewScalar>
inline ActivationModel2NormBarrierTpl<NewScalar> cast() const
inline const Scalar &get_alpha() const

Get and set the threshold factor.

inline void set_alpha(const Scalar &alpha)
inline virtual void print(std::ostream &os) const override

Print relevant information of the 2-norm barrier model.

Parameters:

os[out] Output stream object

Public Members

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _Scalar Scalar

Protected Attributes

Scalar alpha_

< Dimension of the residual vector

Threshold factor

bool true_hessian_

Use true Hessian in calcDiff if true, Gauss-Newton approximation if false