- 3.0.2 optimal control module.
SwitchedLinearConstraintContainer.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include <ct/core/core.h>
10 
11 namespace ct {
12 namespace optcon {
13 
14 
26 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
27 class SwitchedLinearConstraintContainer : public LinearConstraintContainer<STATE_DIM, CONTROL_DIM, SCALAR>
28 {
29 public:
30  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31 
34 
37  typedef std::shared_ptr<LinearConstraintContainer<STATE_DIM, CONTROL_DIM, SCALAR>> LinearConstraintContainer_Ptr_t;
39  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> VectorXs;
40  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> MatrixXs;
41 
43 
47  SwitchedLinearConstraintContainer(const SwitchedLinearConstraintContainers& switchedLinearConstraintContainers,
48  const ModeSequence_t& continuousModeSequence);
49 
50 
62 
67  virtual SwitchedLinearConstraintContainer_Raw_Ptr_t clone() const override;
68 
69  virtual VectorXs evaluateIntermediate() override;
70 
71  virtual VectorXs evaluateTerminal() override;
72 
73  virtual size_t getIntermediateConstraintsCount() override;
74 
75  virtual size_t getTerminalConstraintsCount() override;
76 
77  virtual VectorXs jacobianStateSparseIntermediate() override;
78 
79  virtual MatrixXs jacobianStateIntermediate() override;
80 
81  virtual VectorXs jacobianStateSparseTerminal() override;
82 
83  virtual MatrixXs jacobianStateTerminal() override;
84 
85  virtual VectorXs jacobianInputSparseIntermediate() override;
86 
87  virtual MatrixXs jacobianInputIntermediate() override;
88 
89  virtual VectorXs jacobianInputSparseTerminal() override;
90 
91  virtual MatrixXs jacobianInputTerminal() override;
92 
93  virtual void sparsityPatternStateIntermediate(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) override;
94 
95  virtual void sparsityPatternStateTerminal(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) override;
96 
97  virtual void sparsityPatternInputIntermediate(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) override;
98 
99  virtual void sparsityPatternInputTerminal(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) override;
100 
101  virtual size_t getJacobianStateNonZeroCountIntermediate() override;
102 
103  virtual size_t getJacobianStateNonZeroCountTerminal() override;
104 
105  virtual size_t getJacobianInputNonZeroCountIntermediate() override;
106 
107  virtual size_t getJacobianInputNonZeroCountTerminal() override;
108 
109  virtual bool initializeIntermediate() override;
110 
111  virtual bool initializeTerminal() override;
112 
113 private:
114  virtual void update() override;
115 
116  SwitchedLinearConstraintContainers switchedLinearConstraintContainers_;
117  ModeSequence_t continuousModeSequence_;
118  LinearConstraintContainer_Ptr_t activeLinearConstraintContainer_;
119  LinearConstraintContainer_Ptr_t terminalLinearConstraintContainer_;
120 };
121 
122 } // namespace optcon
123 } // namespace ct
std::vector< T, Alloc > Switched
virtual SwitchedLinearConstraintContainer_Raw_Ptr_t clone() const override
Definition: SwitchedLinearConstraintContainer-impl.h:47
virtual MatrixXs jacobianInputTerminal() override
Evaluates the constraint jacobian wrt the control input.
Definition: SwitchedLinearConstraintContainer-impl.h:129
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: SwitchedLinearConstraintContainer.h:32
virtual VectorXs jacobianInputSparseIntermediate() override
Evaluates the constraint jacobian wrt the control input using sparse representation.
Definition: SwitchedLinearConstraintContainer-impl.h:108
virtual void sparsityPatternStateTerminal(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols) override
Returns the sparsity pattern for the jacobian wrt state.
Definition: SwitchedLinearConstraintContainer-impl.h:143
virtual size_t getTerminalConstraintsCount() override
Retrieves the number of final constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:73
A base function for linear constraint functions which have a first derivative.
Definition: LinearConstraintContainer.h:27
A container for switching linear constraint containers.
Definition: SwitchedLinearConstraintContainer.h:27
virtual VectorXs jacobianInputSparseTerminal() override
Evaluates the constraint jacobian wrt the control input using sparse representation.
Definition: SwitchedLinearConstraintContainer-impl.h:122
virtual VectorXs jacobianStateSparseIntermediate() override
Evaluates the constraint jacobian wrt the state using sparse representation.
Definition: SwitchedLinearConstraintContainer-impl.h:80
virtual MatrixXs jacobianStateTerminal() override
Evaluates the constraint jacobian wrt the state.
Definition: SwitchedLinearConstraintContainer-impl.h:101
virtual size_t getJacobianStateNonZeroCountTerminal() override
Returns the number of non zero elements in the constraint jacobian wrt state.
Definition: SwitchedLinearConstraintContainer-impl.h:173
virtual bool initializeTerminal() override
Initializes the terminal constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:207
virtual size_t getIntermediateConstraintsCount() override
Retrieves the number of intermediate constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:67
core::Switched< LinearConstraintContainer_Ptr_t > SwitchedLinearConstraintContainers
Definition: SwitchedLinearConstraintContainer.h:38
virtual void sparsityPatternInputTerminal(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols) override
Returns the sparsity pattern for the jacobian wrt control.
Definition: SwitchedLinearConstraintContainer-impl.h:159
std::shared_ptr< LinearConstraintContainer< STATE_DIM, CONTROL_DIM, SCALAR > > LinearConstraintContainer_Ptr_t
Definition: SwitchedLinearConstraintContainer.h:37
virtual MatrixXs jacobianInputIntermediate() override
Evaluates the constraint jacobian wrt the control input.
Definition: SwitchedLinearConstraintContainer-impl.h:115
virtual VectorXs evaluateTerminal() override
Evaluates the terminal constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:61
virtual size_t getJacobianStateNonZeroCountIntermediate() override
Returns the number of non zero elements in the constraint jacobian wrt state.
Definition: SwitchedLinearConstraintContainer-impl.h:167
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Definition: SwitchedLinearConstraintContainer.h:40
SwitchedLinearConstraintContainer(const SwitchedLinearConstraintContainers &switchedLinearConstraintContainers, const ModeSequence_t &continuousModeSequence)
Default constructor.
Definition: SwitchedLinearConstraintContainer-impl.h:12
core::ControlVector< CONTROL_DIM, SCALAR > input_vector_t
Definition: SwitchedLinearConstraintContainer.h:33
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: SwitchedLinearConstraintContainer.h:39
virtual void sparsityPatternInputIntermediate(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols) override
Returns the sparsity pattern for the jacobian wrt control.
Definition: SwitchedLinearConstraintContainer-impl.h:151
core::PhaseSequence< std::size_t, SCALAR > ModeSequence_t
Definition: SwitchedLinearConstraintContainer.h:42
virtual VectorXs evaluateIntermediate() override
Evaluates the intermediate constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:54
virtual VectorXs jacobianStateSparseTerminal() override
Evaluates the constraint jacobian wrt the state using sparse representation.
Definition: SwitchedLinearConstraintContainer-impl.h:94
virtual ~SwitchedLinearConstraintContainer()
Destructor.
Definition: SwitchedLinearConstraintContainer-impl.h:41
virtual size_t getJacobianInputNonZeroCountTerminal() override
Returns the number of non zero elements in the constraint jacobian wrt input.
Definition: SwitchedLinearConstraintContainer-impl.h:185
virtual MatrixXs jacobianStateIntermediate() override
Evaluates the constraint jacobian wrt the state.
Definition: SwitchedLinearConstraintContainer-impl.h:87
virtual void sparsityPatternStateIntermediate(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols) override
Returns the sparsity pattern for the jacobian wrt state.
Definition: SwitchedLinearConstraintContainer-impl.h:135
SwitchedLinearConstraintContainer< STATE_DIM, CONTROL_DIM, SCALAR > * SwitchedLinearConstraintContainer_Raw_Ptr_t
Definition: SwitchedLinearConstraintContainer.h:36
virtual size_t getJacobianInputNonZeroCountIntermediate() override
Returns the number of non zero elements in the constraint jacobian wrt input.
Definition: SwitchedLinearConstraintContainer-impl.h:179
virtual bool initializeIntermediate() override
Initializes the intermediate constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:191