aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-dse
diff options
context:
space:
mode:
authorLibravatar Attila Ficsor <ficsorattila96@gmail.com>2023-08-08 13:20:07 +0200
committerLibravatar Attila Ficsor <ficsorattila96@gmail.com>2023-08-08 13:20:07 +0200
commitf889dea154c57fd1831abc0db766f367665c0f60 (patch)
treed5c06e201c97d28c72895998dcbe95224605874f /subprojects/store-dse
parentReduce complexity of Depth first search (diff)
downloadrefinery-f889dea154c57fd1831abc0db766f367665c0f60.tar.gz
refinery-f889dea154c57fd1831abc0db766f367665c0f60.tar.zst
refinery-f889dea154c57fd1831abc0db766f367665c0f60.zip
Improve performance of best first earch
Diffstat (limited to 'subprojects/store-dse')
-rw-r--r--subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/Fitness.java1
-rw-r--r--subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStrategy.java19
2 files changed, 16 insertions, 4 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/Fitness.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/Fitness.java
index 0bf956d2..b1dc4442 100644
--- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/Fitness.java
+++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/objectives/Fitness.java
@@ -32,6 +32,7 @@ public class Fitness extends HashMap<String, Double> {
32 public boolean equals(Object other) { 32 public boolean equals(Object other) {
33 if (other == null) return false; 33 if (other == null) return false;
34 if (getClass() != other.getClass()) return false; 34 if (getClass() != other.getClass()) return false;
35 if (!super.equals(other)) return false;
35 return satisfiesHardObjectives == ((Fitness) other).satisfiesHardObjectives; 36 return satisfiesHardObjectives == ((Fitness) other).satisfiesHardObjectives;
36 } 37 }
37 38
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStrategy.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStrategy.java
index 98af5695..0883d3d7 100644
--- a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStrategy.java
+++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/strategy/BestFirstStrategy.java
@@ -16,10 +16,7 @@ import tools.refinery.store.dse.internal.Activation;
16import tools.refinery.store.dse.objectives.Fitness; 16import tools.refinery.store.dse.objectives.Fitness;
17import tools.refinery.store.dse.objectives.ObjectiveComparatorHelper; 17import tools.refinery.store.dse.objectives.ObjectiveComparatorHelper;
18 18
19import java.util.Collection; 19import java.util.*;
20import java.util.Iterator;
21import java.util.List;
22import java.util.PriorityQueue;
23 20
24public class BestFirstStrategy implements Strategy { 21public class BestFirstStrategy implements Strategy {
25 22
@@ -37,6 +34,20 @@ public class BestFirstStrategy implements Strategy {
37 public String toString() { 34 public String toString() {
38 return trajectory.toString() + fitness.toString(); 35 return trajectory.toString() + fitness.toString();
39 } 36 }
37
38 @Override
39 public int hashCode() {
40 return trajectory.get(trajectory.size() - 1).hashCode();
41 }
42
43 @Override
44 public boolean equals(Object obj) {
45 if (obj instanceof TrajectoryWithFitness other) {
46 return Objects.equals(trajectory.get(trajectory.size() - 1), other.trajectory.get(other.trajectory.size() - 1));
47// return trajectory.equals(((TrajectoryWithFitness) obj).trajectory);
48 }
49 return false;
50 }
40 } 51 }
41 52
42 public BestFirstStrategy() { 53 public BestFirstStrategy() {