Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelCourtney committed Sep 15, 2023
1 parent c62ee90 commit ff77b25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public enum RollingThresholdAlgorithm {
@Override
public ConstraintResult evaluate(SimulationResults results, final Interval bounds, EvaluationEnvironment environment) {
final var width = this.width.evaluate(results, bounds, environment);
var spans = this.spans.evaluate(results, bounds, environment);
final var spans = this.spans.evaluate(results, bounds, environment);

final Spans reportedSpans;
if (algorithm == RollingThresholdAlgorithm.ExcessHull || algorithm == RollingThresholdAlgorithm.ExcessSpans) {
reportedSpans = spans;
} else {
} else if (algorithm == RollingThresholdAlgorithm.DeficitHull || algorithm == RollingThresholdAlgorithm.DeficitSpans) {
reportedSpans = spans.intoWindows().not().intoSpans(bounds);
} else {
throw new IllegalArgumentException("Algorithm not supported: " + algorithm);
}

final var threshold = this.threshold.evaluate(results, bounds, environment);
Expand All @@ -58,7 +60,7 @@ public ConstraintResult evaluate(SimulationResults results, final Interval bound

if (algorithm == RollingThresholdAlgorithm.ExcessHull || algorithm == RollingThresholdAlgorithm.ExcessSpans) {
leftViolatingBounds = localAccDuration.greaterThan(thresholdEq);
} else {
} else if (algorithm == RollingThresholdAlgorithm.DeficitHull || algorithm == RollingThresholdAlgorithm.DeficitSpans) {
leftViolatingBounds = localAccDuration.lessThan(thresholdEq).select(
Interval.between(
bounds.start,
Expand All @@ -67,6 +69,8 @@ public ConstraintResult evaluate(SimulationResults results, final Interval bound
bounds.endInclusivity
)
);
} else {
throw new IllegalArgumentException("Algorithm not supported: " + algorithm);
}

for (final var leftViolatingBound : leftViolatingBounds.iterateEqualTo(true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class Constraint {
* contributed to the threshold violation in one interval.
* - `DeficitSpans` detects times when the duration falls short of the threshold and highlights the individual gaps between spans
* that contributed to the threshold violation.
* - `ExcessHull` detects times when the duration falls short of the threshold and highlights the whole group of gaps between
* - `DeficitHull` detects times when the duration falls short of the threshold and highlights the whole group of gaps between
* spans that contributed to the threshold violation in one interval.
*
* @param spans spans object to detect threshold events on
Expand Down Expand Up @@ -1108,7 +1108,7 @@ declare global {
* contributed to the threshold violation in one interval.
* - `DeficitSpans` detects times when the duration falls short of the threshold and highlights the individual gaps between spans
* that contributed to the threshold violation.
* - `ExcessHull` detects times when the duration falls short of the threshold and highlights the whole group of gaps between
* - `DeficitHull` detects times when the duration falls short of the threshold and highlights the whole group of gaps between
* spans that contributed to the threshold violation in one interval.
*
* @param spans spans object to detect threshold events on
Expand Down

0 comments on commit ff77b25

Please sign in to comment.