Skip to content

Commit

Permalink
Fix hull operation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelCourtney committed Sep 13, 2023
1 parent 794143e commit e013ee9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,10 @@ public ConstraintResult evaluate(SimulationResults results, final Interval bound
}
}
if (this.algorithm == RollingThresholdAlgorithm.ExcessHull || this.algorithm == RollingThresholdAlgorithm.DeficitHull) {
final var hull = Interval.between(
violationIntervals.get(0).start,
violationIntervals.get(0).startInclusivity,
violationIntervals.get(violationIntervals.size() - 1).end,
violationIntervals.get(violationIntervals.size() - 1).endInclusivity
);
var hull = violationIntervals.get(0);
for (final var interval: violationIntervals.subList(1, violationIntervals.size())) {
hull = Interval.unify(hull, interval);
}
violationIntervals.clear();
violationIntervals.add(hull);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,10 @@ public void testRollingThresholdExcess() {
);

final var spans = new Spans(
// These two are out of order to make sure RollingThreshold's hull operation correctly handles unsorted spans.
Interval.between(4, 5, SECONDS),
Interval.between(0, 1, SECONDS),
Interval.between(2, 3, SECONDS),
Interval.between(4, 5, SECONDS),

Interval.between(14, 15, SECONDS),
Interval.between(16, 17, SECONDS),
Expand Down Expand Up @@ -1174,9 +1175,9 @@ public void testRollingThresholdExcess() {
List.of(
new Violation(
List.of(
Interval.between(4, 5, SECONDS),
Interval.between(0, 1, SECONDS),
Interval.between(2, 3, SECONDS),
Interval.between(4, 5, SECONDS)
Interval.between(2, 3, SECONDS)
), List.of()
),
new Violation(
Expand Down

0 comments on commit e013ee9

Please sign in to comment.