-
Notifications
You must be signed in to change notification settings - Fork 32
feat(pumpkin-solver): Implement consistency checker infrastructure #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
maartenflippo
wants to merge
23
commits into
main
Choose a base branch
from
feat/consistency-checkers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2be6e8d
Started reworking multiplication for consistency checkers.
maartenflippo 4ca596a
feat(pumpkin-solver): Implement consistency checker infrastructure
maartenflippo f7c9b69
Fix multiline test command syntax
maartenflippo 11511e2
Implement domain consistency checker
maartenflippo 70a2c31
Avoid copying domains when doing domain consistency checks
maartenflippo 1d32565
Refactor PropagatorConstructor to remove `add_inference_checkers`
maartenflippo a9324b9
Fix conditional compilation errors and split up reified propagator
maartenflippo 5fc57f9
Fix formatting
maartenflippo dee4887
Implement the checkers for nogood propagator
maartenflippo 1c9f258
Cleanup code
maartenflippo 893989d
Various cleanup
maartenflippo 2d999b7
Rename 'ConsistencyChecker' to 'RetentionChecker'
maartenflippo 2bbdd59
Explicitly introduce the concept of 'PropagationChecker'
maartenflippo 12e8f2b
refactor: split up maximum propagator
ImkoMarijnissen 5dbb7e1
feat: adding consistency checker for maximum
ImkoMarijnissen d220a64
feat: adding weak consistency checker
ImkoMarijnissen 11713ff
feat: adding consistency checker for time-tabling
ImkoMarijnissen ca935d0
chore: add proper error logging to weak retention checker
ImkoMarijnissen 4d22b09
fix: test cases
ImkoMarijnissen c676757
Squashed commit of the following:
maartenflippo f2169ee
refactor: simplify disjunctive propagation checker
ImkoMarijnissen a5b2548
feat: add consistency checker for disjunctive
ImkoMarijnissen 2d8f33b
chore: add back commented out lines
ImkoMarijnissen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| mod propagation_checker; | ||
| mod retention_checker; | ||
| mod scope; | ||
| mod self_disabling; | ||
| mod store; | ||
| mod strong_retention_checker; | ||
| pub mod support; | ||
| mod weak_retention_checker; | ||
|
|
||
| pub use propagation_checker::*; | ||
| pub use retention_checker::*; | ||
| pub use scope::*; | ||
| pub use self_disabling::*; | ||
| pub use store::*; | ||
| pub use strong_retention_checker::*; | ||
| pub use weak_retention_checker::*; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| use pumpkin_checking::BoxedChecker; | ||
| use pumpkin_checking::VariableState; | ||
|
|
||
| use crate::predicates::Predicate; | ||
| use crate::propagation::Domains; | ||
| use crate::propagation::ReadDomains; | ||
| use crate::variables::DomainId; | ||
|
|
||
| /// Tests whether an inference is correct given the solver state. | ||
| /// | ||
| /// An inference is correct when: | ||
| /// 1. All premises are satisfied. | ||
| /// 2. The conjunction of the premises and negation of the consequent is consistent. | ||
| /// 3. The consequent is logically entailed given the inference code. | ||
| #[derive(Clone, Debug)] | ||
| pub struct PropagationChecker { | ||
| inference_checker: BoxedChecker<Predicate>, | ||
| } | ||
|
|
||
| impl PropagationChecker { | ||
| /// Create a new propagation checker given an inference checker and inference code. | ||
| pub fn new(inference_checker: BoxedChecker<Predicate>) -> PropagationChecker { | ||
| PropagationChecker { inference_checker } | ||
| } | ||
|
|
||
| /// Run the propagation checker for the given inference. | ||
| pub fn check( | ||
| &self, | ||
| premises: &[Predicate], | ||
| consequent: Option<Predicate>, | ||
| domains: Domains<'_>, | ||
| ) -> Result<(), InvalidInference> { | ||
| let premises_satisfied = premises | ||
| .iter() | ||
| .all(|&premise| domains.evaluate_predicate(premise) == Some(true)); | ||
|
|
||
| if !premises_satisfied { | ||
| return Err(InvalidInference::UnsatisfiedPremises); | ||
| } | ||
|
|
||
| let variable_state = | ||
| VariableState::prepare_for_conflict_check(premises.iter().copied(), consequent) | ||
| .map_err(InvalidInference::InconsistentPredicates)?; | ||
|
|
||
| if self | ||
| .inference_checker | ||
| .check(variable_state, premises, consequent.as_ref()) | ||
| { | ||
| Ok(()) | ||
| } else { | ||
| Err(InvalidInference::Unsound) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| pub enum InvalidInference { | ||
| /// Not all premises are true given the current state. | ||
| UnsatisfiedPremises, | ||
| /// The predicates that make up the inference are trivially inconsistent. | ||
| InconsistentPredicates(DomainId), | ||
| /// Cannot establish that the inference is sound. | ||
| Unsound, | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.