Nested soft constraint support #178
Merged
+136
−34
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.
This addresses #176 by first separating each soft constraint into its own Implies soft constraint while building RandInfo. The condition for the Implies constraint is built up by keeping a stack of the if_then and implies conditions while visiting constraints and combining those with And expressions.
Then in the RandSetNodeBuilder a soft_phase flag has been added to prevent nested soft constraints from being built during the hard constraints. A new soft constraints build phase is added to specifically build soft and nested soft constraints.
There's a TODO in rand_info_builder.py under visit_constraint_soft about how a 'priority' attribute is being added to the Implies constraint built up for nested soft constraints so that they can be sorted alongside other soft constraints as well as make it possible
to check for soft vs hard constraints in the add_constraints function.
I should reread the docs, but the soft constraints section might need to be changed.