diff options
author | 2023-09-05 21:05:49 +0200 | |
---|---|---|
committer | 2023-09-05 21:05:49 +0200 | |
commit | 4780a5796ca6018adcead309f15898a097b584dd (patch) | |
tree | f75cb1331ec3f47089a34bad1cc93d5597e1d365 /subprojects/store-dse/src/main | |
parent | fixed numerous issues with activation coder (diff) | |
parent | Add minor improvements and fixes for explorer (diff) | |
download | refinery-4780a5796ca6018adcead309f15898a097b584dd.tar.gz refinery-4780a5796ca6018adcead309f15898a097b584dd.tar.zst refinery-4780a5796ca6018adcead309f15898a097b584dd.zip |
Merge pull request #1 from nagilooh/datastructure
Add minor improvements and fixes for explorer
Diffstat (limited to 'subprojects/store-dse/src/main')
4 files changed, 10 insertions, 16 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/modification/internal/ModificationStoreAdapterImpl.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/modification/internal/ModificationStoreAdapterImpl.java index 913cb33f..62e4227b 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/modification/internal/ModificationStoreAdapterImpl.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/modification/internal/ModificationStoreAdapterImpl.java | |||
@@ -24,6 +24,6 @@ public class ModificationStoreAdapterImpl implements ModificationStoreAdapter { | |||
24 | 24 | ||
25 | @Override | 25 | @Override |
26 | public ModelAdapter createModelAdapter(Model model) { | 26 | public ModelAdapter createModelAdapter(Model model) { |
27 | return null; | 27 | return new ModificationAdapterImpl(this, model); |
28 | } | 28 | } |
29 | } | 29 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java index 72bbbc55..03a7fca3 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstExplorer.java | |||
@@ -5,7 +5,6 @@ | |||
5 | */ | 5 | */ |
6 | package tools.refinery.store.dse.strategy; | 6 | package tools.refinery.store.dse.strategy; |
7 | 7 | ||
8 | import tools.refinery.store.dse.transition.ObjectiveValue; | ||
9 | import tools.refinery.store.dse.transition.VersionWithObjectiveValue; | 8 | import tools.refinery.store.dse.transition.VersionWithObjectiveValue; |
10 | import tools.refinery.store.model.Model; | 9 | import tools.refinery.store.model.Model; |
11 | 10 | ||
@@ -32,13 +31,11 @@ public class BestFirstExplorer extends BestFirstWorker { | |||
32 | public void explore() { | 31 | public void explore() { |
33 | VersionWithObjectiveValue lastVisited = submit().newVersion(); | 32 | VersionWithObjectiveValue lastVisited = submit().newVersion(); |
34 | 33 | ||
35 | mainLoop: while (shouldRun()) { | 34 | while (shouldRun()) { |
36 | 35 | ||
37 | if (lastVisited == null) { | 36 | if (lastVisited == null) { |
38 | var restored = this.restoreToBest(); | 37 | lastVisited = this.restoreToBest(); |
39 | if(restored != null) { | 38 | if(lastVisited == null) { |
40 | lastVisited = restored; | ||
41 | } else { | ||
42 | return; | 39 | return; |
43 | } | 40 | } |
44 | } | 41 | } |
@@ -47,7 +44,7 @@ public class BestFirstExplorer extends BestFirstWorker { | |||
47 | while(tryActivation && shouldRun()) { | 44 | while(tryActivation && shouldRun()) { |
48 | RandomVisitResult randomVisitResult = this.visitRandomUnvisited(random); | 45 | RandomVisitResult randomVisitResult = this.visitRandomUnvisited(random); |
49 | 46 | ||
50 | tryActivation &= randomVisitResult.shouldRetry(); | 47 | tryActivation = randomVisitResult.shouldRetry(); |
51 | var newSubmit = randomVisitResult.submitResult(); | 48 | var newSubmit = randomVisitResult.submitResult(); |
52 | if(newSubmit != null) { | 49 | if(newSubmit != null) { |
53 | if(!newSubmit.include()) { | 50 | if(!newSubmit.include()) { |
@@ -57,7 +54,7 @@ public class BestFirstExplorer extends BestFirstWorker { | |||
57 | int compareResult = compare(lastVisited,newVisit); | 54 | int compareResult = compare(lastVisited,newVisit); |
58 | if(compareResult >= 0) { | 55 | if(compareResult >= 0) { |
59 | lastVisited = newVisit; | 56 | lastVisited = newVisit; |
60 | continue mainLoop; | 57 | break; |
61 | } | 58 | } |
62 | } | 59 | } |
63 | } | 60 | } |
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStoreManager.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStoreManager.java index d1fd7884..3795daa4 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStoreManager.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStoreManager.java | |||
@@ -35,7 +35,7 @@ public class BestFirstStoreManager { | |||
35 | objectiveStore = new ObjectivePriorityQueueImpl(storeAdapter.getObjectives()); | 35 | objectiveStore = new ObjectivePriorityQueueImpl(storeAdapter.getObjectives()); |
36 | Procedure<VersionWithObjectiveValue> whenAllActivationsVisited = x -> objectiveStore.remove(x); | 36 | Procedure<VersionWithObjectiveValue> whenAllActivationsVisited = x -> objectiveStore.remove(x); |
37 | activationStore = new ActivationStoreImpl(storeAdapter.getTransformations().size(), whenAllActivationsVisited); | 37 | activationStore = new ActivationStoreImpl(storeAdapter.getTransformations().size(), whenAllActivationsVisited); |
38 | solutionStore = new SolutionStoreImpl(1); | 38 | solutionStore = new SolutionStoreImpl(10); |
39 | equivalenceClassStore = new FastEquivalenceClassStore(modelStore.getAdapter(StateCoderStoreAdapter.class)) { | 39 | equivalenceClassStore = new FastEquivalenceClassStore(modelStore.getAdapter(StateCoderStoreAdapter.class)) { |
40 | @Override | 40 | @Override |
41 | protected void delegate(VersionWithObjectiveValue version, int[] emptyActivations, boolean accept) { | 41 | protected void delegate(VersionWithObjectiveValue version, int[] emptyActivations, boolean accept) { |
@@ -56,7 +56,7 @@ public class BestFirstStoreManager { | |||
56 | return activationStore; | 56 | return activationStore; |
57 | } | 57 | } |
58 | 58 | ||
59 | SolutionStore getSolutionStore() { | 59 | public SolutionStore getSolutionStore() { |
60 | return solutionStore; | 60 | return solutionStore; |
61 | } | 61 | } |
62 | 62 | ||
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstWorker.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstWorker.java index ea7fe43f..4240fdf9 100644 --- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstWorker.java +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstWorker.java | |||
@@ -13,7 +13,6 @@ import tools.refinery.store.map.Version; | |||
13 | import tools.refinery.store.model.Model; | 13 | import tools.refinery.store.model.Model; |
14 | import tools.refinery.store.statecoding.StateCoderAdapter; | 14 | import tools.refinery.store.statecoding.StateCoderAdapter; |
15 | 15 | ||
16 | |||
17 | import java.util.Random; | 16 | import java.util.Random; |
18 | 17 | ||
19 | public class BestFirstWorker { | 18 | public class BestFirstWorker { |
@@ -31,6 +30,7 @@ public class BestFirstWorker { | |||
31 | stateCoderAdapter = model.getAdapter(StateCoderAdapter.class); | 30 | stateCoderAdapter = model.getAdapter(StateCoderAdapter.class); |
32 | activationStoreWorker = new ActivationStoreWorker(storeManager.getActivationStore(), | 31 | activationStoreWorker = new ActivationStoreWorker(storeManager.getActivationStore(), |
33 | explorationAdapter.getTransformations()); | 32 | explorationAdapter.getTransformations()); |
33 | |||
34 | } | 34 | } |
35 | 35 | ||
36 | private VersionWithObjectiveValue last = null; | 36 | private VersionWithObjectiveValue last = null; |
@@ -48,12 +48,9 @@ public class BestFirstWorker { | |||
48 | var res = new VersionWithObjectiveValue(version, objectiveValue); | 48 | var res = new VersionWithObjectiveValue(version, objectiveValue); |
49 | var code = stateCoderAdapter.calculateStateCode(); | 49 | var code = stateCoderAdapter.calculateStateCode(); |
50 | var accepted = explorationAdapter.checkAccept(); | 50 | var accepted = explorationAdapter.checkAccept(); |
51 | |||
52 | boolean isNew = storeManager.getEquivalenceClassStore().submit(res, code, | 51 | boolean isNew = storeManager.getEquivalenceClassStore().submit(res, code, |
53 | activationStoreWorker.calculateEmptyActivationSize(), accepted); | 52 | activationStoreWorker.calculateEmptyActivationSize(), accepted); |
54 | 53 | return new SubmitResult(isNew, accepted, objectiveValue, isNew ? res : null); | |
55 | last = new VersionWithObjectiveValue(version, objectiveValue); | ||
56 | return new SubmitResult(isNew, accepted, objectiveValue, last); | ||
57 | } | 54 | } |
58 | 55 | ||
59 | public void restoreToLast() { | 56 | public void restoreToLast() { |