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?
| Item | Definition |
|---|---|
| State | Position |
| Control | Velocity |
| Objective | Minimize duration plus the integral of squared velocity |
| Phases | One phase, 8 nodes, fixed start time 5, free final time |
| New concepts | Dynamics, boundary conditions, terminal and running costs |
Situation
Section titled “Situation”We choose the point’s velocity at every instant. This input is the control; position , determined by that choice, is the state (terminology). We want to move from to while balancing two goals:
- Arrive sooner.
- Use less effort, measured by the integral of .
All quantities are dimensionless. The purpose is to learn the structure of an optimal control problem.
Formulation
Section titled “Formulation”Dynamics
Section titled “Dynamics”Position changes at the chosen velocity. This relationship must hold throughout optimization.
Boundary conditions
Section titled “Boundary conditions”The start time is fixed at to demonstrate that time need not start at zero. The optimal duration does not depend on this offset. The final time is free.
Constraints
Section titled “Constraints”Duration therefore lies between 0.1 and 10. Neither bound is active at the optimum.
Objective
Section titled “Objective”The first term is a terminal cost; the second is a running cost. Reducing duration requires faster motion and increases the running cost.
Parameters and scaling
Section titled “Parameters and scaling”| Symbol | Meaning | Value |
|---|---|---|
Distance (target) | 2 | |
| Start time | 5 | |
| Velocity limit | 3 |
The time and position units are 3 and 2 internally (scaling). Results are returned in the original units.
Initial guess
Section titled “Initial guess”Start with time 5 to 8, position increasing linearly from 0 to 2, and constant velocity .
Results
Section titled “Results”
- Duration: 2.0000; objective: 4.0000.
- Velocity remains 1.0000 throughout, and position increases linearly.
- The velocity limit is inactive everywhere.
Explanation
Section titled “Explanation”Best motion for a fixed duration
Section titled “Best motion for a fixed duration”Let . The mean velocity is . For a given mean, constant velocity minimizes the integral of the square: the mean square is at least the square of the mean. Thus and
Best duration
Section titled “Best duration”Setting gives
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.
What the numerical method does
Section titled “What the numerical method does”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.
Try it
Section titled “Try it”- Change
target = 2.0inmain()to 1 or 5. Duration should equal distance and velocity should remain 1. - Set
targetto 20. The unconstrained duration 20 exceeds the allowed duration 10, so the optimum has duration 10, velocity 2, and cost . - Change the node count in
Problem([5, 8], [8], ...)to 3 or 20 and compare the answer.
uv run python examples/01_minimum_energy_transfer.py