14 std::vector<
typename math_types<Scalar>::VectorXs> &xs) {
15 const std::size_t nsteps = problem.numSteps();
16 xs.resize(nsteps + 1);
17 if (problem.initCondIsStateError()) {
18 xs[0] = problem.getInitState();
20 if (problem.stages_.size() > 0) {
21 xs[0] = problem.stages_[0]->xspace().neutral();
24 "The problem should have either a StateErrorResidual as an initial "
25 "condition or at least one stage.");
28 for (std::size_t i = 0; i < nsteps; i++) {
29 const StageModelTpl<Scalar> &sm = *problem.stages_[i];
30 xs[i + 1] = sm.xspace_next().neutral();
38 std::vector<
typename math_types<Scalar>::VectorXs> &us) {
39 const std::size_t nsteps = problem.numSteps();
41 for (std::size_t i = 0; i < nsteps; i++) {
42 const StageModelTpl<Scalar> &sm = *problem.stages_[i];
43 us[i] = sm.uspace().neutral();
49 using VectorXs =
typename math_types<Scalar>::VectorXs;
50 std::vector<VectorXs> xs, us, vs, lbdas;
51 const size_t nsteps = problem.numSteps();
55 vs.resize(nsteps + 1);
56 lbdas.resize(nsteps + 1);
57 lbdas[0].setZero(problem.init_condition_->nr);
58 for (
size_t i = 0; i < nsteps; i++) {
59 const StageModelTpl<Scalar> &sm = *problem.stages_[i];
60 lbdas[i + 1].setZero(sm.ndx2());
61 vs[i].setZero(sm.nc());
64 if (!problem.term_cstrs_.empty()) {
65 vs[nsteps].setZero(problem.term_cstrs_.totalDim());
68 return std::make_tuple(std::move(xs), std::move(us), std::move(vs),
76 const TrajOptProblemTpl<Scalar> &problem,
77 const typename math_types<Scalar>::VectorOfVectors &xs_init,
78 const typename math_types<Scalar>::VectorOfVectors &us_init,
79 typename math_types<Scalar>::VectorOfVectors &xs_out,
80 typename math_types<Scalar>::VectorOfVectors &us_out) {
81 const std::size_t nsteps = problem.numSteps();
82 xs_out.reserve(nsteps + 1);
83 us_out.reserve(nsteps);
84 if (xs_init.size() == 0) {
87 if (xs_init.size() != (nsteps + 1)) {
92 if (us_init.size() == 0) {
95 if (us_init.size() != nsteps) {
void check_trajectory_and_assign(const TrajOptProblemTpl< Scalar > &problem, const typename math_types< Scalar >::VectorOfVectors &xs_init, const typename math_types< Scalar >::VectorOfVectors &us_init, typename math_types< Scalar >::VectorOfVectors &xs_out, typename math_types< Scalar >::VectorOfVectors &us_out)
Check the input state-control trajectory is a consistent warm-start for the output.
void us_default_init(const TrajOptProblemTpl< Scalar > &problem, std::vector< typename math_types< Scalar >::VectorXs > &us)
Default-initialize a controls trajectory from the neutral element of each control space.
void xs_default_init(const TrajOptProblemTpl< Scalar > &problem, std::vector< typename math_types< Scalar >::VectorXs > &xs)
Default-intialize a trajectory to the neutral states for each state space at each stage.