Decouple CP model from component constraint generators using context/state/result pattern#436
Draft
Decouple CP model from component constraint generators using context/state/result pattern#436
Conversation
…from constraint generators
- Introduce CpBuildContext (frozen), CpBuildState (mutable), and
CpComponentBuildResult dataclasses to decouple CP model state from
component constraint methods.
- Migrate all ~56 cp_* constraint methods across 16 component files to
accept (context, state) and return CpComponentBuildResult instead of
mutating the model directly.
- Update all 9 CP model files to use the new context/state/result protocol.
- Remove the if/else dispatch in build_generic_cp_model_from_dictionary
that branched on model_type.startswith("cp_") vs minizinc_*; the method
now exclusively calls cp_* methods with (context, state).
- Update all affected unit tests (component + model tests).
|
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.



Remove cp_/minizinc_ dispatch in build_generic and decouple CP model from constraint generators
Below a diagram showing the interaction between classes/methods/objects involved in the generation of CP models according to the refactor