14 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
16 std::shared_ptr<Backend_t>& backend_,
22 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
28 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
32 this->
backend_->setInitialGuess(initialGuess);
35 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
43 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
46 if (!this->
backend_->isInitialized())
47 throw std::runtime_error(
"SingleShooting is not initialized!");
50 throw std::runtime_error(
"SingleShooting is not configured!");
55 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
58 int K = this->
backend_->getNumSteps();
60 bool debugPrint = this->
backend_->getSettings().debugPrint;
63 if (this->
backend_->iteration() == 0)
65 if (!this->
backend_->nominalRollout())
66 throw std::runtime_error(
"Rollout failed. System became unstable");
71 #ifdef MATLAB_FULL_LOG 72 if (this->
backend_->iteration() == 0)
76 auto start = std::chrono::steady_clock::now();
77 auto startEntire = start;
80 this->
backend_->setInputBoxConstraintsForLQOCProblem();
81 this->
backend_->setStateBoxConstraintsForLQOCProblem();
82 this->
backend_->computeLQApproximation(0, K - 1);
83 auto end = std::chrono::steady_clock::now();
84 auto diff = end - start;
86 std::cout <<
"[SingleShooting]: Computing LQ approximation took " 87 << std::chrono::duration<double, std::milli>(diff).count() <<
" ms" << std::endl;
89 end = std::chrono::steady_clock::now();
90 diff = end - startEntire;
92 std::cout <<
"[SingleShooting]: Forward pass took " << std::chrono::duration<double, std::milli>(diff).count()
93 <<
" ms" << std::endl;
96 std::cout <<
"[SingleShooting]: #2 Solve LQOC Problem" << std::endl;
98 start = std::chrono::steady_clock::now();
99 this->
backend_->solveFullLQProblem();
101 end = std::chrono::steady_clock::now();
104 std::cout <<
"[SingleShooting]: Solving LQOC problem took " 105 << std::chrono::duration<double, std::milli>(diff).count() <<
" ms" << std::endl;
109 std::cout <<
"[SingleShooting]: #3 LineSearch" << std::endl;
111 start = std::chrono::steady_clock::now();
112 bool foundBetter = this->
backend_->lineSearch();
113 end = std::chrono::steady_clock::now();
116 std::cout <<
"[SingleShooting]: Line search took " << std::chrono::duration<double, std::milli>(diff).count()
117 <<
" ms" << std::endl;
119 diff = end - startEntire;
121 std::cout <<
"[SingleShooting]: finishIteration took " 122 << std::chrono::duration<double, std::milli>(diff).count() <<
" ms" << std::endl;
126 #ifdef MATLAB_FULL_LOG 135 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
141 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
Definition: NLOCAlgorithm.hpp:19
virtual void configure(const Settings_t &settings) override
configure the solver
Definition: SingleShooting-impl.hpp:23
virtual bool runIteration() override
runIteration combines prepareIteration and finishIteration
Definition: SingleShooting-impl.hpp:36
SingleShooting(std::shared_ptr< Backend_t > &backend_, const Settings_t &settings)
constructor
Definition: SingleShooting-impl.hpp:15
std::shared_ptr< Backend_t > backend_
Definition: NLOCAlgorithm.hpp:47
Settings for the NLOptCon algorithm.
Definition: NLOptConSettings.hpp:198
virtual bool finishMPCIteration() override
Definition: SingleShooting-impl.hpp:142
virtual void prepareIteration() override
Definition: SingleShooting-impl.hpp:44
virtual void prepareMPCIteration() override
Definition: SingleShooting-impl.hpp:136
virtual bool finishIteration() override
Definition: SingleShooting-impl.hpp:56
Base::Policy_t Policy_t
Definition: SingleShooting.hpp:31
virtual void setInitialGuess(const Policy_t &initialGuess) override
set an initial guess
Definition: SingleShooting-impl.hpp:29