Examples¶
Each page uses the same skeleton:
- Question
- Formulation (states, control, dynamics, objective, constraints, horizon)
- What was done
- What we found
- Interpretation
- Figures
- How to run / tests
- References — last, and only when a paper or Yop page must be cited
Typewriter names match folders under examples/ in the git clone
(not the wheel). Plot scripts need matplotlib; Goddard comparison
plots and Lindh’s 1-D check need scipy:
python -m pip install -e ".[examples]"
cd examples/microbial_growth
python microbial_growth.py
Every Run and tests block starts with cd examples/<folder> so it
works from the repository root. Plot scripts need .[examples].
Those blocks also run pytest, which is [test] (pytest plus the
plot extras). Scripts import the public package
(import eco_opt, and from eco_opt import Namespace when named
signals are used). Do not import eco_opt.system or other internal
modules. Namespace is names only. Import casadi as cs when \(f\)
uses CasADi functions (exp, sin, sign, interpolants); a list of
derivatives needs no CasADi import
(CasADi expressions). Each page has a short public-API
skeleton; the full script is under examples/<name>/.
A suggested path: First solve (one worked script),
Posing a problem,
Transcription,
Constraints and time,
Build and optimize,
then the tables below. eco_opt is not only plants and microbes:
lakes, greenhouse climate, irrigation, harvest, and textbook OCPs
(rockets, bang–bang, path constraints) sit alongside allocation and
uptake models. Traditional OCP pages supply a closed form or a
transcription check. Troubleshooting if the
NLP fails.
Yop-shipped problems are rewritten here and link the Yop page in References. The wording is not copied from yoptimization.com.
microbial_growth is Manzoni, Chakrawal and Ledder (2023), not a Yop
website example. Cases inspired by other papers state in References that
trajectories are not validated against those papers’ figures
(Chakrawal et al. excepted).
Ecological models¶
| Example | Question |
|---|---|
| microbial_growth | When should uptake stop as substrate is exhausted? |
| opt_lignin | When to pay for ligninolytic oxidation? |
| root_opt | How to split belowground carbon under N limitation? |
| cohen_king_roughgarden | Vegetative vs reproductive allocation |
| iwasa_roughgarden_shoot_root | Shoot, root, and fruit |
| lindh_2016_flowering | Flowering time under constrained growth |
| multiphase_cohen | Cohen’s switch as two phases |
| shallow_lake | Phosphorus loading and two management locals |
| greenhouse | Heating with tabulated weather |
| irrigation_bucket | Irrigation when rain is not in the forecast |
Traditional OCP problems¶
Textbook and benchmark transcriptions. They are not ecological models. They check free time, path constraints, bang–bang structure, and collocation against closed forms or an archive.
| Example | Question |
|---|---|
| goddard_benchmark | Dimensional Goddard, free horizon |
| goddard_rocket_basic | Nondimensional Goddard |
| multiphase_goddard_landing | Ascent then landing |
| bang_free_tf | Minimum-time double integrator |
| bryson_denham | Path-constrained minimum energy |
| iso_constraint | Fixed integral of \(u^2\) |
| non_diff | Discontinuous pulse in \(f\) |
| brachistochrone | Minimum-time cycloid |
| van_der_pol | Forced oscillator, running cost |
| lenhart_workman | Three textbook OCPs |
| lenhart_workman_labs | Book labs, posed in eco_opt |
| xuezhong_wang | Fixed-time double integrator |
Numerical features¶
| Example | Question |
|---|---|
| algebraic_qss | Fast biomass as an algebraic closure |
Multi-phase collocation is shown inside multiphase_cohen and Goddard landing. Open vs closed loop is shown inside the irrigation, microbial, lignin, and root-opt pages.