diff options
author | Attila Ficsor <ficsorattila96@gmail.com> | 2023-08-08 13:20:07 +0200 |
---|---|---|
committer | Attila Ficsor <ficsorattila96@gmail.com> | 2023-08-08 13:20:07 +0200 |
commit | f889dea154c57fd1831abc0db766f367665c0f60 (patch) | |
tree | d5c06e201c97d28c72895998dcbe95224605874f /subprojects/store-dse/src | |
parent | Reduce complexity of Depth first search (diff) | |
download | refinery-f889dea154c57fd1831abc0db766f367665c0f60.tar.gz refinery-f889dea154c57fd1831abc0db766f367665c0f60.tar.zst refinery-f889dea154c57fd1831abc0db766f367665c0f60.zip |
Improve performance of best first earch
Diffstat (limited to 'subprojects/store-dse/src')
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; | |||
16 | import tools.refinery.store.dse.objectives.Fitness; | 16 | import tools.refinery.store.dse.objectives.Fitness; |
17 | import tools.refinery.store.dse.objectives.ObjectiveComparatorHelper; | 17 | import tools.refinery.store.dse.objectives.ObjectiveComparatorHelper; |
18 | 18 | ||
19 | import java.util.Collection; | 19 | import java.util.*; |
20 | import java.util.Iterator; | ||
21 | import java.util.List; | ||
22 | import java.util.PriorityQueue; | ||
23 | 20 | ||
24 | public class BestFirstStrategy implements Strategy { | 21 | public 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() { |