[V3] Phase 4: Multi-Phase Concatenation with Solution Merging
Overview
This issue tracks Phase 4 of the V3 refactoring: multi-phase concatenation architecture with proper solution merging.
Related: Discussion #144
Branch: feature/v3-multi-phase
Depends on: PR #2 (Flow API + Extension)
Documentation:
Changes
Architecture
Added:
Modified:
- Concatenation operator
* now creates MultiPhaseSystem instead of concatenating RHS
- Updated
test/test_concatenation.jl
Concatenation Strategy
V2 Approach (old):
- Concatenate RHS functions:
rhs!(t) = t < t_switch ? F.rhs!(t) : G.rhs!(t)
- Single integration from
t0 to tf
V3 Approach (new):
- Sequential integration: integrate each phase separately
- Batch merging: store all phase solutions, then merge at the end
- Proper jump handling: apply state/costate jumps between phases
API Changes
Before (V2):
f = f1 * (t1, f2) # Creates concatenated RHS
After (V3):
f = f1 * (t1, f2) # Creates MultiPhaseSystem{S}
# Point evaluation
xf, pf = f(t0, x0, p0, tf, v) # Integrates each phase sequentially
# Complete solution
sol = f((t0, tf), x0, p0, v) # Returns merged ODESolution
Breaking Changes
⚠️ Moderate impact - Affects users using flow concatenation.
Behavior change: Concatenation now uses multi-phase architecture instead of RHS switching. This provides:
- ✅ Better solution merging
- ✅ Proper handling of jumps
- ✅ Access to intermediate phase solutions
Implementation Checklist
Testing
# Run concatenation tests
julia --project=. test/test_concatenation.jl
# Run all tests
julia --project=. -e 'using Pkg; Pkg.test("CTFlows");'
Success criteria:
- All concatenation tests pass
- Multi-phase evaluation works correctly
- Solution merging produces valid
ODESolution
- Jumps are applied correctly between phases
- Code coverage ≥ 90% for modified files
Documentation
[V3] Phase 4: Multi-Phase Concatenation with Solution Merging
Overview
This issue tracks Phase 4 of the V3 refactoring: multi-phase concatenation architecture with proper solution merging.
Related: Discussion #144
Branch:
feature/v3-multi-phaseDepends on: PR #2 (Flow API + Extension)
Documentation:
Changes
Architecture
Added:
src/concatenation.jl:AbstractMultiPhaseSystem{S<:AbstractSystem}(abstract type)MultiPhaseSystem{S}(concrete implementation)PhaseTransition(stores transition time and jumps)evaluate_point(mps, t0, z0, tf, v, options)- integrates each phase sequentiallyevaluate_solution(mps, tspan, z0, v, options)- stores all phase solutions for merging_merge_solutions(solutions, mps)stubext/CTFlowsSciMLBaseExt.jl:_merge_solutionsimplementation using batch merging strategyDiffEqParamEstim.jlpatternSciMLBase.build_solutionfor proper solution mergingModified:
*now createsMultiPhaseSysteminstead of concatenating RHStest/test_concatenation.jlConcatenation Strategy
V2 Approach (old):
rhs!(t) = t < t_switch ? F.rhs!(t) : G.rhs!(t)t0totfV3 Approach (new):
API Changes
Before (V2):
After (V3):
Breaking Changes
Behavior change: Concatenation now uses multi-phase architecture instead of RHS switching. This provides:
Implementation Checklist
src/concatenation.jlwithAbstractMultiPhaseSystem{S},MultiPhaseSystem{S}, andPhaseTransitiontypesevaluate_point(mps::AbstractMultiPhaseSystem, ...)insrc/(integrates each phase sequentially, applies jumps)evaluate_solution(mps::AbstractMultiPhaseSystem, ...)insrc/(stores all phase solutions for merging)_merge_solutions(solutions::Vector, mps::AbstractMultiPhaseSystem)stub insrc/with helpful error message_merge_solutionsinext/CTFlowsSciMLBaseExt.jlusing batch merging strategy (concatenate u/t vectors, useSciMLBase.build_solution)*to createMultiPhaseSysteminstead of concatenating RHStest/test_concatenation.jlto test multi-phase evaluation and solution mergingTesting
Success criteria:
ODESolutionDocumentation
*docstringsMultiPhaseSystemarchitecture