feat(traits): implement ControlDependence on Model; migrate is_control_free/has_control to CTBase#354
Merged
Merged
Conversation
…as_control to CTBase - Model now implements the CTBase.Traits.ControlDependence contract (has_control_dependence_trait + control_dependence), reading ControlFree from an EmptyControlModel and WithControl otherwise — from the control model TYPE, mirroring the existing variable-dependence design (not from control_dimension) - is_control_free / has_control are now generic functions owned by CTBase.Traits; CTModels re-exports them so CTModels.Models.is_control_free / has_control are unchanged. is_control_free is now type-stable (no runtime control_dimension == 0) - Bump CTBase compat 0.25 -> 0.26 (and docs env compat); bump version 0.13.3-beta -> 0.14.0-beta - Extend control-checks tests with trait-path assertions (control_dependence, has_control) - Add a Control dependence subsection to the model Types-and-traits guide - Update CHANGELOG.md and BREAKING.md (purely additive, no breaking changes) Tests: models/components/display suites 313/313 pass; docs build succeeds (exit 0). Co-Authored-By: Claude Opus 4.8 <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
Implements the new
CTBase.Traits.ControlDependencetrait (added in CTBase 0.26) onModel, and migrates theis_control_free/has_controlpredicates from CTModels-local definitions to the generic CTBase functions. This is PR2 of the ecosystem-wide traits cleanup (CTBase → CTModels → CTFlows).What changed
Modelimplements the control-dependence contract (src/Models/model.jl):has_control_dependence_trait(::Model) = truecontrol_dependence(ocp::Model)reads the control model type:EmptyControlModel→ControlFree, any other →WithControlis_control_free/has_controlmigrated toCTBase.Traits(src/Models/Models.jl):control_dimension(ocp) == 0)CTBase.Traitsand re-exported, soCTModels.Models.is_control_free/has_controlkeep working unchangedis_control_freeis now type-stable (derived from the control model type)Dependencies: CTBase compat
0.25→0.26; version0.13.3-beta→0.14.0-betaTests (
test/suite/models/test_variable_control_checks.jl): extended the control-free / with-control cases with trait-path assertions (control_dependence,has_control_dependence_trait,has_control)Docs: added a Control dependence subsection to the model Types and traits guide
Why this matters
Control presence is a genuine dispatch axis. PR3 (CTFlows) will dispatch
Flow(ocp)oncontrol_dependence(ocp)to route control-free vs with-control problems, closing a latent bug where a with-control OCP would silently mis-build a Hamiltonian. This PR makes the trait available onModel(its proper home, avoiding type piracy in CTFlows).Verification
@refwarnings foris_control_free/has_controlare identical to the pre-existingis_autonomouswarning on the same page (imported CTBase predicates, no InterLinks) — consistent, tolerated viawarnonlycontrol_dependencedispatches onModel;is_control_free/has_controlconfirmed=== CTBase.Traits.*(re-export preserved)Compatibility
No breaking changes — predicate names and behaviour preserved via re-export. Requires CTBase ≥ 0.26.0-beta. See BREAKING.md.
🤖 Generated with Claude Code