-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Make Literal wrapper of Predicate #398
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
ImkoMarijnissen
wants to merge
25
commits into
main
Choose a base branch
from
feat/literal-atomic
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 13 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ce4da57
feat: initial setup for making literal wrapper around atomic
ImkoMarijnissen 2363a7e
chore: cleanup
ImkoMarijnissen 5224ac3
chore: place todo in bool2int
ImkoMarijnissen 856e025
refactor: avoid duplicate notification + properly notifying or removal
ImkoMarijnissen ff21389
fix: bug in notifications not working properly
ImkoMarijnissen 233f391
chore: remove check for duplicate notifications in system
ImkoMarijnissen 22561ac
refactor: create structure for watch list literals and predicate ids
ImkoMarijnissen e9b25e1
Merge branch 'main' into feat/literal-atomic
ImkoMarijnissen 0657c57
fix: add enum for integer variable to be able to post elements
ImkoMarijnissen 1e32139
fix: introduce enum for boolean + fixing backtrack events + correctly…
ImkoMarijnissen b8c8b9b
fix: initial attempt at fix for python interface
ImkoMarijnissen 0812291
refactor: moving everything to IntExpression
ImkoMarijnissen 63b8a11
fix: issues with python interface
ImkoMarijnissen 08bd014
refactor: merge watch lists
ImkoMarijnissen 137ca1e
refactor: WIP - remove literal in its entirety and move to predicate
ImkoMarijnissen f7743a2
fix: test cases + update docs
ImkoMarijnissen 90647bb
Merge branch 'main' into feat/literal-atomic
ImkoMarijnissen 1232285
refactor: rename to AnyInteger and move to new file
ImkoMarijnissen 895b8e3
refactor: do not store affineview in AnyInteger
ImkoMarijnissen c3e2b63
fix: affine view
ImkoMarijnissen 35a4b22
chore: apply comments
ImkoMarijnissen 6d3ffa6
Merge branch 'main' into feat/literal-atomic
ImkoMarijnissen 1339241
fix: as_expression to as_integer
ImkoMarijnissen e587c93
test: use bitset for tracking whether predicateid has already been no…
ImkoMarijnissen ae1c0c4
fix: properly check whether predicate id notification has occurred
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
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
92 changes: 92 additions & 0 deletions
92
...crates/core/src/engine/notifications/domain_event_notification/watch_list_predicate_id.rs
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,92 @@ | ||
| use enumset::EnumSet; | ||
|
|
||
| use crate::basic_types::PredicateId; | ||
| use crate::containers::HashMap; | ||
| use crate::containers::KeyedVec; | ||
| use crate::propagation::DomainEvent; | ||
| use crate::propagation::LocalId; | ||
| use crate::propagation::PropagatorVarId; | ||
| use crate::state::PropagatorId; | ||
| use crate::variables::Literal; | ||
|
|
||
| #[derive(Debug, Default, Clone)] | ||
| pub(crate) struct PredicateWatchList { | ||
| /// The watch list from predicates to propagators. | ||
| pub(crate) watch_list_predicate_id: KeyedVec<PredicateId, Vec<PropagatorId>>, | ||
| // TODO: Should use direct hashing | ||
| pub(crate) literal_watch_list: | ||
| HashMap<Literal, HashMap<PropagatorId, (LocalId, EnumSet<DomainEvent>)>>, | ||
| pub(crate) literal_watch_list_backtrack: | ||
| HashMap<Literal, HashMap<PropagatorId, (LocalId, EnumSet<DomainEvent>)>>, | ||
| } | ||
|
|
||
| impl PredicateWatchList { | ||
| pub(crate) fn watch_predicate_id( | ||
| &mut self, | ||
| predicate_id: PredicateId, | ||
| propagator_id: PropagatorId, | ||
| ) { | ||
| self.watch_list_predicate_id | ||
| .accomodate(predicate_id, vec![]); | ||
| self.watch_list_predicate_id[predicate_id].push(propagator_id); | ||
| } | ||
|
|
||
| pub(crate) fn watchers_predicate_id_mut( | ||
| &mut self, | ||
| predicate_id: PredicateId, | ||
| ) -> Option<&mut Vec<PropagatorId>> { | ||
| self.watch_list_predicate_id.get_mut(predicate_id) | ||
| } | ||
|
|
||
| pub(crate) fn watchers_predicate_id( | ||
| &self, | ||
| predicate_id: PredicateId, | ||
| ) -> Option<&Vec<PropagatorId>> { | ||
| self.watch_list_predicate_id.get(predicate_id) | ||
| } | ||
|
|
||
| pub(crate) fn insert_literal_watcher( | ||
| &mut self, | ||
| literal: Literal, | ||
| propagator_var: PropagatorVarId, | ||
| events: EnumSet<DomainEvent>, | ||
| ) { | ||
| let entry = self | ||
| .literal_watch_list | ||
| .entry(literal) | ||
| .or_default() | ||
| .entry(propagator_var.propagator) | ||
| .or_insert((propagator_var.variable, events)); | ||
| entry.1 |= events; | ||
| } | ||
|
|
||
| pub(crate) fn insert_literal_watcher_backtrack( | ||
| &mut self, | ||
| literal: Literal, | ||
| propagator_var: PropagatorVarId, | ||
| events: EnumSet<DomainEvent>, | ||
| ) { | ||
| let entry = self | ||
| .literal_watch_list_backtrack | ||
| .entry(literal) | ||
| .or_default() | ||
| .entry(propagator_var.propagator) | ||
| .or_insert((propagator_var.variable, events)); | ||
| entry.1 |= events; | ||
| } | ||
|
|
||
| pub(crate) fn watchers_literal_propagator( | ||
| &self, | ||
| literal: Literal, | ||
| propagator_id: PropagatorId, | ||
| ) -> Option<&(LocalId, EnumSet<DomainEvent>)> { | ||
| self.literal_watch_list | ||
| .get(&literal) | ||
| .and_then(|inner| inner.get(&propagator_id)) | ||
| .or_else(|| { | ||
| self.literal_watch_list | ||
| .get(&(!literal)) | ||
| .and_then(|inner| inner.get(&propagator_id)) | ||
| }) | ||
| } | ||
| } | ||
Oops, something went wrong.
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.