control-toolbox / control-toolbox/CTFlows.jl

[Roadmap] CTFlows — flow derivatives, GPU, AD performance, and control modes

Open
#315 0 comments 0 reactions 1 assignee Claimed by @ocots View on GitHub
roadmap
Dominant language
Julia
Stars
2
Forks
3
Avg merge
22h 16m
Merged PRs (30d)
9

Description

## Objective

Extend CTFlows with the remaining v4 roadmap capabilities: implicit control, constrained flows, flow derivatives, GPU support, non-Hamiltonian flow for direct shooting, and supporting improvements.

## Context

CTFlows v4 roadmap. Several items already shipped since v3: control-law wrappers (`OpenLoop`, `ClosedLoop`, `DynClosedLoop`) in `CTBase.Data` with feedback traits, pseudo-Hamiltonian path (`PseudoHamiltonianSystem`, `ComposedHamiltonian`, `ComposedVectorField`, `ControlledVectorField`), `:total`/`:partial` action option, "1-D = scalar" refactor, and `variable_costate` free-time semantics. The [detailed roadmap](https://github.com/control-toolbox/CTFlows.jl/discussions/299) records what shipped and re-scopes the remaining work.

## Work items

1. **Implicit control** (§1, #46) — Compute control from `∂H̃/∂u = 0` when no control law is provided. Two strategies: **IFT** (augmented ODE for `(x,p,u)` using `u̇ = -(∂²H̃/∂u²)⁻¹·(∂²H̃/∂z∂u)ᵀ·ẋ_H`) or **DAE** (keep `∂H̃/∂u = 0` as algebraic constraint). Needs Hessian AD primitives in `CTBase.Differentiation`. Control passed as keyword (`control = u0`), consistent with `variable` / `variable_costate`. Decision pending: option vs. CTBase.Strategies strategy.

2. **Constrained flows** (§2) — Extend `Flow(ocp, law)` to OCPs with path constraints (`g(t,x) ≤ 0`, `g(t,u) ≤ 0`, `g(t,x,u) ≤ 0`). Design now resolved (see [Constraints & Duals](https://github.com/control-toolbox/CTFlows.jl/issues/314)): separate `PathConstraint` and `Multiplier` carriers, constrained Hamiltonian is `H + μ'g`, junctions via `MultiPhase` concatenation.

3. **Constraints & multipliers design** (§3) — Design note delivered and decisions validated. See [issue #314](https://github.com/control-toolbox/CTFlows.jl/issues/314).

4. **Flow derivative via dual numbers** (§4, #93) — Internal Numerical Differentiation (IND): integrate variational equations (`δż = J·δz`) when flow is evaluated on `ForwardDiff.Dual` inputs, instead of naively pushing duals through the black-box integrator. Tagged dual dispatch to avoid collision with outer AD. Decision on option-vs-strategy to be made jointly with §1.

5. **GPU support & testing** (§5, #249, #111) — Flows on GPU arrays (`CuArray`, AMDGPU/Metal) with GPU-compatible integrators and actual GPU tests in CI or guarded test env.

6. **Non-Hamiltonian flow without costate** (§6, #230) — `Flow(ocp)` for direct shooting: integrate `ẋ = f(t,x,∅,v)` as a plain ODE with variables, no adjoint. `xf = f(t0, x0, tf; variable = v)` — the direct-shooting use case (parameter estimation / optimal design).

7. **Getter naming & vector-field getter** (§7, #185) — `vector_field(flow)` accessor. Small, closes #185, unblocks downstream.

8. **Variable costate for variable times** (§8, #231) — Confirm remaining cases (free `t0`, free `(t0,tf)`).

9. **Cache trajectory projections** (§9) — Quality/perf: precompute projections at construction for two cases (fixed and variable time).

10. **Internal ODE solver** (§10, #81) — Optional/strategic: standalone RKF 5(4) adaptive solver to reduce OrdinaryDiffEq.jl dependency. Revisit if precompile cost or AD-through-integrator becomes a pain point.

## Cross-cutting decision

Three features (§1 implicit control, §4 flow derivative, §5 GPU) each face the same architectural choice: expose as a keyword option (like `hamiltonian_type`) or as a first-class `CTBase.Strategies` strategy (like `:di` backend and `:sciml` integrator). **Decide once, up front, and apply consistently.** Rule of thumb: strategy when the feature needs its own options and/or extension boundary (weak deps); plain option when it is a local RHS branch with no new dependency.

## Priority summary

**High**: §1 implicit control (IFT first), §7 getter naming, §6 non-Hamiltonian Flow(ocp)
**Medium**: §4 flow derivative (IND), §2 constrained flows (after §3 design, now resolved), §8 variable costate tests
**Lower**: §5 GPU, §9 projection caching, §10 internal solver

## References

- [CTFlows roadmap v4](https://github.com/control-toolbox/CTFlows.jl/discussions/299)
- [Constraints & duals design note](https://github.com/control-toolbox/CTFlows.jl/discussions/312)
- [Handbook](https://github.com/control-toolbox/Handbook)
- [Roadmap comment](https://github.com/orgs/control-toolbox/discussions/68#discussioncomment-17584843)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.