- 3.0.2 optimal control module.
LinearConstraintContainer-impl.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 namespace ct {
9 namespace optcon {
10 
11 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
13  : initializedIntermediate_(false), initializedTerminal_(false)
14 {
15 }
16 
17 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
19  const LinearConstraintContainer& arg)
20  : ConstraintContainerBase<STATE_DIM, CONTROL_DIM, SCALAR>(arg),
23 {
24 }
25 
26 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
28 {
29 }
30 
31 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
33 {
36 }
37 
38 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
40 {
43 }
44 
45 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
47 {
49 }
50 
51 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
53 {
54  Eigen::VectorXi iRows, jCols; // local var
55 
56  std::cout << std::endl;
57 
58  std::cout << "LinearConstraintContainer - Printout INTERMEDIATE STAGE" << std::endl;
59 
60  std::cout << "getLowerBoundsIntermediate().transpose() :" << std::endl;
61  std::cout << this->getLowerBoundsIntermediate().transpose() << std::endl;
62 
63  std::cout << "getUpperBoundsIntermediate().transpose() :" << std::endl;
64  std::cout << this->getUpperBoundsIntermediate().transpose() << std::endl;
65 
66  std::cout << "getJacobianStateNonZeroCountIntermediate() :" << std::endl;
67  std::cout << getJacobianStateNonZeroCountIntermediate() << std::endl;
68 
69  std::cout << "getJacobianInputNonZeroCountIntermediate() :" << std::endl;
70  std::cout << getJacobianInputNonZeroCountIntermediate() << std::endl;
71 
72  std::cout << "jacobianStateIntermediate() :" << std::endl;
73  std::cout << jacobianStateIntermediate() << std::endl;
74 
75  std::cout << "jacobianStateSparseIntermediate() :" << std::endl;
76  std::cout << jacobianStateSparseIntermediate() << std::endl;
77 
78  std::cout << "jacobianInputIntermediate() :" << std::endl;
79  std::cout << jacobianInputIntermediate() << std::endl;
80 
81  std::cout << "jacobianInputSparseIntermediate() :" << std::endl;
82  std::cout << jacobianInputSparseIntermediate() << std::endl;
83 
84  std::cout << "sparsityPatternStateIntermediate(iRows, jCols) :" << std::endl;
86  std::cout << "iRows: " << iRows.transpose() << std::endl;
87  std::cout << "jCols: " << jCols.transpose() << std::endl;
88 
89  std::cout << "sparsityPatternInputIntermediate(iRows, jCols) :" << std::endl;
91  std::cout << "iRows: " << iRows.transpose() << std::endl;
92  std::cout << "jCols: " << jCols.transpose() << std::endl;
93 
94 
95  std::cout << "LinearConstraintContainer - Printout TERMINAL STAGE" << std::endl;
96 
97  std::cout << "getLowerBoundsTerminal().transpose() :" << std::endl;
98  std::cout << this->getLowerBoundsTerminal().transpose() << std::endl;
99 
100  std::cout << "getUpperBoundsTerminal().transpose() :" << std::endl;
101  std::cout << this->getUpperBoundsTerminal().transpose() << std::endl;
102 
103  std::cout << "getJacobianStateNonZeroCountTerminal() :" << std::endl;
104  std::cout << getJacobianStateNonZeroCountTerminal() << std::endl;
105 
106  std::cout << "getJacobianInputNonZeroCountTerminal() :" << std::endl;
107  std::cout << getJacobianInputNonZeroCountTerminal() << std::endl;
108 
109  std::cout << "jacobianStateTerminal() :" << std::endl;
110  std::cout << jacobianStateTerminal() << std::endl;
111 
112  std::cout << "jacobianStateSparseTerminal() :" << std::endl;
113  std::cout << jacobianStateSparseTerminal() << std::endl;
114 
115  std::cout << "jacobianInputTerminal() :" << std::endl;
116  std::cout << jacobianInputTerminal() << std::endl;
117 
118  std::cout << "jacobianInputSparseTerminal() :" << std::endl;
119  std::cout << jacobianInputSparseTerminal() << std::endl;
120 
121  std::cout << "sparsityPatternStateTerminal(iRows, jCols) :" << std::endl;
122  sparsityPatternStateTerminal(iRows, jCols);
123  std::cout << "iRows: " << iRows.transpose() << std::endl;
124  std::cout << "jCols: " << jCols.transpose() << std::endl;
125 
126  std::cout << "sparsityPatternInputTerminal(iRows, jCols) :" << std::endl;
127  sparsityPatternInputTerminal(iRows, jCols);
128  std::cout << "iRows: " << iRows.transpose() << std::endl;
129  std::cout << "jCols: " << jCols.transpose() << std::endl;
130 
131  std::cout << std::endl;
132  std::cout << std::endl;
133 }
134 
135 
136 } // namespace optcon
137 } // namespace ct
VectorXs getLowerBoundsIntermediate() const
Retrieves the lower constraint bound on the intermediate constraints.
Definition: ConstraintContainerBase-impl.h:53
VectorXs getLowerBoundsTerminal() const
Retrieves the lower constraint bound on the terminal constraints.
Definition: ConstraintContainerBase-impl.h:60
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
VectorXs getUpperBoundsTerminal() const
Retrieves the upper constraint bound on the terminal constraints.
Definition: ConstraintContainerBase-impl.h:74
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.
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.
virtual MatrixXs jacobianInputIntermediate()=0
Evaluates the constraint jacobian wrt the control input.
VectorXs getUpperBoundsIntermediate() const
Retrieves the upper constraint bound on the intermediate constraints.
Definition: ConstraintContainerBase-impl.h:67
CppAD::AD< CppAD::cg::CG< double > > SCALAR
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.
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.
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.