Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Example and Implementation Workflow

Mass–spring–damper direct transcription

Consider

mq¨+cq˙+kq=u(t)+d(t),m\ddot{q}+c\dot{q}+kq=u(t)+d(t),

with plant decisions k,ck,c, state x=[q  v]T\mathbf{x}=[q\;v]^T, and

x˙=[vkq/mcv/m+(u+d)/m].\dot{\mathbf{x}}= \begin{bmatrix}v\\-kq/m-cv/m+(u+d)/m\end{bmatrix}.

Use

J=0T(wqq2+wvv2+wuu2)dt+wkk+wccJ=\int_0^T(w_qq^2+w_vv^2+w_uu^2)dt+w_kk+w_cc

with bounds on qq, uu, kk, and cc.

The decision vector is

z=[k,c,q0,v0,u0,,qN,vN,uN]T.\mathbf{z}=[k,c,q_0,v_0,u_0,\ldots,q_N,v_N,u_N]^T.

Trapezoidal defects are

0=qk+1qkhk2(vk+vk+1),0=q_{k+1}-q_k-\frac{h_k}{2}(v_k+v_{k+1}),
0=vk+1vkhk2(fv,k+fv,k+1).0=v_{k+1}-v_k-\frac{h_k}{2}(f_{v,k}+f_{v,k+1}).

The second is nonlinear because plant decisions multiply state variables. Use trapezoidal objective quadrature, node bounds, and dense between-node checks.

Note the structure this creates for a nested CCD architecture: for any fixed plant design (k,c)(k,c), the dynamics are linear and the objective is quadratic in the remaining state and control variables, so the inner control-design transcription is a linear-quadratic dynamic-optimization problem whose sparse Hessian and defect Jacobian can be assembled directly from constant matrices rather than by finite-differencing or automatic differentiation at every inner solve. Only the outer sweep over (k,c)(k,c) reintroduces nonlinearity. Recognizing this fixed-plant/variable-control structure is often what makes repeated inner-loop transcription affordable inside a nested plant search.

A credible study uses at least three meshes, design and objective convergence, dense constraint checks, independent simulation, derivative verification, and multiple initial guesses.

Numerical workflow

A ten-step loop from continuous formulation through scaling, method selection, sparse assembly, solve, refinement, verification, multiple starts, and reporting.

The loop from refinement back to formulation and method selection is intentional.

  1. Formulate the continuous problem.

  2. Scale variables, objective terms, and residuals.

  3. Select shooting, multiple shooting, or transcription.

  4. Choose the mesh, polynomial order, control interpolation, and quadrature.

  5. Assemble sparse functions and verified derivatives.

  6. Solve and inspect feasibility, stationarity, and warnings.

  7. Refine and warm start.

  8. Verify with independent simulation and dense constraint checks.

  9. Test nonconvexity using multiple starts and continuation.

  10. Report method, mesh, scaling, solver, tolerances, derivatives, initialization, convergence, residuals, and verification.

Method selection

MethodBest suited forMain strengthMain limitation
Direct shootingStable systems, short horizonsSimple simulator connectionLong-horizon conditioning
Multiple shootingUnstable systems, terminal constraintsShort sensitivity propagationAdded states and continuity equations
Local collocationGeneral nonlinear path-constrained CCDSparse and locally refinableLarge NLP and trajectory initialization
PseudospectralSmooth high-accuracy trajectoriesRapid smooth convergenceAwkward near discontinuities
IndirectKnown active sets and theoretical analysisHigh accuracy and costatesDifficult initialization and constraints