- 3.0.2 optimal control module.
LinearConstraintContainer.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 
9 
10 namespace ct {
11 namespace optcon {
12 
13 
26 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR = double>
27 class LinearConstraintContainer : public ConstraintContainerBase<STATE_DIM, CONTROL_DIM, SCALAR>
28 {
29 public:
30  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31 
34 
36  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> VectorXs;
37  typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic> MatrixXs;
38 
43 
44 
56 
61  virtual LinearConstraintContainer_Raw_Ptr_t clone() const = 0;
62 
69  virtual VectorXs jacobianStateSparseIntermediate() = 0;
70 
76  virtual MatrixXs jacobianStateIntermediate() = 0;
77 
84  virtual VectorXs jacobianStateSparseTerminal() = 0;
85 
91  virtual MatrixXs jacobianStateTerminal() = 0;
92 
99  virtual VectorXs jacobianInputSparseIntermediate() = 0;
100 
106  virtual MatrixXs jacobianInputIntermediate() = 0;
107 
114  virtual VectorXs jacobianInputSparseTerminal() = 0;
115 
121  virtual MatrixXs jacobianInputTerminal() = 0;
122 
133  virtual void sparsityPatternStateIntermediate(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) = 0;
134 
145  virtual void sparsityPatternStateTerminal(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) = 0;
146 
157  virtual void sparsityPatternInputIntermediate(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) = 0;
158 
169  virtual void sparsityPatternInputTerminal(Eigen::VectorXi& iRows, Eigen::VectorXi& jCols) = 0;
170 
176  virtual size_t getJacobianStateNonZeroCountIntermediate() = 0;
177 
183  virtual size_t getJacobianStateNonZeroCountTerminal() = 0;
184 
190  virtual size_t getJacobianInputNonZeroCountIntermediate() = 0;
191 
197  virtual size_t getJacobianInputNonZeroCountTerminal() = 0;
198 
205  size_t getJacNonZeroCount();
209  void initialize();
210 
216  virtual bool initializeIntermediate() = 0;
217 
223  virtual bool initializeTerminal() = 0;
224 
230  bool isInitialized();
231 
235  void printout();
236 
237 protected:
240 };
241 
242 } // namespace optcon
243 } // namespace ct
virtual LinearConstraintContainer_Raw_Ptr_t clone() const =0
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Definition: LinearConstraintContainer.h:37
void initialize()
Initializes the constraint container.
Definition: LinearConstraintContainer-impl.h:39
virtual size_t getJacobianStateNonZeroCountTerminal()=0
Returns the number of non zero elements in the constraint jacobian wrt state.
A base function for linear constraint functions which have a first derivative.
Definition: LinearConstraintContainer.h:27
virtual ~LinearConstraintContainer()
Destructor.
Definition: LinearConstraintContainer-impl.h:27
virtual VectorXs jacobianStateSparseTerminal()=0
Evaluates the constraint jacobian wrt the state using sparse representation.
virtual VectorXs jacobianStateSparseIntermediate()=0
Evaluates the constraint jacobian wrt the state using sparse representation.
bool initializedIntermediate_
Definition: LinearConstraintContainer.h:238
virtual VectorXs jacobianInputSparseTerminal()=0
Evaluates the constraint jacobian wrt the control input using sparse representation.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: LinearConstraintContainer.h:32
virtual size_t getJacobianInputNonZeroCountTerminal()=0
Returns the number of non zero elements in the constraint jacobian wrt input.
virtual MatrixXs jacobianStateTerminal()=0
Evaluates the constraint jacobian wrt the state.
virtual VectorXs jacobianInputSparseIntermediate()=0
Evaluates the constraint jacobian wrt the control input using sparse representation.
bool isInitialized()
Checks if the constraint container is initialized.
Definition: LinearConstraintContainer-impl.h:46
virtual bool initializeTerminal()=0
Initializes the terminal constraints.
LinearConstraintContainer< STATE_DIM, CONTROL_DIM, SCALAR > * LinearConstraintContainer_Raw_Ptr_t
Definition: LinearConstraintContainer.h:35
virtual MatrixXs jacobianInputIntermediate()=0
Evaluates the constraint jacobian wrt the control input.
bool initializedTerminal_
Definition: LinearConstraintContainer.h:239
virtual size_t getJacobianStateNonZeroCountIntermediate()=0
Returns the number of non zero elements in the constraint jacobian wrt state.
LinearConstraintContainer()
Default constructor.
Definition: LinearConstraintContainer-impl.h:12
virtual void sparsityPatternInputIntermediate(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols)=0
Returns the sparsity pattern for the jacobian wrt control.
The ConstraintBase Class is the base class for defining the non-linear optimization constraints...
Definition: ConstraintContainerBase.h:31
virtual void sparsityPatternStateTerminal(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols)=0
Returns the sparsity pattern for the jacobian wrt state.
virtual void sparsityPatternStateIntermediate(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols)=0
Returns the sparsity pattern for the jacobian wrt state.
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: LinearConstraintContainer.h:36
virtual MatrixXs jacobianInputTerminal()=0
Evaluates the constraint jacobian wrt the control input.
virtual size_t getJacobianInputNonZeroCountIntermediate()=0
Returns the number of non zero elements in the constraint jacobian wrt input.
core::ControlVector< CONTROL_DIM, SCALAR > input_vector_t
Definition: LinearConstraintContainer.h:33
size_t getJacNonZeroCount()
Returns the number of non zeros in the constraint jacobian wrt to state and input.
Definition: LinearConstraintContainer-impl.h:32
void printout()
Print out sparsity patterns, jacobians, etc. Serves for quick visual inspection.
Definition: LinearConstraintContainer-impl.h:52
virtual bool initializeIntermediate()=0
Initializes the intermediate constraints.
virtual MatrixXs jacobianStateIntermediate()=0
Evaluates the constraint jacobian wrt the state.
virtual void sparsityPatternInputTerminal(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols)=0
Returns the sparsity pattern for the jacobian wrt control.