OCS2 Manual  v1.0.0
OCS2 Documentation
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T > Class Template Reference

#include <ConstraintBase.h>

Detailed Description

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
class ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >

Base class for the constraints and its Derivatives. The linearized constraints are defined as:
Here we consider three types of constraints:

  • state-input constraints, $ g_1(x,u,t) = 0$,
  • state-only constraints, $ g_2(x,t) = 0$.
  • inequality constraint, $ h(x,u,t) \geq 0$

    $ x $, $ u $, and $ t $ are state, input, and vector of event times respectively.

  • Linearized state-input constraints: $ C(t) \delta x + D(t) \delta u + e(t) = 0 $
  • Linearized only-state constraints: $ F(t) \delta x + h(t) = 0 $
  • Linearized only-state final constraints: $ F_f(t) \delta x + h_f(t) = 0 $
  • Quadratic approximation of each inequality constraint: $ h_{0,i}(t) + h_{x,i}(t) \delta x + h_{u,i}(t) \delta u $
    $ \qquad + 0.5 \delta x H_{xx,i}(t) \delta x + \delta u H_{ux,i}(t) \delta x + 0.5 \delta u H_{uu,i}(t) \delta u \geq 0 \quad \forall i $
Template Parameters
STATE_DIMDimension of the state space.
INPUT_DIMDimension of the control input space.
LOGIC_RULES_TLogic Rules type (default NullLogicRules).
Inheritance diagram for ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >:
ocs2::ConstraintBaseAD< Derived, STATE_DIM, INPUT_DIM, LOGIC_RULES_T > ocs2::LinearConstraint< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >

Public Types

using Ptr = std::shared_ptr< ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T > >
 
using ConstPtr = std::shared_ptr< const ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T > >
 
using DIMENSIONS = Dimensions< STATE_DIM, INPUT_DIM >
 
using scalar_t = typename DIMENSIONS::scalar_t
 
using scalar_array_t = typename DIMENSIONS::scalar_array_t
 
using state_vector_t = typename DIMENSIONS::state_vector_t
 
using state_vector_array_t = typename DIMENSIONS::state_vector_array_t
 
using input_vector_t = typename DIMENSIONS::input_vector_t
 
using input_vector_array_t = typename DIMENSIONS::input_vector_array_t
 
using state_matrix_t = typename DIMENSIONS::state_matrix_t
 
using state_matrix_array_t = typename DIMENSIONS::state_matrix_array_t
 
using input_matrix_t = typename DIMENSIONS::input_matrix_t
 
using input_matrix_array_t = typename DIMENSIONS::input_matrix_array_t
 
using state_input_matrix_t = typename DIMENSIONS::state_input_matrix_t
 
using input_state_matrix_t = typename DIMENSIONS::input_state_matrix_t
 
using input_state_matrix_array_t = typename DIMENSIONS::input_state_matrix_array_t
 
using constraint1_vector_t = typename DIMENSIONS::constraint1_vector_t
 
using constraint1_vector_array_t = typename DIMENSIONS::constraint1_vector_array_t
 
using constraint2_vector_t = typename DIMENSIONS::constraint2_vector_t
 
using constraint2_vector_array_t = typename DIMENSIONS::constraint2_vector_array_t
 
using constraint1_state_matrix_t = typename DIMENSIONS::constraint1_state_matrix_t
 
using constraint1_input_matrix_t = typename DIMENSIONS::constraint1_input_matrix_t
 
using constraint2_state_matrix_t = typename DIMENSIONS::constraint2_state_matrix_t
 

Public Member Functions

 ConstraintBase ()=default
 
 ConstraintBase (const ConstraintBase &rhs)=default
 
virtual ~ConstraintBase ()=default
 
virtual void setCurrentStateAndControl (const scalar_t &t, const state_vector_t &x, const input_vector_t &u)
 
virtual void initializeModel (LogicRulesMachine< LOGIC_RULES_T > &logicRulesMachine, const size_t &partitionIndex, const char *algorithmName=nullptr)
 
virtual ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T > * clone () const
 
virtual void getConstraint1 (constraint1_vector_t &e)
 
virtual size_t numStateInputConstraint (const scalar_t &time)
 
virtual void getConstraint2 (constraint2_vector_t &h)
 
virtual size_t numStateOnlyConstraint (const scalar_t &time)
 
virtual void getInequalityConstraint (scalar_array_t &h)
 
virtual size_t numInequalityConstraint (const scalar_t &time)
 
virtual void getFinalConstraint2 (constraint2_vector_t &h_f)
 
virtual size_t numStateOnlyFinalConstraint (const scalar_t &time)
 
virtual void getConstraint1DerivativesState (constraint1_state_matrix_t &C)
 
virtual void getConstraint1DerivativesControl (constraint1_input_matrix_t &D)
 
virtual void getConstraint1DerivativesEventTimes (constraint1_vector_array_t &g1DevArray)
 
virtual void getConstraint2DerivativesState (constraint2_state_matrix_t &F)
 
virtual void getInequalityConstraintDerivativesState (state_vector_array_t &dhdx)
 
virtual void getInequalityConstraintDerivativesInput (input_vector_array_t &dhdu)
 
virtual void getInequalityConstraintSecondDerivativesState (state_matrix_array_t &ddhdxdx)
 
virtual void getInequalityConstraintSecondDerivativesInput (input_matrix_array_t &ddhdudu)
 
virtual void getInequalityConstraintDerivativesInputState (input_state_matrix_array_t &ddhdudx)
 
virtual void getFinalConstraint2DerivativesState (constraint2_state_matrix_t &F_f)
 

Public Attributes

 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 

Protected Attributes

scalar_t t_
 
state_vector_t x_
 
input_vector_t u_
 

Member Typedef Documentation

◆ ConstPtr

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::ConstPtr = std::shared_ptr<const ConstraintBase<STATE_DIM, INPUT_DIM, LOGIC_RULES_T> >

◆ constraint1_input_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint1_input_matrix_t = typename DIMENSIONS::constraint1_input_matrix_t

◆ constraint1_state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint1_state_matrix_t = typename DIMENSIONS::constraint1_state_matrix_t

◆ constraint1_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint1_vector_array_t = typename DIMENSIONS::constraint1_vector_array_t

◆ constraint1_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint1_vector_t = typename DIMENSIONS::constraint1_vector_t

◆ constraint2_state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint2_state_matrix_t = typename DIMENSIONS::constraint2_state_matrix_t

◆ constraint2_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint2_vector_array_t = typename DIMENSIONS::constraint2_vector_array_t

◆ constraint2_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::constraint2_vector_t = typename DIMENSIONS::constraint2_vector_t

◆ DIMENSIONS

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::DIMENSIONS = Dimensions<STATE_DIM, INPUT_DIM>

◆ input_matrix_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::input_matrix_array_t = typename DIMENSIONS::input_matrix_array_t

◆ input_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::input_matrix_t = typename DIMENSIONS::input_matrix_t

◆ input_state_matrix_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::input_state_matrix_array_t = typename DIMENSIONS::input_state_matrix_array_t

◆ input_state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::input_state_matrix_t = typename DIMENSIONS::input_state_matrix_t

◆ input_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::input_vector_array_t = typename DIMENSIONS::input_vector_array_t

◆ input_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::input_vector_t = typename DIMENSIONS::input_vector_t

◆ Ptr

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::Ptr = std::shared_ptr<ConstraintBase<STATE_DIM, INPUT_DIM, LOGIC_RULES_T> >

◆ scalar_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::scalar_array_t = typename DIMENSIONS::scalar_array_t

◆ scalar_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::scalar_t = typename DIMENSIONS::scalar_t

◆ state_input_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::state_input_matrix_t = typename DIMENSIONS::state_input_matrix_t

◆ state_matrix_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::state_matrix_array_t = typename DIMENSIONS::state_matrix_array_t

◆ state_matrix_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::state_matrix_t = typename DIMENSIONS::state_matrix_t

◆ state_vector_array_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::state_vector_array_t = typename DIMENSIONS::state_vector_array_t

◆ state_vector_t

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
using ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::state_vector_t = typename DIMENSIONS::state_vector_t

Constructor & Destructor Documentation

◆ ConstraintBase() [1/2]

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::ConstraintBase ( )
default

Default constructor

◆ ConstraintBase() [2/2]

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::ConstraintBase ( const ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T > &  rhs)
default

Default copy constructor

◆ ~ConstraintBase()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::~ConstraintBase ( )
virtualdefault

Default destructor

Member Function Documentation

◆ clone()

◆ getConstraint1()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getConstraint1 ( constraint1_vector_t e)
inlinevirtual

◆ getConstraint1DerivativesControl()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getConstraint1DerivativesControl ( constraint1_input_matrix_t D)
inlinevirtual

◆ getConstraint1DerivativesEventTimes()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getConstraint1DerivativesEventTimes ( constraint1_vector_array_t g1DevArray)
inlinevirtual

calculate and retrieve the the derivative of the state-input constraints w.r.t. event times. g1DevArray[i] is a vector of dimension MAX_CONSTRAINT1_DIM_ which is the partial derivative of state-input equality constraints with respect to i'th event time.

Note that only nc1 top rows of g1DevArray[i] are valid where nc1 is the number of active state-input constraints at the current time.

If the constraints are not a function of event times either set the array size to zero (as the default) implementation or set it to an array of zero vector with a size equal to number event times.

Parameters
[out]g1DevArrayan array of nc1-by-1 vector.

◆ getConstraint1DerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getConstraint1DerivativesState ( constraint1_state_matrix_t C)
inlinevirtual

◆ getConstraint2()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getConstraint2 ( constraint2_vector_t h)
inlinevirtual

◆ getConstraint2DerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getConstraint2DerivativesState ( constraint2_state_matrix_t F)
inlinevirtual

◆ getFinalConstraint2()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getFinalConstraint2 ( constraint2_vector_t h_f)
inlinevirtual

◆ getFinalConstraint2DerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getFinalConstraint2DerivativesState ( constraint2_state_matrix_t F_f)
inlinevirtual

◆ getInequalityConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getInequalityConstraint ( scalar_array_t h)
inlinevirtual

◆ getInequalityConstraintDerivativesInput()

◆ getInequalityConstraintDerivativesInputState()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getInequalityConstraintDerivativesInputState ( input_state_matrix_array_t ddhdudx)
inlinevirtual

◆ getInequalityConstraintDerivativesState()

◆ getInequalityConstraintSecondDerivativesInput()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getInequalityConstraintSecondDerivativesInput ( input_matrix_array_t ddhdudu)
inlinevirtual

◆ getInequalityConstraintSecondDerivativesState()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::getInequalityConstraintSecondDerivativesState ( state_matrix_array_t ddhdxdx)
inlinevirtual

◆ initializeModel()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::initializeModel ( LogicRulesMachine< LOGIC_RULES_T > &  logicRulesMachine,
const size_t &  partitionIndex,
const char *  algorithmName = nullptr 
)
inlinevirtual

Initializes the system constraints.

Parameters
[in]logicRulesMachineA class which contains and parse the logic rules e.g method findActiveSubsystemHandle returns a Lambda expression which can be used to find the ID of the current active subsystem.
[in]partitionIndexindex of the time partition.
[in]algorithmNameThe algorithm that class this class (default not defined).

Reimplemented in ocs2::ConstraintBaseAD< Derived, STATE_DIM, INPUT_DIM, LOGIC_RULES_T >, and ocs2::LoopshapingConstraint< FULL_STATE_DIM, FULL_INPUT_DIM, SYSTEM_STATE_DIM, SYSTEM_INPUT_DIM, FILTER_STATE_DIM, FILTER_INPUT_DIM, LOGIC_RULES_T >.

◆ numInequalityConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::numInequalityConstraint ( const scalar_t time)
inlinevirtual

◆ numStateInputConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::numStateInputConstraint ( const scalar_t time)
inlinevirtual

◆ numStateOnlyConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::numStateOnlyConstraint ( const scalar_t time)
inlinevirtual

◆ numStateOnlyFinalConstraint()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual size_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::numStateOnlyFinalConstraint ( const scalar_t time)
inlinevirtual

◆ setCurrentStateAndControl()

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
virtual void ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::setCurrentStateAndControl ( const scalar_t t,
const state_vector_t x,
const input_vector_t u 
)
inlinevirtual

Member Data Documentation

◆ EIGEN_MAKE_ALIGNED_OPERATOR_NEW

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::EIGEN_MAKE_ALIGNED_OPERATOR_NEW

◆ t_

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
scalar_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::t_
protected

◆ u_

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
input_vector_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::u_
protected

◆ x_

template<size_t STATE_DIM, size_t INPUT_DIM, class LOGIC_RULES_T = NullLogicRules>
state_vector_t ocs2::ConstraintBase< STATE_DIM, INPUT_DIM, LOGIC_RULES_T >::x_
protected

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