Skip to content

Commit

Permalink
Distribution.equals fix (use evaluator to compare values).
Browse files Browse the repository at this point in the history
In particular, this means allowing some tolerance for distributions
where probabilities are doubles (1e-12 relative, by default).

This also allows bisimulation minimisation to factor in double
imprecision too.
  • Loading branch information
davexparker committed Jun 10, 2024
1 parent a52c48e commit 294a8b6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion prism/src/explicit/Distribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,20 @@ public boolean equals(Object o)
if (! (o instanceof Distribution)) {
return false;
}
return map.equals(((Distribution<?>) o).map);
// Check elements of distribution using evaluator equals method
HashMap<Integer,Value> oMap = ((Distribution<Value>) o).map;
if (map.size() != oMap.size()) {
return false;
}
for (Map.Entry<Integer,Value> entry : map.entrySet()) {
Integer key = entry.getKey();
Value value = entry.getValue(); // We assume nothing maps to null
Value oValue = oMap.get(key);
if (oValue == null || !getEvaluator().equals(value, oValue)) {
return false;
}
}
return true;
}

@Override
Expand Down

0 comments on commit 294a8b6

Please sign in to comment.