fix(data): OpenLoop is unconditionally non-autonomous - #523
Merged
Conversation
is_autonomous stripped the time argument uniformly across all three control-law kinds; for OpenLoop that made the default build a zero-argument u(), so OpenLoop(t -> 0.0) silently constructed a law that only failed with a bare MethodError once a flow was integrated, not at construction. Autonomy is a property of the OCP, not of the control, so OpenLoop's natural call is now always u(t) (or u(t, v)). is_autonomous is kept as a misuse-detector keyword only (warns, no effect); the typed constructor rejects the (OpenLoopFeedback, Autonomous) combination outright. Fixes #515. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_autonomouscurrently strips the time argument uniformly across all three control-law kinds.For
OpenLoop, sincetis the only possible argument, the default (is_autonomous=true) built a zero-argument natural callu(), soOpenLoop(t -> 0.0)silently constructed a law that only failed with a bareMethodErroronce a flow was later integrated — not at construction.Autonomy is a property of the OCP, not of the control — an open-loop control for an autonomous OCP can still depend on time.
OpenLoop's natural call is now unconditionallyu(t)(oru(t, v)).OpenLoop'sTimeDependenceis fixed toTraits.NonAutonomous. This is not hidden:Traits.time_dependence/Traits.is_autonomouson anOpenLoopcontrol law still answer normally — alwaysNonAutonomous/false.is_autonomousis kept inOpenLoop's signature purely as a misuse detector, defaulting to theCTBase.Core.NotProvidedsentinel. Passing it explicitly (true/false) emits an@warnand has no effect.ControlLaw(f, Traits.OpenLoopFeedback, Traits.Autonomous, VD)now raisesExceptions.IncorrectArgumentinstead of silently building an uncallable law.ClosedLoop/DynClosedLoopare unaffected —is_autonomousremains a real choice for those.Base.showforOpenLoopdrops the now-meaningless time-dependence label.Version bumped to
0.28.9-beta;CHANGELOG.mdandBREAKING.mdupdated with migration notes.Fixes #515.
Test plan
test/suite/data/test_control_law.jl— updated for the new contract (nois_autonomousonOpenLoop, alwaysu(t)), plus new coverage for the misuse-warning (Test.@test_logs) and the rejected typed-constructor combo.test/suite/data/test_composed_hamiltonian.jl,test/suite/data/test_composed_vector_field.jl— updated zero-argOpenLoopclosures tot -> ....docs/src/guide/data.md,docs/src/guide/traits.md— narrative + executed examples updated.🤖 Generated with Claude Code