robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
robotoc::ConstraintComponentBase Class Referenceabstract

Base class for constraint components. More...

#include <constraint_component_base.hpp>

Inheritance diagram for robotoc::ConstraintComponentBase:
Collaboration diagram for robotoc::ConstraintComponentBase:

Public Member Functions

 ConstraintComponentBase (const double barrier_param=1.0e-03, const double fraction_to_boundary_rule=0.995)
 Constructor. More...
 
virtual ~ConstraintComponentBase ()
 Destructor. More...
 
 ConstraintComponentBase (const ConstraintComponentBase &)=default
 Default copy constructor. More...
 
ConstraintComponentBaseoperator= (const ConstraintComponentBase &)=default
 Default copy operator. More...
 
 ConstraintComponentBase (ConstraintComponentBase &&) noexcept=default
 Default move constructor. More...
 
ConstraintComponentBaseoperator= (ConstraintComponentBase &&) noexcept=default
 Default move assign operator. More...
 
virtual KinematicsLevel kinematicsLevel () const =0
 Checks the kinematics level of the constraint component. More...
 
virtual void allocateExtraData (ConstraintComponentData &data) const =0
 Allocates extra data in ConstraintComponentData. More...
 
virtual bool isFeasible (Robot &robot, const ContactStatus &contact_status, ConstraintComponentData &data, const SplitSolution &s) const =0
 Checks whether the current solution s is feasible or not. More...
 
virtual void setSlack (Robot &robot, const ContactStatus &contact_status, ConstraintComponentData &data, const SplitSolution &s) const =0
 Sets the slack variables of each constraint components. More...
 
virtual void evalConstraint (Robot &robot, const ContactStatus &contact_status, ConstraintComponentData &data, const SplitSolution &s) const =0
 Computes the primal residual, residual in the complementary slackness, and the log-barrier function of the slack varible. More...
 
virtual void evalDerivatives (Robot &robot, const ContactStatus &contact_status, ConstraintComponentData &data, const SplitSolution &s, SplitKKTResidual &kkt_residual) const =0
 Computes the derivatives of the priaml residual, i.e., the Jacobian of the inequality constraint, and add the product of the Jacobian and the dual variable to the KKT residual. This function is always called just after evalConstraint(). More...
 
virtual void condenseSlackAndDual (const ContactStatus &contact_status, ConstraintComponentData &data, SplitKKTMatrix &kkt_matrix, SplitKKTResidual &kkt_residual) const =0
 Condenses the slack and dual variables, i.e., factorizes the
condensed Hessians and KKT residuals. This function is always called just after evalDerivatives(). More...
 
virtual void expandSlackAndDual (const ContactStatus &contact_status, ConstraintComponentData &data, const SplitDirection &d) const =0
 Expands the slack and dual, i.e., computes the directions of the slack and dual variables from the directions of the primal variables. More...
 
virtual int dimc () const =0
 Returns the size of the constraint. More...
 
void setSlackAndDualPositive (ConstraintComponentData &data) const
 Sets the slack and dual variables positive. More...
 
double maxSlackStepSize (const ConstraintComponentData &data) const
 Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of the slack variable. More...
 
double maxDualStepSize (const ConstraintComponentData &data) const
 Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of the dual variable. More...
 
virtual double getBarrierParam () const final
 Gets the barrier parameter. More...
 
virtual double getFractionToBoundaryRule () const final
 Gets the margin parameter of the fraction-to-boundary-rule. More...
 
virtual void setBarrierParam (const double barrier_param) final
 Sets the barrier parameter. More...
 
virtual void setFractionToBoundaryRule (const double fraction_to_boundary_rule) final
 Sets the margin parameter of the fraction-to-boundary-rule. More...
 
template<typename Derived >
std::shared_ptr< Derived > as_shared_ptr ()
 Gets the shared ptr of this object as the specified type. If this fails in dynamic casting, throws an exception. More...
 

Static Public Member Functions

static void updateSlack (ConstraintComponentData &data, const double step_size)
 Updates the slack variable according to the step size. More...
 
static void updateDual (ConstraintComponentData &data, const double step_size)
 Updates the dual variable according to the step size. More...
 

Protected Member Functions

void computeComplementarySlackness (ConstraintComponentData &data) const
 Computes the residual in the complementarity slackness between
the slack and dual variables. More...
 
void computeComplementarySlackness (ConstraintComponentData &data, const int start, const int size) const
 Computes the residual in the complementarity slackness between
the slack and dual variables. More...
 
template<int Size>
void computeComplementarySlackness (ConstraintComponentData &data, const int start) const
 Computes the residual in the complementarity slackness between
the slack and dual variables. More...
 
double computeComplementarySlackness (const double slack, const double dual) const
 Computes the residual in the complementarity slackness between
the slack and dual variables. More...
 
template<typename VectorType >
double logBarrier (const Eigen::MatrixBase< VectorType > &slack) const
 Computes the log barrier function of the slack variable. More...
 

Static Protected Member Functions

static void computeCondensingCoeffcient (ConstraintComponentData &data)
 Computes the coefficient of the condensing. More...
 
static void computeCondensingCoeffcient (ConstraintComponentData &data, const int start, const int size)
 Computes the coefficient of the condensing. More...
 
template<int Size>
static void computeCondensingCoeffcient (ConstraintComponentData &data, const int start)
 Computes the coefficient of the condensing. More...
 
static double computeCondensingCoeffcient (const double slack, const double dual, const double residual, const double cmpl)
 Computes the residual in the complementarity slackness between
the slack and dual variables. More...
 
static void computeDualDirection (ConstraintComponentData &data)
 Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack. More...
 
static void computeDualDirection (ConstraintComponentData &data, const int start, const int size)
 Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack. More...
 
template<int Size>
static void computeDualDirection (ConstraintComponentData &data, const int start)
 Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack. More...
 
static double computeDualDirection (const double slack, const double dual, const double dslack, const double cmpl)
 Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack. More...
 

Detailed Description

Base class for constraint components.

Constructor & Destructor Documentation

◆ ConstraintComponentBase() [1/3]

robotoc::ConstraintComponentBase::ConstraintComponentBase ( const double  barrier_param = 1.0e-03,
const double  fraction_to_boundary_rule = 0.995 
)

Constructor.

Parameters
[in]barrier_paramBarrier parameter. Must be positive. Should be small. Default is 1.0e-03.
[in]fraction_to_boundary_ruleParameter of the fraction-to-boundary-rule Must be larger than 0 and smaller than 1. Should be between 0.9 and 0.995. Default is 0.995.

◆ ~ConstraintComponentBase()

virtual robotoc::ConstraintComponentBase::~ConstraintComponentBase ( )
inlinevirtual

Destructor.

◆ ConstraintComponentBase() [2/3]

robotoc::ConstraintComponentBase::ConstraintComponentBase ( const ConstraintComponentBase )
default

Default copy constructor.

◆ ConstraintComponentBase() [3/3]

robotoc::ConstraintComponentBase::ConstraintComponentBase ( ConstraintComponentBase &&  )
defaultnoexcept

Default move constructor.

Member Function Documentation

◆ allocateExtraData()

◆ as_shared_ptr()

template<typename Derived >
std::shared_ptr< Derived > robotoc::ConstraintComponentBase::as_shared_ptr
inline

Gets the shared ptr of this object as the specified type. If this fails in dynamic casting, throws an exception.

Template Parameters
DerivedThe derived type.
Returns
shared ptr of this object as the specified type.

◆ computeComplementarySlackness() [1/4]

double robotoc::ConstraintComponentBase::computeComplementarySlackness ( const double  slack,
const double  dual 
) const
inlineprotected

Computes the residual in the complementarity slackness between
the slack and dual variables.

Parameters
[in]slackAn element of the slack variable.
[in]dualAn element of the dual variable.
Returns
The complementarity slackness between the slack and dual variables.

◆ computeComplementarySlackness() [2/4]

void robotoc::ConstraintComponentBase::computeComplementarySlackness ( ConstraintComponentData data) const
inlineprotected

Computes the residual in the complementarity slackness between
the slack and dual variables.

Parameters
[in,out]dataConstraint data.

◆ computeComplementarySlackness() [3/4]

template<int Size>
void robotoc::ConstraintComponentBase::computeComplementarySlackness ( ConstraintComponentData data,
const int  start 
) const
inlineprotected

Computes the residual in the complementarity slackness between
the slack and dual variables.

Parameters
[in,out]dataConstraint data.
[in]startStart position of the segment.
Template Parameters
SizeSize of the segment.

◆ computeComplementarySlackness() [4/4]

void robotoc::ConstraintComponentBase::computeComplementarySlackness ( ConstraintComponentData data,
const int  start,
const int  size 
) const
inlineprotected

Computes the residual in the complementarity slackness between
the slack and dual variables.

Parameters
[in,out]dataConstraint data.
[in]startStart position of the segment.
[in]sizeSize of the segment.

◆ computeCondensingCoeffcient() [1/4]

double robotoc::ConstraintComponentBase::computeCondensingCoeffcient ( const double  slack,
const double  dual,
const double  residual,
const double  cmpl 
)
inlinestaticprotected

Computes the residual in the complementarity slackness between
the slack and dual variables.

Parameters
[in]slackAn element of the slack variable.
[in]dualAn element of the dual variable.
[in]residualAn element of the primal residual.
[in]cmplAn element of the complementarity slackness.
Returns
Coefficient of the condensing.

◆ computeCondensingCoeffcient() [2/4]

void robotoc::ConstraintComponentBase::computeCondensingCoeffcient ( ConstraintComponentData data)
inlinestaticprotected

Computes the coefficient of the condensing.

Parameters
[in,out]dataConstraint component data.

◆ computeCondensingCoeffcient() [3/4]

template<int Size>
void robotoc::ConstraintComponentBase::computeCondensingCoeffcient ( ConstraintComponentData data,
const int  start 
)
inlinestaticprotected

Computes the coefficient of the condensing.

Parameters
[in,out]dataConstraint data.
[in]startStart position of the segment.
Template Parameters
SizeSize of the segment.

◆ computeCondensingCoeffcient() [4/4]

void robotoc::ConstraintComponentBase::computeCondensingCoeffcient ( ConstraintComponentData data,
const int  start,
const int  size 
)
inlinestaticprotected

Computes the coefficient of the condensing.

Parameters
[in,out]dataConstraint data.
[in]startStart position of the segment.
[in]sizeSize of the segment.

◆ computeDualDirection() [1/4]

double robotoc::ConstraintComponentBase::computeDualDirection ( const double  slack,
const double  dual,
const double  dslack,
const double  cmpl 
)
inlinestaticprotected

Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack.

Parameters
[in]slackThe slack variable.
[in]dualThe dual variable.
[in]dslackThe direction of the slack variable.
[in]cmplThe residual in the complementary slackness.
Returns
The direction of the dual variable.

◆ computeDualDirection() [2/4]

void robotoc::ConstraintComponentBase::computeDualDirection ( ConstraintComponentData data)
inlinestaticprotected

Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack.

Parameters
[in,out]dataConstraint data.

◆ computeDualDirection() [3/4]

template<int Size>
void robotoc::ConstraintComponentBase::computeDualDirection ( ConstraintComponentData data,
const int  start 
)
inlinestaticprotected

Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack.

Parameters
[in,out]dataConstraint data.
[in]startStart position of the segment.
Template Parameters
SizeSize of the segment.

◆ computeDualDirection() [4/4]

void robotoc::ConstraintComponentBase::computeDualDirection ( ConstraintComponentData data,
const int  start,
const int  size 
)
inlinestaticprotected

Computes the direction of the dual variable from slack, primal residual, complementary slackness, and the direction of the slack.

Parameters
[in,out]dataConstraint data.
[in]startStart position of the segment.
[in]sizeSize of the segment.

◆ condenseSlackAndDual()

virtual void robotoc::ConstraintComponentBase::condenseSlackAndDual ( const ContactStatus contact_status,
ConstraintComponentData data,
SplitKKTMatrix kkt_matrix,
SplitKKTResidual kkt_residual 
) const
pure virtual

Condenses the slack and dual variables, i.e., factorizes the
condensed Hessians and KKT residuals. This function is always called just after evalDerivatives().

Parameters
[in]contact_statusContact status.
[in]dataConstraint data.
[out]kkt_matrixSplit KKT matrix. The condensed Hessians are added
to this object.
[out]kkt_residualSplit KKT residual. The condensed residuals are added to this object.

Implemented in robotoc::ContactWrenchCone, robotoc::FrictionCone, robotoc::JointAccelerationLowerLimit, robotoc::JointAccelerationUpperLimit, robotoc::JointPositionLowerLimit, robotoc::JointPositionUpperLimit, robotoc::JointTorquesLowerLimit, robotoc::JointTorquesUpperLimit, robotoc::JointVelocityLowerLimit, and robotoc::JointVelocityUpperLimit.

◆ dimc()

◆ evalConstraint()

virtual void robotoc::ConstraintComponentBase::evalConstraint ( Robot robot,
const ContactStatus contact_status,
ConstraintComponentData data,
const SplitSolution s 
) const
pure virtual

Computes the primal residual, residual in the complementary slackness, and the log-barrier function of the slack varible.

Parameters
[in]robotRobot model.
[in]contact_statusContact status.
[in]dataConstraint data.
[in]sSplit solution.

Implemented in robotoc::ContactWrenchCone, robotoc::FrictionCone, robotoc::JointAccelerationLowerLimit, robotoc::JointAccelerationUpperLimit, robotoc::JointPositionLowerLimit, robotoc::JointPositionUpperLimit, robotoc::JointTorquesLowerLimit, robotoc::JointTorquesUpperLimit, robotoc::JointVelocityLowerLimit, and robotoc::JointVelocityUpperLimit.

◆ evalDerivatives()

virtual void robotoc::ConstraintComponentBase::evalDerivatives ( Robot robot,
const ContactStatus contact_status,
ConstraintComponentData data,
const SplitSolution s,
SplitKKTResidual kkt_residual 
) const
pure virtual

Computes the derivatives of the priaml residual, i.e., the Jacobian of the inequality constraint, and add the product of the Jacobian and the dual variable to the KKT residual. This function is always called just after evalConstraint().

Parameters
[in]robotRobot model.
[in]contact_statusContact status.
[in]dataConstraint data.
[in]sSplit solution.
[out]kkt_residualSplit KKT residual.

Implemented in robotoc::ContactWrenchCone, robotoc::FrictionCone, robotoc::JointAccelerationLowerLimit, robotoc::JointAccelerationUpperLimit, robotoc::JointPositionLowerLimit, robotoc::JointPositionUpperLimit, robotoc::JointTorquesLowerLimit, robotoc::JointTorquesUpperLimit, robotoc::JointVelocityLowerLimit, and robotoc::JointVelocityUpperLimit.

◆ expandSlackAndDual()

virtual void robotoc::ConstraintComponentBase::expandSlackAndDual ( const ContactStatus contact_status,
ConstraintComponentData data,
const SplitDirection d 
) const
pure virtual

Expands the slack and dual, i.e., computes the directions of the slack and dual variables from the directions of the primal variables.

Parameters
[in]contact_statusContact status.
[in,out]dataConstraint data.
[in]dSplit direction.

Implemented in robotoc::ContactWrenchCone, robotoc::FrictionCone, robotoc::JointAccelerationLowerLimit, robotoc::JointAccelerationUpperLimit, robotoc::JointPositionLowerLimit, robotoc::JointPositionUpperLimit, robotoc::JointTorquesLowerLimit, robotoc::JointTorquesUpperLimit, robotoc::JointVelocityLowerLimit, and robotoc::JointVelocityUpperLimit.

◆ getBarrierParam()

virtual double robotoc::ConstraintComponentBase::getBarrierParam ( ) const
finalvirtual

Gets the barrier parameter.

Returns
The barrier parameter.

◆ getFractionToBoundaryRule()

virtual double robotoc::ConstraintComponentBase::getFractionToBoundaryRule ( ) const
finalvirtual

Gets the margin parameter of the fraction-to-boundary-rule.

Returns
The margin parameter of the fraction-to-boundary-rule.

◆ isFeasible()

virtual bool robotoc::ConstraintComponentBase::isFeasible ( Robot robot,
const ContactStatus contact_status,
ConstraintComponentData data,
const SplitSolution s 
) const
pure virtual

Checks whether the current solution s is feasible or not.

Parameters
[in]robotRobot model.
[in]contact_statusContact status.
[in]dataConstraint data.
[in]sSplit solution.
Returns
true if s is feasible. false if not.

Implemented in robotoc::ContactWrenchCone, robotoc::FrictionCone, robotoc::JointAccelerationLowerLimit, robotoc::JointAccelerationUpperLimit, robotoc::JointPositionLowerLimit, robotoc::JointPositionUpperLimit, robotoc::JointTorquesLowerLimit, robotoc::JointTorquesUpperLimit, robotoc::JointVelocityLowerLimit, and robotoc::JointVelocityUpperLimit.

◆ kinematicsLevel()

virtual KinematicsLevel robotoc::ConstraintComponentBase::kinematicsLevel ( ) const
pure virtual

◆ logBarrier()

template<typename VectorType >
double robotoc::ConstraintComponentBase::logBarrier ( const Eigen::MatrixBase< VectorType > &  slack) const
inlineprotected

Computes the log barrier function of the slack variable.

Parameters
[in]slackSlack variable. All the components must be positive.
Returns
log barrier function of the slack variable.

◆ maxDualStepSize()

double robotoc::ConstraintComponentBase::maxDualStepSize ( const ConstraintComponentData data) const
inline

Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of the dual variable.

Parameters
[in]dataConstraint data.
Returns
Maximum step size regarding the dual variable.

◆ maxSlackStepSize()

double robotoc::ConstraintComponentBase::maxSlackStepSize ( const ConstraintComponentData data) const
inline

Computes and returns the maximum step size by applying fraction-to-boundary-rule to the direction of the slack variable.

Parameters
[in]dataConstraint data.
Returns
Maximum step size regarding the slack variable.

◆ operator=() [1/2]

ConstraintComponentBase & robotoc::ConstraintComponentBase::operator= ( const ConstraintComponentBase )
default

Default copy operator.

◆ operator=() [2/2]

ConstraintComponentBase & robotoc::ConstraintComponentBase::operator= ( ConstraintComponentBase &&  )
defaultnoexcept

Default move assign operator.

◆ setBarrierParam()

virtual void robotoc::ConstraintComponentBase::setBarrierParam ( const double  barrier_param)
finalvirtual

Sets the barrier parameter.

Parameters
[in]barrier_paramBarrier parameter. Must be positive. Should be small.

◆ setFractionToBoundaryRule()

virtual void robotoc::ConstraintComponentBase::setFractionToBoundaryRule ( const double  fraction_to_boundary_rule)
finalvirtual

Sets the margin parameter of the fraction-to-boundary-rule.

Parameters
[in]fraction_to_boundary_ruleMust be larger than 0 and smaller than 1. Should be between 0.9 and 0.995.

◆ setSlack()

virtual void robotoc::ConstraintComponentBase::setSlack ( Robot robot,
const ContactStatus contact_status,
ConstraintComponentData data,
const SplitSolution s 
) const
pure virtual

◆ setSlackAndDualPositive()

void robotoc::ConstraintComponentBase::setSlackAndDualPositive ( ConstraintComponentData data) const

Sets the slack and dual variables positive.

Parameters
[in,out]dataConstraint data.

◆ updateDual()

void robotoc::ConstraintComponentBase::updateDual ( ConstraintComponentData data,
const double  step_size 
)
inlinestatic

Updates the dual variable according to the step size.

Parameters
[in,out]dataConstraint data.
[in]step_sizeStep size.

◆ updateSlack()

void robotoc::ConstraintComponentBase::updateSlack ( ConstraintComponentData data,
const double  step_size 
)
inlinestatic

Updates the slack variable according to the step size.

Parameters
[in,out]dataConstraint data.
[in]step_sizeStep size.

The documentation for this class was generated from the following files: