- 3.0.2 optimal control module.
ConstraintsContainerDms-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 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
7 ConstraintsContainerDms<STATE_DIM, CONTROL_DIM, SCALAR>::ConstraintsContainerDms(
8  std::shared_ptr<OptVectorDms<STATE_DIM, CONTROL_DIM, SCALAR>> w,
9  std::shared_ptr<tpl::TimeGrid<SCALAR>> timeGrid,
10  std::vector<std::shared_ptr<ShotContainer<STATE_DIM, CONTROL_DIM, SCALAR>>> shotContainers,
11  std::shared_ptr<ConstraintDiscretizer<STATE_DIM, CONTROL_DIM, SCALAR>> discretizedConstraints,
12  const state_vector_t& x0,
13  const DmsSettings settings)
14  : settings_(settings), shotContainers_(shotContainers)
15 {
16  c_init_ = std::shared_ptr<InitStateConstraint<STATE_DIM, CONTROL_DIM, SCALAR>>(
17  new InitStateConstraint<STATE_DIM, CONTROL_DIM, SCALAR>(x0, w));
18 
19  this->constraints_.push_back(c_init_);
20 
21  for (size_t shotNr = 0; shotNr < settings_.N_; shotNr++)
22  {
23  std::shared_ptr<ContinuityConstraint<STATE_DIM, CONTROL_DIM, SCALAR>> c_i =
24  std::shared_ptr<ContinuityConstraint<STATE_DIM, CONTROL_DIM, SCALAR>>(
25  new ContinuityConstraint<STATE_DIM, CONTROL_DIM, SCALAR>(shotContainers[shotNr], w, shotNr, settings));
26 
27  this->constraints_.push_back(c_i);
28  }
29 
30  if (discretizedConstraints)
31  {
32  std::cout << "Adding discretized constraints" << std::endl;
33  this->constraints_.push_back(discretizedConstraints);
34  }
35 }
36 
37 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
39 {
40 #pragma omp parallel for num_threads(settings_.nThreads_)
41  for (auto shotContainer = shotContainers_.begin(); shotContainer < shotContainers_.end(); ++shotContainer)
42  {
43  (*shotContainer)->integrateShot();
44  }
45 }
46 
47 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
49 {
50 #pragma omp parallel for num_threads(settings_.nThreads_)
51  for (auto shotContainer = shotContainers_.begin(); shotContainer < shotContainers_.end(); ++shotContainer)
52  {
53  (*shotContainer)->integrateSensitivities();
54  }
55 }
56 
57 template <size_t STATE_DIM, size_t CONTROL_DIM, typename SCALAR>
59 {
60  c_init_->updateConstraint(x0);
61 }
void changeInitialConstraint(const state_vector_t &x0)
Updates the initial constraint.
Definition: ConstraintsContainerDms.h:59
void prepareEvaluation() override
Gets called before the constraint evaluation. This method should contain all the calculations needed ...
Definition: ConstraintsContainerDms.h:39
size_t N_
Definition: DmsSettings.h:51
void prepareJacobianEvaluation() override
Gets called before the constraint jacobian evaluation. This method should contain all the calculation...
Definition: ConstraintsContainerDms.h:49
StateVector< state_dim > x0
Definition: ConstrainedNLOCTest.cpp:14
Eigen::Matrix< double, nStates, 1 > state_vector_t