Skip to content

01. Minimum-effort transfer

Move a point a fixed distance along a line. Moving faster saves time but requires larger inputs. Moving slowly uses less effort but takes longer. Which motion gives the best balance?

ItemDefinition
StatePosition xx
ControlVelocity uu
ObjectiveMinimize duration plus the integral of squared velocity
PhasesOne phase, 8 nodes, fixed start time 5, free final time
New conceptsDynamics, boundary conditions, terminal and running costs

We choose the point’s velocity uu at every instant. This input is the control; position xx, determined by that choice, is the state (terminology). We want to move from x=0x=0 to x=2x=2 while balancing two goals:

  • Arrive sooner.
  • Use less effort, measured by the integral of u2u^2.

All quantities are dimensionless. The purpose is to learn the structure of an optimal control problem.

x˙=u.\dot{x}=u.

Position changes at the chosen velocity. This relationship must hold throughout optimization.

x(t0)=0,x(tf)=2.x(t_0)=0,\qquad x(t_f)=2.

The start time is fixed at t0=5t_0=5 to demonstrate that time need not start at zero. The optimal duration does not depend on this offset. The final time is free.

0≤u≤3,5.1≤tf≤15.0\le u\le3,\qquad 5.1\le t_f\le15.

Duration therefore lies between 0.1 and 10. Neither bound is active at the optimum.

J=(tf−t0)⏟duration+∫t0tfu2 dt⏟control effort.J=\underbrace{(t_f-t_0)}_{\text{duration}}+\underbrace{\int_{t_0}^{t_f}u^2\,dt}_{\text{control effort}}.

The first term is a terminal cost; the second is a running cost. Reducing duration requires faster motion and increases the running cost.

SymbolMeaningValue
ddDistance (target)2
t0t_0Start time5
umax⁡u_{\max}Velocity limit3

The time and position units are 3 and 2 internally (scaling). Results are returned in the original units.

Start with time 5 to 8, position increasing linearly from 0 to 2, and constant velocity 2/32/3.

Position and velocity. Dots show the eight nodes, the blue curves are interpolants, black dashed curves are analytic solutions, and the red dotted line is the velocity limit 3.
Position and velocity. Dots show the eight nodes, the blue curves are interpolants, black dashed curves are analytic solutions, and the red dotted line is the velocity limit 3.
Motion along the line (left) and position and velocity histories (right). The vertical cursor marks the current time.
  • Duration: 2.0000; objective: 4.0000.
  • Velocity remains 1.0000 throughout, and position increases linearly.
  • The velocity limit is inactive everywhere.

Let T=tf−t0T=t_f-t_0. The mean velocity is d/Td/T. For a given mean, constant velocity minimizes the integral of the square: the mean square is at least the square of the mean. Thus u=d/Tu=d/T and

∫t0tfu2 dt=(dT)2T=d2T.\int_{t_0}^{t_f}u^2\,dt=\left(\frac{d}{T}\right)^2T=\frac{d^2}{T}. J(T)=T+d2T.J(T)=T+\frac{d^2}{T}.

Setting dJ/dT=1−d2/T2=0dJ/dT=1-d^2/T^2=0 gives

T=d=2,u=d/T=1,J=2d=4.T=d=2,\qquad u=d/T=1,\qquad J=2d=4.

The computed duration 2.0000 and objective 4.0000 agree. For this particular objective, the optimal speed is 1 regardless of distance, provided the bounds remain inactive. Only duration changes.

OpenGoddard optimizes position and velocity at eight nodes, plus final time, subject to dynamics and constraints (direct methods, pseudospectral methods). The solution is linear in position and constant in velocity, so even eight nodes represent it exactly.

  • Change target = 2.0 in main() to 1 or 5. Duration should equal distance and velocity should remain 1.
  • Set target to 20. The unconstrained duration 20 exceeds the allowed duration 10, so the optimum has duration 10, velocity 2, and cost 10+202/10=5010+20^2/10=50.
  • Change the node count in Problem([5, 8], [8], ...) to 3 or 20 and compare the answer.
Terminal window
uv run python examples/01_minimum_energy_transfer.py

View the Python source on GitHub.