> ancestors() {
@@ -256,32 +263,18 @@ private Stream> unexcludedDescendantsOfNode() {
if (this.isSubsumed()) {
return Stream.empty();
} else {
- return Stream.concat(Stream.of(this),
- this.children().flatMap(ArgNode::unexcludedDescendantsOfNode));
+ return Stream.concat(Stream.of(this), this.children().flatMap(ArgNode::unexcludedDescendantsOfNode));
}
}
////
- @Override
- public int hashCode() {
- int result = hashCode;
- if (result == 0) {
- result = HASH_SEED;
- result = 31 * result + id;
- hashCode = result;
- }
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- return super.equals(obj);
- }
-
@Override
public String toString() {
return Utils.lispStringBuilder("ArgNode").add(id).body().add(state).toString();
}
+ public void disableCoveringAbility() {
+ canCover = false;
+ }
}
diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgNodeComparators.java b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgNodeComparators.java
index c990cdb893..fde6fb2f56 100644
--- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgNodeComparators.java
+++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgNodeComparators.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023 Budapest University of Technology and Economics
+ * Copyright 2024 Budapest University of Technology and Economics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgStructuralEquality.java b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgStructuralEquality.java
new file mode 100644
index 0000000000..8003232ff9
--- /dev/null
+++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/ArgStructuralEquality.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2024 Budapest University of Technology and Economics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package hu.bme.mit.theta.analysis.algorithm;
+
+import hu.bme.mit.theta.analysis.Action;
+import hu.bme.mit.theta.analysis.State;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Objects.equal;
+
+/**
+ * Structural comparisons using equal() and hashCode() for ARG-related classes.
+ * Each node is uniquely identifiable using its incoming edge (or its absence), and wrapped state.
+ * Each edge is uniquely identifiable using its source node, and wrapped action.
+ * An ARG is uniquely identifiable using its leaf nodes.
+ * An ArgTrace is uniquely identifiable using its last node.
+ *
+ * We perform caching for the hash codes, but equals() checks will always traverse the ancestors of
+ * a node (and edge). However, this traversal only goes towards the root, rather than in all
+ * directions.
+ */
+public final class ArgStructuralEquality {
+ private static final Map