27 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR =
double>
31 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45 typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>
VectorXs;
46 typedef Eigen::Matrix<SCALAR, Eigen::Dynamic, Eigen::Dynamic>
MatrixXs;
64 : shotContainer_(shotContainer), w_(w), shotIndex_(shotIndex), settings_(settings)
66 lb_.setConstant(
SCALAR(0.0));
67 ub_.setConstant(
SCALAR(0.0));
75 nr = STATE_DIM * STATE_DIM + STATE_DIM * CONTROL_DIM + STATE_DIM;
80 nr = STATE_DIM * STATE_DIM + STATE_DIM * CONTROL_DIM + STATE_DIM + STATE_DIM * CONTROL_DIM;
85 throw(std::runtime_error(
"specified invalid spliner type in ContinuityConstraint-class"));
95 VectorXs
eval()
override {
return w_->getOptimizedState(shotIndex_ + 1) - shotContainer_->getStateIntegrated(); }
122 throw(std::runtime_error(
"specified invalid spliner type in ContinuityConstraint-class"));
135 no = STATE_DIM * STATE_DIM + STATE_DIM * CONTROL_DIM + STATE_DIM * 1;
140 no = STATE_DIM * STATE_DIM + STATE_DIM * CONTROL_DIM + STATE_DIM * 1 + STATE_DIM * CONTROL_DIM;
145 throw(std::runtime_error(
"specified invalid spliner type in ContinuityConstraint-class"));
161 size_t indexNumber = 0;
168 indexNumber += BASE::genBlockIndices(
169 w_->getStateIndex(shotIndex_), STATE_DIM, STATE_DIM, iRow_vec, jCol_vec, indexNumber);
172 indexNumber += BASE::genBlockIndices(
173 w_->getControlIndex(shotIndex_), STATE_DIM, CONTROL_DIM, iRow_vec, jCol_vec, indexNumber);
176 indexNumber += BASE::genDiagonalIndices(
177 w_->getStateIndex(shotIndex_ + 1), STATE_DIM, iRow_vec, jCol_vec, indexNumber);
183 indexNumber += BASE::genBlockIndices(
184 w_->getStateIndex(shotIndex_), STATE_DIM, STATE_DIM, iRow_vec, jCol_vec, indexNumber);
187 indexNumber += BASE::genBlockIndices(
188 w_->getControlIndex(shotIndex_), STATE_DIM, CONTROL_DIM, iRow_vec, jCol_vec, indexNumber);
191 indexNumber += BASE::genDiagonalIndices(
192 w_->getStateIndex(shotIndex_ + 1), STATE_DIM, iRow_vec, jCol_vec, indexNumber);
195 indexNumber += BASE::genBlockIndices(
196 w_->getControlIndex(shotIndex_ + 1), STATE_DIM, CONTROL_DIM, iRow_vec, jCol_vec, indexNumber);
201 throw(std::runtime_error(
"specified invalid spliner type in ContinuityConstraint-class"));
221 void computeXblock();
227 void computeUblock();
233 void computeUblock_2();
238 void computeIblock();
244 void computeHblock();
246 std::shared_ptr<ShotContainer<STATE_DIM, CONTROL_DIM, SCALAR>> shotContainer_;
247 std::shared_ptr<OptVectorDms<STATE_DIM, CONTROL_DIM, SCALAR>> w_;
294 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
298 mat.transposeInPlace();
299 VectorXs dXdSiVec = (Eigen::Map<VectorXs>(mat.data(), STATE_DIM * STATE_DIM));
302 jacLocal_.segment(count_local_, STATE_DIM * STATE_DIM) = dXdSiVec;
304 count_local_ += STATE_DIM * STATE_DIM;
308 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
311 MatrixXs mat = -shotContainer_->getdXdQiIntegrated();
312 mat.transposeInPlace();
313 VectorXs dXdQiVec = Eigen::Map<VectorXs>(mat.data(), STATE_DIM * CONTROL_DIM);
316 jacLocal_.segment(count_local_, STATE_DIM * CONTROL_DIM) = dXdQiVec;
317 count_local_ += STATE_DIM * CONTROL_DIM;
321 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
324 MatrixXs mat = -shotContainer_->getdXdQip1Integrated();
325 mat.transposeInPlace();
326 VectorXs dXdU1Vec = Eigen::Map<VectorXs>(mat.data(), STATE_DIM * CONTROL_DIM);
329 jacLocal_.segment(count_local_, STATE_DIM * CONTROL_DIM) = dXdU1Vec;
330 count_local_ += STATE_DIM * CONTROL_DIM;
333 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
typename SCALAR>
337 jacLocal_.segment(count_local_, STATE_DIM) = VectorXs::Ones(STATE_DIM);
338 count_local_ += STATE_DIM;
VectorXs getLowerBound() override
Returns the lower bound of the constraint.
Definition: ContinuityConstraint.h:213
VectorXs getUpperBound() override
Returns the upper bound of the constraint.
Definition: ContinuityConstraint.h:214
VectorXs eval() override
Evaluates the constraint violation.
Definition: ContinuityConstraint.h:95
Definition: DmsSettings.h:26
Implementation of the DMS continuity constraints.
Definition: ContinuityConstraint.h:28
DIMENSIONS::state_control_matrix_array_t state_control_matrix_array_t
Definition: ContinuityConstraint.h:43
DIMENSIONS::control_vector_array_t control_vector_array_t
Definition: ContinuityConstraint.h:38
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ct::core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: DmsDimensions.h:23
VectorXs evalSparseJacobian() override
Returns the non zero elements of the eval method with respect to the optimization variables...
Definition: ContinuityConstraint.h:96
Implements an abstract base class from which all the discrete custom NLP constraints should derive...
Definition: DiscreteConstraintBase.h:21
This class is a wrapper around the NLP Optvector. It wraps the Vectors from the NLP solvers into stat...
Definition: OptVectorDms.h:37
DIMENSIONS::control_vector_t control_vector_t
Definition: ContinuityConstraint.h:37
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > VectorXs
Definition: ContinuityConstraint.h:45
This class performs the state and the sensitivity integration on a shot.
Definition: ShotContainer.h:32
Definition: DmsSettings.h:26
DIMENSIONS::state_matrix_array_t state_matrix_array_t
Definition: ContinuityConstraint.h:42
CppAD::AD< CppAD::cg::CG< double > > SCALAR
size_t getNumNonZerosJacobian() override
Returns the number of non zero elements of the jacobian.
Definition: ContinuityConstraint.h:128
Defines basic types used in the DMS algorithm.
Definition: DmsDimensions.h:18
DmsDimensions< STATE_DIM, CONTROL_DIM, SCALAR > DIMENSIONS
Definition: ContinuityConstraint.h:34
DIMENSIONS::state_vector_t state_vector_t
Definition: ContinuityConstraint.h:36
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef tpl::DiscreteConstraintBase< SCALAR > BASE
Definition: ContinuityConstraint.h:33
Eigen::Matrix< SCALAR, STATE_DIM, STATE_DIM > state_matrix_t
Definition: DmsDimensions.h:26
DIMENSIONS::state_matrix_t state_matrix_t
Definition: ContinuityConstraint.h:41
SplineType_t splineType_
Definition: DmsSettings.h:54
ContinuityConstraint(std::shared_ptr< ShotContainer< STATE_DIM, CONTROL_DIM, SCALAR >> shotContainer, std::shared_ptr< OptVectorDms< STATE_DIM, CONTROL_DIM, SCALAR >> w, size_t shotIndex, const DmsSettings settings)
Custom constructor.
Definition: ContinuityConstraint.h:60
DIMENSIONS::time_array_t time_array_t
Definition: ContinuityConstraint.h:39
Defines the DMS settings.
Definition: DmsSettings.h:23
void genSparsityPattern(Eigen::VectorXi &iRow_vec, Eigen::VectorXi &jCol_vec) override
Returns the sparsity structure of the constraint jacobian.
Definition: ContinuityConstraint.h:159
size_t getConstraintSize() override
Returns size of the constraint vector.
Definition: ContinuityConstraint.h:215
ContinuityConstraint()=default
Default constructor.
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Definition: ContinuityConstraint.h:46