Add user-facing Model predicates and restrict predicates to Model only#304
Merged
Add user-facing Model predicates and restrict predicates to Model only#304
Conversation
- Remove all __is_*_set(::Model) methods (trivial/unused) - Remove __is_*_set(::PreModel) for optional fields (control, variable, definition) - Add __is_*_empty(ocp::PreModel) overloads delegating to component - Rewrite __is_empty(::PreModel) to use overloads for optional fields - Remove __is_complete(::PreModel) (redundant with __is_consistent) - Migrate all call sites from __is_*_set to !__is_*_empty for optional fields - Update test assertions to reflect new predicate semantics - Remove dead import __is_definition_set from Display.jl This establishes clear semantic separation: - __is_*_set: only for mandatory fields on PreModel - __is_*_empty: only for optional fields (works on PreModel via overload)
- Add has_variable, has_control, has_abstract_definition, is_abstractly_defined, is_nonautonomous, is_nonvariable for Model - Remove is_autonomous, is_variable, is_control_free on PreModel - Update Display call sites to use internal predicates - Update tests accordingly
- Document removal of PreModel predicates (breaking change) - Add new user-facing Model predicates documentation - Update internal changes section
Contributor
Closed
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.
Add user-facing Model predicates and restrict predicates to Model only
This PR adds user-friendly predicate methods exclusively for
Modelinstances and removes predicate methods forPreModelto enforce a clear separation between mutable construction and immutable problem definition.Changes after commit bfc0198
New User-Facing Predicates (Model only)
has_variable(model)- alias foris_variable(model)is_nonvariable(model)- opposite ofis_variable(model)has_control(model)- opposite ofis_control_free(model)has_abstract_definition(model)- checks if definition is non-emptyis_abstractly_defined(model)- alias forhas_abstract_definitionis_nonautonomous(model)- opposite ofis_autonomous(model)Breaking Changes
Removed predicate methods for
PreModel:is_autonomous(ocp::PreModel)- removedis_variable(ocp::PreModel)- removedis_control_free(ocp::PreModel)- removedThese methods remain available for
Modelinstances.Internal Changes
__is_variable_empty,__is_control_empty) and direct field access (ocp.autonomous)Testing
All tests pass: 3617/3617 ✅
Migration Guide