Skip to content

[WIP] Rebase features into Rewrite#68

Draft
Copilot wants to merge 93 commits into
mainfrom
copilot/rebase-features-into-rewrite
Draft

[WIP] Rebase features into Rewrite#68
Copilot wants to merge 93 commits into
mainfrom
copilot/rebase-features-into-rewrite

Conversation

Copilot AI commented Jun 4, 2026

Copy link
Copy Markdown

Thanks for the feedback on #61. I've created this new PR, which merges into #61, to address your comment. I will work on the changes and keep this PR's description up to date as I make progress.

Original PR: #61
Triggering comment (#61 (comment)):

@copilot resolve the merge conflicts in this pull request by creating a new pull request with the requested changes on a new branch in a separate PR.

AlCap23 and others added 23 commits March 27, 2026 08:06
- Add specific value checks for bounds (α, β with Inf bounds)
- Add symbolic access tests for all state/control variables
- Use consistent test patterns with lotka_oc.jl
- Fix syntax issues with SingleShootingLayer calls (positional args)
- Remove unused imports (ComponentArrays, Optimization, Ipopt)
- Add DynamicOptimizationLayer and Quadrature tests
- All 224 tests pass
- Add Single Shooting IPOPT optimization testset with AutoForwardDiff
- Add Multiple Shooting IPOPT optimization testset
- Mirror the pattern from lotka_oc.jl but use only ForwardDiff for MTK
- Test initial objective, bounds, successful retcode, final objective
- All tests pass with successful IPOPT convergence
…port

Features:
- Fix controls splatting in DynamicOptimizationLayer(sys, ...) dispatch
- Add MTK symbolic interface tests for terminal cost expressions
- Add Lagrangian cost tests using Symbolics.Integral
- Add Single/Multiple Shooting IPOPT optimization tests with symbolic interface

Changes:
- ext/CorleoneModelingToolkitExtension.jl: Normalize controls to vector before splatting
- test/examples/mtk_oc.jl: New testsets for symbolic DynamicOptimizationLayer interface
…upport

Add comprehensive tests for the symbolic interface:
- Terminal Cost test: uses SingleShootingLayer with quadrature_indices
- Lagrangian Cost with Integral: tests Integral() expression parsing
- Single/Multiple Shooting IPOPT: tests optimization with symbolic interface

All tests use the MTK system definition directly with DynamicOptimizationLayer(sys, ...). The symbolic interface correctly handles:
- Control parameter bindings (u => cgrid)
- Integral expressions for Lagrangian costs
- Terminal cost expressions with time points
- Shooting constraints for multiple shooting

Note: Some bounds checks fail for tunable parameters with Inf bounds (α, β)
which is consistent with existing MTK Single/Multiple Shooting IPOPT tests.
- Fix sensealg kwarg propagation in MTK extension (extract before passing to SingleShootingLayer)
- Remove @parameters block to avoid MTK+ForwardDiff incompatibility
- Hardcode α=1, β=1 in equations instead of tunable params
- Mark IPOPT optimization tests as @test_broken with documentation
- Update test assertions for new parameter structure

MTK's RuntimeGeneratedFunction wrappers using FunctionWrappersWrappers.jl
don't support ForwardDiff.Dual types, causing 'No matching function wrapper was found'
errors during optimization. Use plain Julia ODEProblem (lotka_oc.jl) for optimization tests.
Core changes:
- Add control_timeseries field (ParameterTimeseriesCollection) to Trajectory
- Controls are now is_timeseries_parameter=true (not is_observed=true)
- is_parameter falls through to SymbolCache (controls ARE parameters)
- Add timeseries_parameter_index for control symbol indexing
- Add is_parameter_timeseries(::Type{<:Trajectory}) = Timeseries()
- Add get_parameter_timeseries_collection for SII discrete-time access
- Remove observed() for controls, keep parameter_observed for interpolated eval
- is_observed now returns false, freeing it for algebraic observables/MTK
- Update getindex to not deprecate timeseries-parameter indexing
- _build_control_timeseries pre-computes ControlSignal for ParameterTimeseriesCollection
- Update Trajectory constructors in Single- and MultipleShootingLayer
- Update docstrings in remake_system

This frees the is_observed/observed SII channel for genuine algebraic
observables (postprocessing layers, MTK observed equations). Controls now
route through GetParameterTimeseriesIndex for discrete-time indexed access
and parameter_observed for continuous-time interpolated evaluation.

Breaking: is_observed(traj, :u) now returns false (was true)
         is_parameter(traj, :u) now returns true (was false)
Functional APIs (getsym, getp, traj.ps) are backward compatible.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Preferences & Parameter Fixes
Copilot AI requested a review from AlCap23 June 4, 2026 13:58
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