Lenhart and Workman (lenhart_workman)¶
Question. Can the same API recover three textbook OCPs: bang–bang, smooth tracking, and minimum time?
Formulation¶
17.2 — linear bang–bang.
Analytic switch \(t^*=2-\ln 2.5\approx 1.084\).
17.3 — tracking.
Fixed horizon; free terminal state.
20.4 — min-time trolley. Double integrator, free \(T\), drive to rest. Analytic \(T\) from the textbook.
What was done¶
Three small System/Ocp scripts in one folder. Same constraint
tuples as the ecological examples.
What we found¶
17.2 recovers the switch. 17.3 is smooth (not bang–bang); objective regression-tracked. 20.4 matches the analytic \(T\).



Interpretation¶
Textbook biology OCPs are small enough that a wrong transcription is obvious. They are not substitutes for the process-model examples; they gate bang–bang, tracking, and free time separately.
Public API¶
Example 17.2 returns bare dx; 20.4 uses Namespace
(examples/lenhart_workman/):
import eco_opt
from eco_opt import Namespace
sys = eco_opt.System(states=1, controls=1, model=linear_bangbang_model)
ocp = eco_opt.Ocp()
ocp.max([2 * sys.x[0] - 3 * sys.u[0]])
ocp.st(system=sys, constraints=[...])
Run and tests¶
cd examples/lenhart_workman
python linear_bangbang_ex17_2.py
python lq_tracking_ex17_3.py
python min_time_trolley_ex20_4.py
python plot_lenhart_workman.py
python -m pytest ../../tests/test_lenhart_workman.py -q
References¶
Lenhart and Workman, Optimal Control Applied to Biological Models, examples 17.2, 17.3, and 20.4.
Not validated against the book’s figures
Where the book gives a closed form (switch time, \(T\)), tests check that. Trajectories are not compared to plotted solutions in Lenhart and Workman.