Skip to content

Perf/stage solvers - #5

Open
rafaelborges5 wants to merge 6 commits into
mainfrom
perf/stage-solvers
Open

rafaelborges5 wants to merge 6 commits into
mainfrom
perf/stage-solvers

Conversation

@rafaelborges5

Copy link
Copy Markdown
Owner
  • Add the ability to use FATROP instead of only IPOPT, there is a different OCP formulation due to it's requirements when it comes to definition of states.
  • Add the ability to provide compiled derivatives to both IPOPT (doable within Casadi), but had to write a C adapter in order to allow it for FATROP.
  • Add the ability to enable / disable these compiled derivatives, as well as a hashing system in order for the system to know when a recompilation is needed or not. IPOPT or FATROP can be chosen
  • Updated documentation

@rafaelborges5 rafaelborges5 self-assigned this Oct 13, 2026
Copilot AI balanced review requested due to automatic review settings October 13, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Backend validation gaps and unsafe concurrent cache compilation can produce unsupported solves or failed builds.

4 open findings
What changed in this PR

Adds stage-wise IPOPT and FATROP backends with cached compiled derivatives, CLI integration, documentation, and tests.

Changes:

  • Implements stage-wise OCP formulations and solver adapters.
  • Adds compiled-derivative caching and prebuild support.
  • Documents and tests solver/derivative combinations.
File Description
tests/​optimization/​test_stage_solvers.py Tests solver agreement and derivatives.
src/​fast_lto/​README.md Documents solver performance.
src/​fast_lto/​pipeline.py Configures and prebuilds solvers.
src/​fast_lto/​optimization/​stage_problem.py Defines stage-wise OCPs.
src/​fast_lto/​optimization/​stage_ipopt.py Implements compiled IPOPT derivatives.
src/​fast_lto/​optimization/​stage_fatrop.py Implements FATROP integration.
src/​fast_lto/​optimization/​README.md Documents new backends.
src/​fast_lto/​optimization/​integrators.py Supports symbolic step sizes.
src/​fast_lto/​optimization/​global_ocp.py Selects solver backends.
src/​fast_lto/​optimization/​fatrop_glue.c Adapts FATROP’s C interface.
src/​fast_lto/​optimization/​codegen.py Compiles and caches derivatives.
src/​fast_lto/​cli.py Adds solver and prebuild flags.
README.md Adds FATROP usage examples.
pyproject.toml Packages the C adapter.
configs/​README.md Documents configuration options.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +76 to +78
t0 = time.perf_counter()
build = root / f"{name}_{key}"
build.mkdir(parents=True, exist_ok=True)
Comment on lines +1017 to +1018
if solver not in SOLVERS:
raise ValueError(f"Unknown solver: {solver!r}. Must be one of {list(SOLVERS)}.")
kappa_half = np.asarray(track["curvatures_half"], dtype=float)
w_left = np.asarray(track["w_left"], dtype=float) - boundary_margin
w_right = np.asarray(track["w_right"], dtype=float) - boundary_margin
ds = float(track["ds_m"])
Comment thread src/fast_lto/pipeline.py
Comment on lines +742 to +743
if config.derivatives != "compiled":
raise ValueError("Nothing to prebuild: set derivatives: compiled.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants