11 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
15 : switchedLinearConstraintContainers_(switchedLinearConstraintContainers),
16 continuousModeSequence_(continuousModeSequence),
17 activeLinearConstraintContainer_(switchedLinearConstraintContainers.front()),
18 terminalLinearConstraintContainer_(switchedLinearConstraintContainers.at(continuousModeSequence.getFinalPhase()))
22 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
26 continuousModeSequence_(arg.continuousModeSequence_)
29 switchedLinearConstraintContainers_.clear();
30 for (
auto& linearConstraintContainer : arg.switchedLinearConstraintContainers_)
32 switchedLinearConstraintContainers_.emplace_back(linearConstraintContainer->clone());
35 activeLinearConstraintContainer_ = switchedLinearConstraintContainers_.front();
36 terminalLinearConstraintContainer_ =
37 switchedLinearConstraintContainers_.at(continuousModeSequence_.
getFinalPhase());
40 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
45 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
52 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
56 return activeLinearConstraintContainer_->evaluateIntermediate();
59 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
63 return terminalLinearConstraintContainer_->evaluateTerminal();
66 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
69 return activeLinearConstraintContainer_->getIntermediateConstraintsCount();
72 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
75 return terminalLinearConstraintContainer_->getTerminalConstraintsCount();
78 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
82 return activeLinearConstraintContainer_->jacobianStateSparseIntermediate();
85 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
89 return activeLinearConstraintContainer_->jacobianStateIntermediate();
92 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
96 return terminalLinearConstraintContainer_->jacobianStateSparseTerminal();
99 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
103 return terminalLinearConstraintContainer_->jacobianStateTerminal();
106 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
110 return activeLinearConstraintContainer_->jacobianInputSparseIntermediate();
113 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
117 return activeLinearConstraintContainer_->jacobianInputIntermediate();
120 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
124 return terminalLinearConstraintContainer_->jacobianInputSparseTerminal();
127 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
131 return terminalLinearConstraintContainer_->jacobianInputTerminal();
134 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
136 Eigen::VectorXi& iRows,
137 Eigen::VectorXi& jCols)
139 return activeLinearConstraintContainer_->sparsityPatternStateIntermediate(iRows, jCols);
142 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
144 Eigen::VectorXi& iRows,
145 Eigen::VectorXi& jCols)
147 return terminalLinearConstraintContainer_->sparsityPatternStateTerminal(iRows, jCols);
150 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
152 Eigen::VectorXi& iRows,
153 Eigen::VectorXi& jCols)
155 return activeLinearConstraintContainer_->sparsityPatternInputIntermediate(iRows, jCols);
158 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
160 Eigen::VectorXi& iRows,
161 Eigen::VectorXi& jCols)
163 return terminalLinearConstraintContainer_->sparsityPatternInputTerminal(iRows, jCols);
166 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
169 return activeLinearConstraintContainer_->getJacobianStateNonZeroCountIntermediate();
172 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
175 return terminalLinearConstraintContainer_->getJacobianStateNonZeroCountTerminal();
178 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
181 return activeLinearConstraintContainer_->getJacobianInputNonZeroCountIntermediate();
184 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
187 return terminalLinearConstraintContainer_->getJacobianInputNonZeroCountTerminal();
190 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
193 for (
auto linearConstraintContainer : switchedLinearConstraintContainers_)
195 linearConstraintContainer->initialize();
196 if (!linearConstraintContainer->isInitialized())
198 std::cout <<
"SwitchedLinearConstraintContainer::initializeIntermediate(): " 199 <<
"one of the constraints failed to initialize" << std::endl;
206 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
215 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
219 activeLinearConstraintContainer_ = switchedLinearConstraintContainers_.at(mode);
220 activeLinearConstraintContainer_->setCurrentStateAndControl(this->
x_, this->
u_, this->
t_);
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
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
input_vector_t u_
Definition: ConstraintContainerBase.h:198
A container for switching linear constraint containers.
Definition: SwitchedLinearConstraintContainer.h:27
VectorXs lowerBoundsTerminal_
Definition: ConstraintContainerBase.h:202
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
VectorXs upperBoundsTerminal_
Definition: ConstraintContainerBase.h:204
virtual size_t getJacobianStateNonZeroCountTerminal() override
Returns the number of non zero elements in the constraint jacobian wrt state.
Definition: SwitchedLinearConstraintContainer-impl.h:173
VectorXs lowerBoundsIntermediate_
Definition: ConstraintContainerBase.h:201
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
CppAD::AD< CppAD::cg::CG< double > > SCALAR
virtual MatrixXs jacobianInputIntermediate() override
Evaluates the constraint jacobian wrt the control input.
Definition: SwitchedLinearConstraintContainer-impl.h:115
Phase getFinalPhase() const
virtual VectorXs evaluateTerminal() override
Evaluates the terminal constraints.
Definition: SwitchedLinearConstraintContainer-impl.h:61
SCALAR t_
Definition: ConstraintContainerBase.h:199
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
VectorXs upperBoundsIntermediate_
Definition: ConstraintContainerBase.h:203
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: SwitchedLinearConstraintContainer.h:39
Phase getPhaseFromTime(Time time) const
virtual void sparsityPatternInputIntermediate(Eigen::VectorXi &iRows, Eigen::VectorXi &jCols) override
Returns the sparsity pattern for the jacobian wrt control.
Definition: SwitchedLinearConstraintContainer-impl.h:151
state_vector_t x_
Definition: ConstraintContainerBase.h:197
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
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