-
Notifications
You must be signed in to change notification settings - Fork 205
Add feedback-guided scheduling algorithms #791
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c7dd158
Add feedback strategy. (#715)
aoli-al c6f74dc
Improving the code with some cleanup. (#719)
ankushdesai 3f4781a
PR cleanup (#723)
aoli-al 9241ed4
Merge Recent Bug Fixes (#778)
ankushdesai 9446874
Fix feedback strategy and remove experiment features.
aoli-al 5c98bc9
Merge branch 'master' into experimental/feedback-strategy
aoli-al 9d91a54
Removing Pattern (#786)
ChristineZh0u 5f65c5c
Remove conflict analysis
6537ce6
Merge pull request #787 from p-org/experimental/feedback_cleanup
ChristineZh0u ccaa276
Removing compiler changes (#789)
ChristineZh0u 61fa8d3
Cleanup.
aoli-al 548f0f6
Revert changes to Event.
aoli-al e2dc756
Merge branch 'master' into experimental/feedback
ankushdesai 52dc10a
Revert changes.
aoli-al cfdc88e
Merge branch 'master' into experimental/feedback
aoli-al 8510ec4
Fix merge conflicts.
aoli-al 6262502
Remove temp file.
aoli-al c183bcb
Merge branch 'master' into experimental/feedback
ChristineZh0u 907dcd1
Rename LastSentReceiver to MessageReceiver
aoli-al 0a371a8
Merge branch 'master' into experimental/feedback
ankushdesai 6a4110c
Merge branch 'master' into experimental/feedback
ankushdesai 8153cd6
Simplify scheduler implementation.
aoli-al d8331b8
Revert changes in QLearning strategy.
aoli-al b4837da
Refactor.
aoli-al 6bd65eb
Merge branch 'master' into experimental/feedback
ankushdesai 2eda040
Added VectorTime and BehavioralObserver class for feedback strategy (…
ChristineZh0u 5e306b4
Revert changes in PCTStrategy.
aoli-al 91cd717
Revert changes in Probabilistic folder.
aoli-al 3ee77e3
revert change.
aoli-al 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using PChecker.Runtime.StateMachines; | ||
| using PChecker.IO.Logging; | ||
|
|
||
| public class VectorTime | ||
| { | ||
| // Dictionary that uses StateMachineId as the key and stores the logical clock as the value | ||
| public Dictionary<StateMachineId, int> Clock { get; private set; } | ||
|
|
||
| // The ID of the current state machine | ||
|
|
||
| private StateMachineId stateMachineId; | ||
|
|
||
| public VectorTime(StateMachineId stateMachineId) | ||
| { | ||
| this.stateMachineId = stateMachineId; | ||
| Clock = new Dictionary<StateMachineId, int>(); | ||
| Clock[stateMachineId] = 0; // Initialize the clock for this state machine | ||
| } | ||
|
|
||
| // Clone constructor (creates a snapshot of the vector clock) | ||
| public VectorTime(VectorTime other) | ||
| { | ||
| Clock = new Dictionary<StateMachineId, int>(other.Clock); | ||
| } | ||
|
|
||
| // Increment the logical clock for this state machine | ||
| public void Increment() | ||
| { | ||
| Clock[stateMachineId]++; | ||
| } | ||
|
|
||
| // Merge another vector clock into this one | ||
| public void Merge(VectorTime otherTime) | ||
| { | ||
| foreach (var entry in otherTime.Clock) | ||
| { | ||
| StateMachineId otherMachineId = entry.Key; | ||
| int otherTimestamp = entry.Value; | ||
|
|
||
| if (Clock.ContainsKey(otherMachineId)) | ||
| { | ||
| // Take the maximum timestamp for each state machine | ||
| Clock[otherMachineId] = Math.Max(Clock[otherMachineId], otherTimestamp); | ||
| } | ||
| else | ||
| { | ||
| // Add the state machine's timestamp if it doesn't exist in this time | ||
| Clock[otherMachineId] = otherTimestamp; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Compare this vector clock to another for sorting purposes | ||
| // Rturn value: -1 = This vector clock happens after the other, 1 = This vector clock happens before the other, | ||
| // 0 = Clocks are equal or concurrent | ||
| public int CompareTo(VectorTime other) | ||
| { | ||
| bool atLeastOneLess = false; | ||
| bool atLeastOneGreater = false; | ||
|
|
||
| foreach (var machineId in Clock.Keys) | ||
| { | ||
| int thisTime = Clock[machineId]; | ||
| int otherTime = other.Clock.ContainsKey(machineId) ? other.Clock[machineId] : 0; | ||
|
|
||
| if (thisTime < otherTime) | ||
| { | ||
| atLeastOneLess = true; | ||
| } | ||
| else if (thisTime > otherTime) | ||
| { | ||
| atLeastOneGreater = true; | ||
| } | ||
| if (atLeastOneLess && atLeastOneGreater) | ||
| { | ||
| return 0; | ||
| } | ||
| } | ||
| if (atLeastOneLess && !atLeastOneGreater) | ||
| { | ||
| return -1; | ||
| } | ||
| if (atLeastOneGreater && !atLeastOneLess) | ||
| { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| public override string ToString() | ||
| { | ||
| var elements = new List<string>(); | ||
| foreach (var entry in Clock) | ||
| { | ||
| elements.Add($"StateMachine {entry.Key.Name}: {entry.Value}"); | ||
| } | ||
| return $"[{string.Join(", ", elements)}]"; | ||
| } | ||
|
|
||
| public override bool Equals(object obj) | ||
| { | ||
| if (obj is VectorTime other) | ||
| { | ||
| return Clock.OrderBy(x => x.Key).SequenceEqual(other.Clock.OrderBy(x => x.Key)); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| public override int GetHashCode() | ||
| { | ||
| int hash = 17; | ||
| foreach (var entry in Clock) | ||
| { | ||
| hash = hash * 31 + entry.Key.GetHashCode(); | ||
| hash = hash * 31 + entry.Value.GetHashCode(); | ||
| } | ||
| return hash; | ||
| } | ||
| } |
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
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.