12 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
16 :
NLOCBackendBase(createSystemInterface(optConProblem, settings), settings)
20 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
23 const std::string& settingsFile,
25 const std::string& ns)
30 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
60 Eigen::initParallel();
86 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
89 const std::string& settingsFile,
91 const std::string& ns)
96 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
101 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
102 template <
typename T>
103 typename std::enable_if<std::is_same<T, ContinuousOptConProblem<STATE_DIM, CONTROL_DIM, SCALAR>>::value,
113 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
114 template <
typename T>
115 typename std::enable_if<std::is_same<T, DiscreteOptConProblem<STATE_DIM, CONTROL_DIM, SCALAR>>::value,
125 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
129 if (initialGuess.
x_ref().size() < (size_t)
K_ + 1)
131 std::cout <<
"Initial state guess length too short. Received length " << initialGuess.
x_ref().size()
132 <<
", expected " <<
K_ + 1 << std::endl;
133 throw(std::runtime_error(
"initial state guess to short"));
136 if (initialGuess.
uff().size() < (size_t)
K_)
138 std::cout <<
"Initial control guess length too short. Received length " << initialGuess.
uff().size()
139 <<
", expected " <<
K_ << std::endl;
140 throw std::runtime_error(
"initial control guess to short");
143 if (initialGuess.
K().size() < (size_t)
K_)
145 std::cout <<
"Initial feedback length too short. Received length " << initialGuess.
K().size() <<
", expected " 147 throw std::runtime_error(
"initial control guess to short");
151 L_ = initialGuess.
K();
156 if (
x_.size() > (size_t)
K_ + 1)
158 std::cout <<
"Warning, initial state guess too long. Received length " <<
x_.size() <<
", expected " <<
K_ + 1
159 <<
", will truncate" << std::endl;
165 std::cout <<
"Warning, initial control guess too long. Received length " <<
u_ff_.size() <<
", expected " <<
K_ 166 <<
", will truncate" << std::endl;
170 if (
L_.size() > (size_t)
K_)
172 std::cout <<
"Warning, initial feedback guess too long. Received length " <<
L_.size() <<
", expected " <<
K_ 173 <<
", will truncate" << std::endl;
189 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
196 throw std::runtime_error(
"negative or zero time steps specified");
228 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
232 throw std::runtime_error(
"negative time horizon specified");
237 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
248 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
250 const typename OptConProblem_t::CostFunctionPtr_t& cf)
253 throw std::runtime_error(
"cost function is nullptr");
260 costFunctions_[
i] =
typename OptConProblem_t::CostFunctionPtr_t(cf->clone());
269 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
271 const typename OptConProblem_t::DynamicsPtr_t& dyn)
276 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
278 const typename OptConProblem_t::ConstraintPtr_t& con)
281 throw std::runtime_error(
"NLOCBackendBase: box constraint is nullptr");
298 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
300 const typename OptConProblem_t::ConstraintPtr_t& con)
303 throw std::runtime_error(
"NLOCBackendBase: box constraint is nullptr");
321 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
323 const typename OptConProblem_t::ConstraintPtr_t& con)
326 throw std::runtime_error(
"NLOCBackendBase: general constraint is nullptr");
337 for (
int i = 0;
i <
K_;
i++)
363 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
365 const typename OptConProblem_t::LinearPtr_t& lin)
370 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
374 throw std::runtime_error(
"Time horizon too small resulting in 0 steps");
378 std::cout <<
"Provided initial feed forward controller too short, should be at least " <<
K_ <<
" but is " 379 <<
u_ff_.size() <<
" long." << std::endl;
380 throw(std::runtime_error(
"Provided initial feed forward controller too short"));
384 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
389 throw(std::runtime_error(
"Settings are incorrect. Aborting."));
394 throw(std::runtime_error(
"Number of threads cannot be changed after instance has been created."));
400 if (settings.
lqocp_solver == NLOptConSettings::LQOCP_SOLVER::GNRICCATI_SOLVER)
402 lqocSolver_ = std::shared_ptr<GNRiccatiSolver<STATE_DIM, CONTROL_DIM, SCALAR>>(
405 else if (settings.
lqocp_solver == NLOptConSettings::LQOCP_SOLVER::HPIPM_SOLVER)
409 std::shared_ptr<HPIPMInterface<STATE_DIM, CONTROL_DIM>>(
new HPIPMInterface<STATE_DIM, CONTROL_DIM>());
411 throw std::runtime_error(
"HPIPM selected but not built.");
415 throw std::runtime_error(
"Solver for Linear Quadratic Optimal Control Problem wrongly specified.");
421 #ifdef DEBUG_PRINT_MP 422 std::cout <<
"[MP] Eigen using " << Eigen::nbThreads() <<
" threads." << std::endl;
435 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
444 std::atomic_bool* terminationFlag)
const 446 const int K_local =
K_;
448 if (u_local.size() < (size_t)
K_)
449 throw std::runtime_error(
"rolloutSingleShot: u_local is too short.");
450 if (x_local.size() < (size_t)
K_ + 1)
451 throw std::runtime_error(
"rolloutSingleShot: x_local is too short.");
452 if (xShot.size() < (size_t)
K_ + 1)
453 throw std::runtime_error(
"rolloutSingleShot: xShot is too short.");
455 xShot[k] = x_local[k];
459 if (K_stop > K_local)
463 for (
int i = (
int)k;
i < K_stop;
i++)
465 if (terminationFlag && *terminationFlag)
470 xShot[
i] = xShot[
i - 1];
474 u_local[
i] +=
L_[
i] * (xShot[
i] - x_ref_lqr_local[
i]);
479 x_local[
i] = xShot[i - 1];
483 systemInterface_->propagateControlledDynamics(xShot[i], i, u_local[i], stateNext, threadId);
484 xShot[
i] = stateNext;
486 if (i == K_local - 1)
487 x_local[K_local] = xShot[K_local - 1];
491 for (
size_t j = 0; j < STATE_DIM; j++)
493 if (std::isnan(x_local[i](j)))
495 x_local.resize(K_local + 1,
497 u_local.resize(K_local,
502 for (
size_t j = 0; j < CONTROL_DIM; j++)
504 if (std::isnan(u_local[i](j)))
506 x_local.resize(K_local + 1,
508 u_local.resize(K_local,
510 std::cout <<
"control unstable" << std::endl;
523 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
535 std::atomic_bool* terminationFlag)
const 544 threadId, k, u_ff_local, x_local, x_ref_lqr, xShot, substepsX, substepsU, terminationFlag);
555 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
566 d[k_next - 1] = xShot[k_next - 1] - x_local[k_next];
571 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
579 intermediateCost = 0;
581 for (
size_t k = 0; k < (size_t)
K_; k++)
587 intermediateCost +=
costFunctions_[threadId]->evaluateIntermediate();
595 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
605 for (
size_t k = 0; k < (size_t)
K_; k++)
612 Eigen::Matrix<
SCALAR, -1, 1> box_err =
614 e_tot += box_err.template lpNorm<1>();
622 Eigen::Matrix<
SCALAR, -1, 1> box_err =
624 e_tot += box_err.template lpNorm<1>();
640 e_tot += box_err.template lpNorm<1>();
645 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
655 for (
size_t k = 0; k < (size_t)
K_; k++)
662 Eigen::Matrix<
SCALAR, -1, 1> gen_err =
664 e_tot += gen_err.template lpNorm<1>();
679 e_tot += gen_err.template lpNorm<1>();
684 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
726 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
733 const int nb_u_intermediate =
736 if (nb_u_intermediate > 0)
738 Eigen::VectorXi u_sparsity_row, u_sparsity_col_intermediate;
741 u_sparsity_row, u_sparsity_col_intermediate);
751 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
756 const int nb_x_intermediate =
759 if (nb_x_intermediate > 0)
761 Eigen::VectorXi x_sparsity_row, x_sparsity_col_intermediate;
764 x_sparsity_row, x_sparsity_col_intermediate);
766 lqocProblem_->setIntermediateStateBoxConstraints(nb_x_intermediate,
775 if (nb_x_terminal > 0)
777 Eigen::VectorXi x_sparsity_row_terminal, x_sparsity_col_terminal;
780 x_sparsity_row_terminal, x_sparsity_col_terminal);
789 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
809 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> g_eval =
generalConstraints_[threadId]->evaluateIntermediate();
818 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
840 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> g_eval =
849 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
852 SCALAR d_norm_l1 = computeDefectsNorm<1>(
d_);
853 SCALAR d_norm_l2 = computeDefectsNorm<2>(
d_);
862 SCALAR smallestEigenvalue = 0.0;
865 smallestEigenvalue =
lqocSolver_->getSmallestEigenvalue();
890 std::cout << std::setprecision(15) <<
"smallest eigenvalue this iteration: " << smallestEigenvalue << std::endl;
894 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
897 #ifdef MATLAB_FULL_LOG 901 std::cout <<
"Logging to Matlab" << std::endl;
907 matFile_.put(
"iteration", iteration);
908 matFile_.put(
"K",
K_);
913 matFile_.put(
"t",
t_.toEigenTrajectory());
917 matFile_.put(
"A", p.
A_.toImplementation());
918 matFile_.put(
"B", p.
B_.toImplementation());
919 matFile_.put(
"qv", p.
qv_.toImplementation());
920 matFile_.put(
"Q", p.
Q_.toImplementation());
921 matFile_.put(
"P", p.
P_.toImplementation());
922 matFile_.put(
"rv", p.
rv_.toImplementation());
923 matFile_.put(
"R", p.
R_.toImplementation());
924 matFile_.put(
"q", p.
q_.toEigenTrajectory());
928 matFile_.put(
"cost",
getCost());
932 matFile_.put(
"d_norm",
d_norm_);
941 #endif //MATLAB_FULL_LOG 945 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
951 std::cout <<
"Logging init guess to Matlab" << std::endl;
955 matFile_.put(
"K",
K_);
961 matFile_.put(
"d",
d_);
962 matFile_.put(
"cost",
getCost());
965 matFile_.put(
"d_norm",
d_norm_);
978 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
985 t_control.pop_back();
991 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1002 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1009 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1050 lowestCostPrevious = lowestCost_;
1057 std::cout <<
"[LineSearch]: Starting line search." << std::endl;
1059 std::cout <<
"[LineSearch]: Defect norm last rollout:\t" <<
d_norm_ << std::endl;
1060 std::cout <<
"[LineSearch]: err box constr last rollout:\t" <<
e_box_norm_ << std::endl;
1061 std::cout <<
"[LineSearch]: err gen constr last rollout:\t" <<
e_gen_norm_ << std::endl;
1062 std::cout <<
"[LineSearch]: Merit of last rollout:\t" << lowestCost_ << std::endl;
1069 std::cout <<
"[LineSearch]: Best control found at alpha: " <<
alphaBest_ <<
", with " << std::endl;
1071 std::cout <<
"[LineSearch]: Defect:\t" <<
d_norm_ << std::endl;
1072 std::cout <<
"[LineSearch]: err box constr:\t" <<
e_box_norm_ << std::endl;
1073 std::cout <<
"[LineSearch]: err gen constr:\t" <<
e_gen_norm_ << std::endl;
1080 std::cout <<
"WARNING: No better control found during line search. Converged." << std::endl;
1096 std::cout <<
"CONVERGED: Cost last iteration: " << lowestCostPrevious <<
", current cost: " <<
lowestCost_ 1098 std::cout <<
"CONVERGED: Cost improvement ratio was: " 1099 << fabs(lowestCostPrevious -
lowestCost_) / lowestCostPrevious
1106 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1120 std::atomic_bool* terminationFlag)
const 1122 intermediateCost = std::numeric_limits<scalar_t>::max();
1123 finalCost = std::numeric_limits<scalar_t>::max();
1124 defectNorm = std::numeric_limits<scalar_t>::max();
1128 if (terminationFlag && *terminationFlag)
1140 if (terminationFlag && *terminationFlag)
1146 x_ref_lqr, x_shot_alpha, defects_recorded, substepsX, substepsU, terminationFlag);
1148 if (terminationFlag && *terminationFlag)
1155 defectNorm = computeDefectsNorm<1>(defects_recorded);
1157 if (terminationFlag && *terminationFlag)
1162 if (terminationFlag && *terminationFlag)
1169 if (terminationFlag && *terminationFlag)
1179 std::string msg = std::string(
"dynamics not good, thread: ") + std::to_string(threadId);
1180 std::cout << msg << std::endl;
1186 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1188 const SCALAR intermediateCost,
1193 const SCALAR lowestMeritPrevious,
1198 case LineSearchSettings::TYPE::SIMPLE:
1203 if ((lowestMeritPrevious - new_merit > 0.0) && !std::isnan(new_merit))
1210 case LineSearchSettings::TYPE::ARMIJO:
1215 if (std::isnan(new_merit))
1222 for (
int i = 0;
i <
K_;
i++)
1229 SCALAR expCostDecr = alpha * (Delta1 + alpha * 0.5 * Delta2);
1232 ((lowestMeritPrevious - new_merit) >= 0.0))
1239 case LineSearchSettings::TYPE::GOLDSTEIN:
1241 throw std::runtime_error(
"Goldstein conditions not completed yet, use Armijo for now.");
1246 if (std::isnan(new_merit))
1253 for (
int i = 0;
i <
K_;
i++)
1260 SCALAR expCostDecr = alpha * (Delta1 + alpha * 0.5 * Delta2);
1263 ((lowestMeritPrevious - new_merit) <=
1272 throw std::runtime_error(
"Invalid line search type in acceptStep()");
1279 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1295 for (
int i = this->
lqocProblem_->getNumberOfStages() - 1;
i >=
static_cast<int>(startIndex);
i--)
1299 throw std::runtime_error(
"unknown solver type in prepareSolveLQProblem()");
1303 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1317 for (
int i = endIndex;
i >= 0;
i--)
1323 throw std::runtime_error(
"unknown solver type in finishSolveLQProblem()");
1327 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1337 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1345 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1356 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1364 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1369 d_norm_ = std::numeric_limits<scalar_t>::infinity();
1370 lx_norm_ = std::numeric_limits<scalar_t>::infinity();
1371 lu_norm_ = std::numeric_limits<scalar_t>::infinity();
1380 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1398 case NLOptConSettings::NLOCP_ALGORITHM::GNMS:
1399 case NLOptConSettings::NLOCP_ALGORITHM::GNMS_M_OL:
1400 case NLOptConSettings::NLOCP_ALGORITHM::SS_OL:
1408 case NLOptConSettings::NLOCP_ALGORITHM::ILQR:
1418 case NLOptConSettings::NLOCP_ALGORITHM::MS_ILQR:
1429 case NLOptConSettings::NLOCP_ALGORITHM::SS_CL:
1430 case NLOptConSettings::NLOCP_ALGORITHM::GNMS_M_CL:
1441 throw std::runtime_error(
"Unknown NLOC Algorithm type given in settings.");
1446 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1456 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1458 const std::string& fileName)
1464 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1471 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1478 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1485 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1492 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1503 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1511 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1518 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1525 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1532 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1539 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1548 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1557 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1566 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1575 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1576 std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1584 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1585 const std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1593 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1594 std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1602 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1603 const std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1610 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1611 std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1619 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1620 const std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1628 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1629 std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1637 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1638 const std::vector<typename NLOCBackendBase<STATE_DIM, CONTROL_DIM, P_DIM, V_DIM, SCALAR, CONTINUOUS>::OptConProblem_t::
1646 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1652 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1658 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
1667 template <
size_t STATE_DIM,
size_t CONTROL_DIM,
size_t P_DIM,
size_t V_DIM,
typename SCALAR,
bool CONTINUOUS>
LineSearchSettings lineSearchSettings
number of threads for eigen parallelization (applies both to MP and ST) Note. in order to activate Ei...
Definition: NLOptConSettings.hpp:275
ct::core::StateControlMatrixArray< STATE_DIM, CONTROL_DIM, SCALAR > B_
Definition: LQOCProblem.hpp:207
StateVectorArray xShot_
state array variables
Definition: NLOCBackendBase.hpp:564
std::vector< typename OptConProblem_t::DynamicsPtr_t > & getNonlinearSystemsInstances()
Direct accessor to the system instances.
Definition: NLOCBackendBase-impl.hpp:1542
void computeCostsOfTrajectory(size_t threadId, const core::StateVectorArray< STATE_DIM, SCALAR > &x_local, const core::ControlVectorArray< CONTROL_DIM, SCALAR > &u_local, scalar_t &intermediateCost, scalar_t &finalCost) const
Compute cost for a given set of state and input trajectory.
Definition: NLOCBackendBase-impl.hpp:572
void setInputBoxConstraintsForLQOCProblem()
sets the box constraints for the entire time horizon including terminal stage
Definition: NLOCBackendBase-impl.hpp:727
void computeSingleDefect(size_t k, const StateVectorArray &x_local, const StateVectorArray &xShot, StateVectorArray &d) const
computes the defect between shot and trajectory
Definition: NLOCBackendBase-impl.hpp:556
StateVectorArray delta_x_ref_lqr_
pointer to state increment
Definition: NLOCBackendBase.hpp:575
interface class for optimal control algorithms
Definition: OptconDiscreteSystemInterface.h:21
LQOCP_SOLVER lqocp_solver
which nonlinear optimal control algorithm is to be used
Definition: NLOptConSettings.hpp:259
void executeLQApproximation(size_t threadId, size_t k)
Computes the linearized Dynamics and quadratic cost approximation at a specific point of the trajecto...
Definition: NLOCBackendBase-impl.hpp:685
double maxDefectSum
minimum cost improvement between two interations to assume convergence
Definition: NLOptConSettings.hpp:266
SCALAR getTimeHorizon()
Definition: NLOCBackendBase-impl.hpp:1647
std::vector< typename OptConProblem_t::ConstraintPtr_t > & getStateBoxConstraintsInstances()
Definition: NLOCBackendBase-impl.hpp:1613
systemInterfacePtr_t systemInterface_
pointer to instance of the system interface
Definition: NLOCBackendBase.hpp:603
ct::core::StateMatrixArray< STATE_DIM, SCALAR > A_
affine, time-varying system dynamics in discrete time
Definition: LQOCProblem.hpp:206
bool printSummary
Definition: NLOptConSettings.hpp:278
ct::core::ControlMatrixArray< CONTROL_DIM, SCALAR > R_
Definition: LQOCProblem.hpp:219
std::string loggingPrefix
the solver for the linear-quadratic optimal control problem
Definition: NLOptConSettings.hpp:260
ct::core::FeedbackArray< STATE_DIM, CONTROL_DIM, SCALAR > P_
LQ approximation of the cross terms of the cost function.
Definition: LQOCProblem.hpp:222
constr_control_jac_array_t D_
Definition: LQOCProblem.hpp:250
void computeDefectsNorm()
update the nominal defects
Definition: NLOCBackendBase-impl.hpp:1479
std::enable_if< std::is_same< T, ContinuousOptConProblem< STATE_DIM, CONTROL_DIM, SCALAR > >::value, systemInterfacePtr_t >::type createSystemInterface(const OptConProblem_t &optConProblem, const Settings_t &settings)
Definition: NLOCBackendBase-impl.hpp:105
size_t nThreadsEigen
number of threads, for MP version
Definition: NLOptConSettings.hpp:274
double armijo_parameter
Definition: NLOptConSettings.hpp:65
double dt
Eigenvalue correction factor for Hessian regularization.
Definition: NLOptConSettings.hpp:262
void changeInitialState(const core::StateVector< STATE_DIM, SCALAR > &x0)
Change the initial state for the optimal control problem.
Definition: NLOCBackendBase-impl.hpp:238
int K_
Definition: NLOCBackendBase.hpp:561
StateVectorArray x_ref_lqr_
state array from previous iteration
Definition: NLOCBackendBase.hpp:567
scalar_t lowestCost_
Definition: NLOCBackendBase.hpp:588
TYPE type
Definition: NLOptConSettings.hpp:58
scalar_t finalCostBest_
Definition: NLOCBackendBase.hpp:587
bool rolloutSingleShot(const size_t threadId, const size_t k, ControlVectorArray &u_ff_local, StateVectorArray &x_local, const StateVectorArray &x_ref_lqr, StateVectorArray &xShot, StateSubsteps &substepsX, ControlSubsteps &substepsU, std::atomic_bool *terminationFlag=nullptr) const
integrate the individual shots
Definition: NLOCBackendBase-impl.hpp:436
bool closedLoopShooting() const
return if this is a closed-loop shooting algorithm (or not)
Definition: NLOptConSettings.hpp:303
ct::core::StateVectorArray< STATE_DIM, SCALAR > b_
Definition: LQOCProblem.hpp:208
int getNumSteps()
Definition: NLOCBackendBase-impl.hpp:1653
std::shared_ptr< LQOCProblem< STATE_DIM, CONTROL_DIM, SCALAR > > lqocProblem_
shared pointer to the linear-quadratic optimal control problem that is constructed by NLOC ...
Definition: NLOCBackendBase.hpp:597
virtual void rolloutShots(size_t firstIndex, size_t lastIndex)=0
integrates the specified shots and computes the corresponding defects
size_t iteration_
Definition: NLOCBackendBase.hpp:555
virtual void solveFullLQProblem()
Definition: NLOCBackendBase-impl.hpp:1328
StateVectorArray d_
rolled-out state (at the end of a time step forward)
Definition: NLOCBackendBase.hpp:565
void reset()
Definition: NLOCBackendBase-impl.hpp:1365
std::vector< int > ng_
number of general inequality constraints
Definition: LQOCProblem.hpp:252
void computeLinearizedConstraints(size_t threadId, size_t k)
Computes the linearized general constraints at a specific point of the trajectory.
Definition: NLOCBackendBase-impl.hpp:790
bool debugPrint
Definition: NLOptConSettings.hpp:66
StateVectorArray x_
the time trajectory
Definition: NLOCBackendBase.hpp:563
bool isInitialized()
Definition: NLOCBackendBase-impl.hpp:1519
bool debugPrint
Definition: NLOptConSettings.hpp:277
void changeGeneralConstraints(const typename OptConProblem_t::ConstraintPtr_t &con)
Change the general constraints.
Definition: NLOCBackendBase-impl.hpp:322
double meritFunctionRhoConstraints
trade off between internal (defect)constraint violation and cost
Definition: NLOptConSettings.hpp:268
ct::core::tpl::TimeArray< SCALAR > t_
the number of stages in the overall OptConProblem
Definition: NLOCBackendBase.hpp:562
SCALAR lu_norm_
sum of the norms of state update
Definition: NLOCBackendBase.hpp:584
FeedbackArray L_
feed forward controls from previous iteration
Definition: NLOCBackendBase.hpp:571
void setInitialGuess(const Policy_t &initialGuess)
Definition: NLOCBackendBase-impl.hpp:126
const DiscreteArray< FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR > > & K() const
void setConstant(const T &data)
void setStateBoxConstraintsForLQOCProblem()
Definition: NLOCBackendBase-impl.hpp:752
void changeLinearSystem(const typename OptConProblem_t::LinearPtr_t &lin)
Change the linear system.
Definition: NLOCBackendBase-impl.hpp:364
int getNumStepsPerShot() const
Definition: NLOCBackendBase-impl.hpp:1659
std::vector< StateVectorArrayPtr, Eigen::aligned_allocator< StateVectorArrayPtr > > StateSubsteps
Definition: NLOCBackendBase.hpp:73
const core::ControlTrajectory< CONTROL_DIM, SCALAR > getControlTrajectory() const
Definition: NLOCBackendBase-impl.hpp:980
bool isSingleShooting() const
return if this is a single-shooting algorithm (or not)
Definition: NLOptConSettings.hpp:306
SCALAR getCost() const
return the cost of the solution of the current iteration
Definition: NLOCBackendBase-impl.hpp:1003
virtual ~NLOCBackendBase()
Definition: NLOCBackendBase-impl.hpp:97
StateVectorArray x_prev_
defects in between end of rollouts and subsequent state decision vars
Definition: NLOCBackendBase.hpp:566
double min_cost_improvement
duration of a shot as an integer multiple of dt
Definition: NLOptConSettings.hpp:265
const DiscreteArray< state_vector_t > & x_ref() const
ct::core::StateMatrixArray< STATE_DIM, SCALAR > Q_
Definition: LQOCProblem.hpp:215
std::vector< typename OptConProblem_t::ConstraintPtr_t > & getInputBoxConstraintsInstances()
Direct accessor to the box constraint instances.
Definition: NLOCBackendBase-impl.hpp:1596
ControlVectorArray u_ff_prev_
feed forward controls
Definition: NLOCBackendBase.hpp:570
Definition: NLOCResults.hpp:18
std::vector< typename OptConProblem_t::ConstraintPtr_t > generalConstraints_
Definition: NLOCBackendBase.hpp:612
constr_vec_array_t d_ub_
general constraint upper bound
Definition: LQOCProblem.hpp:247
void extractSolution()
extract relevant quantities for the following rollout/solution update step from the LQ solver ...
Definition: NLOCBackendBase-impl.hpp:1381
const double dt
Definition: LQOCSolverTiming.cpp:18
std::shared_ptr< LQOCSolver< STATE_DIM, CONTROL_DIM, SCALAR > > lqocSolver_
shared pointer to the linear-quadratic optimal control solver, that solves above LQOCP ...
Definition: NLOCBackendBase.hpp:600
NLOCP_ALGORITHM nlocp_algorithm
Definition: NLOptConSettings.hpp:258
void changeCostFunction(const typename OptConProblem_t::CostFunctionPtr_t &cf)
Change the cost function.
Definition: NLOCBackendBase-impl.hpp:249
virtual void prepareSolveLQProblem(size_t startIndex)
Definition: NLOCBackendBase-impl.hpp:1280
StateVectorArray delta_x_
pointer to control increment
Definition: NLOCBackendBase.hpp:574
std::vector< typename OptConProblem_t::LinearPtr_t > & getLinearSystemsInstances()
Direct accessor to the linear system instances.
Definition: NLOCBackendBase-impl.hpp:1560
bool rolloutShotsSingleThreaded(size_t threadId, size_t firstIndex, size_t lastIndex, ControlVectorArray &u_ff_local, StateVectorArray &x_local, const StateVectorArray &x_ref_lqr, StateVectorArray &xShot, StateVectorArray &d, StateSubsteps &substepsX, ControlSubsteps &substepsU, std::atomic_bool *terminationFlag=nullptr) const
do a single threaded rollout and defect computation of the shots - useful for line-search ...
Definition: NLOCBackendBase-impl.hpp:524
bool firstRollout_
Definition: NLOCBackendBase.hpp:557
double meritFunctionRho
maximum sum of squared defects (assume covergence if lower than this number)
Definition: NLOptConSettings.hpp:267
Settings for the NLOptCon algorithm.
Definition: NLOptConSettings.hpp:198
std::conditional< CONTINUOUS, ContinuousOptConProblem< STATE_DIM, CONTROL_DIM, SCALAR >, DiscreteOptConProblem< STATE_DIM, CONTROL_DIM, SCALAR > >::type OptConProblem_t
Definition: NLOCBackendBase.hpp:62
CppAD::AD< CppAD::cg::CG< double > > SCALAR
bool logToMatlab
Definition: NLOptConSettings.hpp:280
SCALAR getTotalDefect() const
return the sum of the L2-norm of the defects along the solution candidate
Definition: NLOCBackendBase-impl.hpp:1526
NLOCBackendBase(const OptConProblem_t &optConProblem, const Settings_t &settings)
Definition: NLOCBackendBase-impl.hpp:13
interface class for optimal control algorithms
Definition: OptconContinuousSystemInterface.h:28
size_t lqpCounter_
a counter used to identify lqp problems in derived classes, i.e. for thread management in MP ...
Definition: NLOCBackendBase.hpp:615
const DiscreteArray< control_vector_t > & uff() const
Settings_t settings_
Definition: NLOCBackendBase.hpp:559
Defines a Linear-Quadratic Optimal Control Problem, which is optionally constrained.
Definition: LQOCProblem.hpp:57
bool testConsistency()
Definition: NLOCBackendBase-impl.hpp:1533
void logToMatlab(const size_t &iteration)
Export all functions to matlab workspace.
Definition: NLOCBackendBase-impl.hpp:895
virtual void configure(const Settings_t &settings)
configure the solver
Definition: NLOCBackendBase-impl.hpp:385
void executeLineSearch(const size_t threadId, const scalar_t alpha, ct::core::StateVectorArray< STATE_DIM, SCALAR > &x_recorded, ct::core::StateVectorArray< STATE_DIM, SCALAR > &x_shot_recorded, ct::core::StateVectorArray< STATE_DIM, SCALAR > &defects_recorded, ct::core::ControlVectorArray< CONTROL_DIM, SCALAR > &u_recorded, scalar_t &intermediateCost, scalar_t &finalCost, scalar_t &defectNorm, scalar_t &e_box_norm, scalar_t &e_gen_norm, StateSubsteps &substepsX, ControlSubsteps &substepsU, std::atomic_bool *terminationFlag=nullptr) const
Check if controller with particular alpha is better.
Definition: NLOCBackendBase-impl.hpp:1107
for i
Definition: mpc_unittest_plotting.m:14
constr_state_jac_array_t C_
linear general constraint matrices
Definition: LQOCProblem.hpp:249
int K_sim
sampling time for the control input (seconds)
Definition: NLOptConSettings.hpp:263
ControlVectorArray u_ff_
reference for lqr
Definition: NLOCBackendBase.hpp:569
std::vector< ControlVectorArrayPtr, Eigen::aligned_allocator< ControlVectorArrayPtr > > ControlSubsteps
Definition: NLOCBackendBase.hpp:76
const Settings_t & getSettings() const
get the current SLQsolver settings
Definition: NLOCBackendBase-impl.hpp:1669
std::shared_ptr< systemInterface_t > systemInterfacePtr_t
Definition: NLOCBackendBase.hpp:80
Definition: GNRiccatiSolver.hpp:22
std::vector< typename OptConProblem_t::CostFunctionPtr_t > costFunctions_
Definition: NLOCBackendBase.hpp:609
ControlVectorArray delta_u_ff_
time-varying lqr feedback
Definition: NLOCBackendBase.hpp:573
void resetDefects()
reset all defects to zero
Definition: NLOCBackendBase-impl.hpp:1472
constr_vec_array_t d_lb_
general constraint lower bound
Definition: LQOCProblem.hpp:245
const Policy_t & getSolution()
Definition: NLOCBackendBase-impl.hpp:1358
SCALAR scalar_t
Definition: NLOCBackendBase.hpp:98
virtual SCALAR performLineSearch()=0
performLineSearch: execute the line search, possibly with different threading schemes ...
scalar_t finalCostPrevious_
Definition: NLOCBackendBase.hpp:592
bool acceptStep(const SCALAR alpha, const SCALAR intermediateCost, const SCALAR finalCost, const SCALAR defectNorm, const SCALAR e_box_norm, const SCALAR e_gen_norm, const SCALAR lowestMeritPrevious, SCALAR &new_merit)
in case of line-search compute new merit and check if to accept step. Returns true if accept step ...
Definition: NLOCBackendBase-impl.hpp:1187
scalar_t alphaBest_
Definition: NLOCBackendBase.hpp:594
int computeK(double timeHorizon) const
log to matlab (true/false)
Definition: NLOptConSettings.hpp:290
StateSubstepsPtr substepsX_
state array from previous iteration
Definition: NLOCBackendBase.hpp:577
void update(const DiscreteArray< state_vector_t > &x_ref, const DiscreteArray< control_vector_t > &uff, const DiscreteArray< FeedbackMatrix< STATE_DIM, CONTROL_DIM, SCALAR >> &K, const tpl::TimeArray< SCALAR > &t)
lv
Definition: gnmsPlot.m:7
Base & toImplementation()
const SummaryAllIterations< SCALAR > & getSummary() const
Definition: NLOCBackendBase-impl.hpp:1466
NLOCBackendBase::Policy_t policy_
The policy. currently only for returning the result, should eventually replace L_ and u_ff_ (todo) ...
Definition: NLOCBackendBase.hpp:618
std::vector< typename OptConProblem_t::ConstraintPtr_t > stateBoxConstraints_
Definition: NLOCBackendBase.hpp:611
void retrieveLastAffineModel(StateMatrixArray &A, StateControlMatrixArray &B, StateVectorArray &b)
Retrieve Last Linearized Model.
Definition: NLOCBackendBase-impl.hpp:1346
virtual void finishSolveLQProblem(size_t endIndex)
Definition: NLOCBackendBase-impl.hpp:1304
ct::core::ControlVectorArray< CONTROL_DIM, SCALAR > rv_
LQ approximation of the pure control penalty.
Definition: LQOCProblem.hpp:218
SCALAR e_gen_norm_
sum of the norms of all box constraint violations
Definition: NLOCBackendBase.hpp:582
scalar_t intermediateCostBest_
sum of the norms of control update
Definition: NLOCBackendBase.hpp:586
SCALAR lx_norm_
sum of the norms of all general constraint violations
Definition: NLOCBackendBase.hpp:583
bool initialized_
Definition: NLOCBackendBase.hpp:552
ct::core::StateVectorArray< STATE_DIM, SCALAR > qv_
LQ approximation of the pure state penalty, including terminal state penalty.
Definition: LQOCProblem.hpp:214
const TimeArray & getTimeArray()
Definition: NLOCBackendBase-impl.hpp:1505
ControlSubstepsPtr substepsU_
state substeps recorded by integrator during rollouts
Definition: NLOCBackendBase.hpp:578
void computeBoxConstraintErrorOfTrajectory(size_t threadId, const ct::core::StateVectorArray< STATE_DIM, SCALAR > &x_local, const ct::core::ControlVectorArray< CONTROL_DIM, SCALAR > &u_local, scalar_t &e_tot) const
Compute box constraint violations for a given set of state and input trajectory.
Definition: NLOCBackendBase-impl.hpp:596
C++ implementation of GNMS.
Definition: NLOCBackendBase.hpp:48
void changeStateBoxConstraints(const typename OptConProblem_t::ConstraintPtr_t &con)
Change the state box constraints.
Definition: NLOCBackendBase-impl.hpp:299
void doFullStepUpdate()
simple full-step update for state and feedforward control (used for MPC-mode!)
Definition: NLOCBackendBase-impl.hpp:1447
void initializeCostToGo()
Initializes cost to go.
Definition: NLOCBackendBase-impl.hpp:819
void changeNonlinearSystem(const typename OptConProblem_t::DynamicsPtr_t &dyn)
Change the nonlinear system.
Definition: NLOCBackendBase-impl.hpp:270
bool recordSmallestEigenvalue
perform Hessian regularization by incrementing the eigenvalues by epsilon.
Definition: NLOptConSettings.hpp:271
bool isConfigured()
Definition: NLOCBackendBase-impl.hpp:1512
StateVector< state_dim > x0
Definition: ConstrainedNLOCTest.cpp:14
ct::core::ScalarArray< SCALAR > q_
constant term of in the LQ approximation of the cost function
Definition: LQOCProblem.hpp:211
std::vector< typename OptConProblem_t::CostFunctionPtr_t > & getCostFunctionInstances()
Direct accessor to the cost function instances.
Definition: NLOCBackendBase-impl.hpp:1578
void printSummary()
Print iteration summary.
Definition: NLOCBackendBase-impl.hpp:850
const bool verbose
Definition: ConstraintComparison.h:18
bool nominalRollout()
nominal rollout using default thread and member variables for the results. // todo maybe rename (init...
Definition: NLOCBackendBase-impl.hpp:1493
int nThreads
save the smallest eigenvalue of the Hessian
Definition: NLOptConSettings.hpp:272
void changeTimeHorizon(const SCALAR &tf)
Change the time horizon the solver operates on.
Definition: NLOCBackendBase-impl.hpp:229
std::vector< typename OptConProblem_t::ConstraintPtr_t > & getGeneralConstraintsInstances()
Direct accessor to the general constraints.
Definition: NLOCBackendBase-impl.hpp:1631
void changeInputBoxConstraints(const typename OptConProblem_t::ConstraintPtr_t &con)
Change the input box constraints.
Definition: NLOCBackendBase-impl.hpp:277
int K_shot
number of sub-integration-steps
Definition: NLOptConSettings.hpp:264
void logSummaryToMatlab(const std::string &fileName)
Definition: NLOCBackendBase-impl.hpp:1457
scalar_t intermediateCostPrevious_
costs of the previous iteration, required to determine convergence
Definition: NLOCBackendBase.hpp:591
bool configured_
Definition: NLOCBackendBase.hpp:553
std::vector< typename OptConProblem_t::ConstraintPtr_t > inputBoxConstraints_
Definition: NLOCBackendBase.hpp:610
void updateCosts()
compute costs of solution candidate
Definition: NLOCBackendBase-impl.hpp:1338
bool parametersOk() const
perform a quick check if the given NLOptCon settings fulfil minimum requirements
Definition: NLOptConSettings.hpp:349
SCALAR d_norm_
control substeps recorded by integrator during rollouts
Definition: NLOCBackendBase.hpp:580
bool lineSearch()
perform line-search and update controller
Definition: NLOCBackendBase-impl.hpp:1010
size_t & iteration()
return the current iteration number
Definition: NLOCBackendBase-impl.hpp:1486
void logInitToMatlab()
log the initial guess to Matlab
Definition: NLOCBackendBase-impl.hpp:946
void checkProblem()
check problem for consistency
Definition: NLOCBackendBase-impl.hpp:371
SCALAR e_box_norm_
sum of the norms of all defects (internal constraint)
Definition: NLOCBackendBase.hpp:581
ct::core::tpl::TimeArray< SCALAR > TimeArray
Definition: NLOCBackendBase.hpp:87
SummaryAllIterations< SCALAR > summaryAllIterations_
Definition: NLOCBackendBase.hpp:620
void computeGeneralConstraintErrorOfTrajectory(size_t threadId, const ct::core::StateVectorArray< STATE_DIM, SCALAR > &x_local, const ct::core::ControlVectorArray< CONTROL_DIM, SCALAR > &u_local, scalar_t &e_tot) const
Compute general constraint violations for a given set of state and input trajectory.
Definition: NLOCBackendBase-impl.hpp:647
const core::StateTrajectory< STATE_DIM, SCALAR > getStateTrajectory() const
Definition: NLOCBackendBase-impl.hpp:993