[V3] Phases 2+3: Flow API Simplification + SciMLBase Extension
Overview
This issue tracks Phases 2 and 3 of the V3 refactoring: simplifying the Flow API with positional control arguments and implementing the SciMLBase extension architecture.
Related: Discussion #144
Branch: feature/v3-flow-api
Depends on: PR #1 (Differential Geometry Refactoring)
Documentation:
Changes
Phase 2: Flow API Simplification
Removed:
- Hamiltonian/VectorField flow constructors (
ext/hamiltonian.jl, ext/vector_field.jl)
- Control wrappers:
ControlLaw, FeedbackControl, StateConstraint, MixedConstraint, Multiplier
- Test files:
test_flow_hamiltonian.jl, test_flow_vector_field.jl, test_flow_hamiltonian_vector_field.jl
Added/Modified:
- New OCP flow API with optional
control_type (default :dynamic_feedback):
Flow(ocp, u)
Flow(ocp, u, :state_feedback)
Flow(ocp, u, :dynamic_feedback, g, μ) (with constraints)
- ODEFunction flow constructor (supports OOP and IP)
- Updated all flow tests
Phase 3: SciMLBase Extension
Added:
src/stubs.jl with helpful error messages:
_ode_problem(system, tspan, z0, params)
_solve(problem, alg, options)
- Extension
ext/CTFlowsSciMLBaseExt.jl (renamed from CTFlowsODE.jl)
- Updated
Project.toml: replaced OrdinaryDiffEq with SciMLBase (lighter dependency)
API Changes
Before (V2):
u = ControlLaw((x, p) -> p[2])
f = Flow(ocp, u)
# With constraints
f = Flow(ocp, u, g, μ)
After (V3):
# Default :dynamic_feedback
f = Flow(ocp, (x, p) -> p[2])
# Explicit control type
f = Flow(ocp, x -> -x, :state_feedback)
# With constraints
f = Flow(ocp, (x, p) -> p[2], :dynamic_feedback, g, μ)
Breaking Changes
⚠️ Major impact - All Flow API users affected.
Users need to:
- Remove control wrappers (
ControlLaw(...), FeedbackControl(...))
- Add optional
control_type argument (or rely on default :dynamic_feedback)
- Load a SciML solver package (
using OrdinaryDiffEq)
Why Combine Phases 2+3?
The extension (Phase 3) is required to test the Flow API (Phase 2). Splitting would create an untestable PR.
Implementation Checklist
Phase 2: Flow API Simplification
Phase 3: Extension and Stub Implementation
Testing
# Run flow tests
julia --project=. test/test_optimal_control_problem.jl
julia --project=. test/test_flow_function.jl
# Run all tests
julia --project=. -e 'using Pkg; Pkg.test("CTFlows");'
# Test extension loading
julia --project=. -e 'using CTFlows; Flow(ocp, u)' # Should error with helpful message
julia --project=. -e 'using CTFlows, OrdinaryDiffEq; Flow(ocp, u)' # Should work
Success criteria:
- All flow tests pass with new API
- Extension loads correctly
- Helpful error messages when extension not loaded
- Code coverage ≥ 90% for modified files
Documentation
[V3] Phases 2+3: Flow API Simplification + SciMLBase Extension
Overview
This issue tracks Phases 2 and 3 of the V3 refactoring: simplifying the Flow API with positional control arguments and implementing the SciMLBase extension architecture.
Related: Discussion #144
Branch:
feature/v3-flow-apiDepends on: PR #1 (Differential Geometry Refactoring)
Documentation:
Changes
Phase 2: Flow API Simplification
Removed:
ext/hamiltonian.jl,ext/vector_field.jl)ControlLaw,FeedbackControl,StateConstraint,MixedConstraint,Multipliertest_flow_hamiltonian.jl,test_flow_vector_field.jl,test_flow_hamiltonian_vector_field.jlAdded/Modified:
control_type(default:dynamic_feedback):Flow(ocp, u)Flow(ocp, u, :state_feedback)Flow(ocp, u, :dynamic_feedback, g, μ)(with constraints)Phase 3: SciMLBase Extension
Added:
src/stubs.jlwith helpful error messages:_ode_problem(system, tspan, z0, params)_solve(problem, alg, options)ext/CTFlowsSciMLBaseExt.jl(renamed fromCTFlowsODE.jl)Project.toml: replacedOrdinaryDiffEqwithSciMLBase(lighter dependency)API Changes
Before (V2):
After (V3):
Breaking Changes
Users need to:
ControlLaw(...),FeedbackControl(...))control_typeargument (or rely on default:dynamic_feedback)using OrdinaryDiffEq)Why Combine Phases 2+3?
The extension (Phase 3) is required to test the Flow API (Phase 2). Splitting would create an untestable PR.
Implementation Checklist
Phase 2: Flow API Simplification
ext/hamiltonian.jl)ext/vector_field.jl)ControlLaw,FeedbackControl,StateConstraint,MixedConstraint,Multiplierwrappers fromsrc/types.jlcontrol_type(default:dynamic_feedback)ext/optimal_control_problem.jltest/test_flow_*.jl,test/test_optimal_control_problem.jl)test/test_flow_hamiltonian.jl,test/test_flow_vector_field.jl,test/test_flow_hamiltonian_vector_field.jlPhase 3: Extension and Stub Implementation
src/stubs.jlwith_ode_problemand_solvestubsext/CTFlowsODE.jltoext/CTFlowsSciMLBaseExt.jl_ode_problemand_solveProject.tomlwith SciMLBase extension (remove OrdinaryDiffEq)Testing
Success criteria:
Documentation