diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ActivityWindow.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ActivityWindow.java index 9a566eebfa..1ad673d159 100644 --- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ActivityWindow.java +++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ActivityWindow.java @@ -20,7 +20,7 @@ public ActivityWindow(final String activityAlias) { public Windows evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) { final var activity = environment.activityInstances().get(this.activityAlias); return new Windows( - Segment.of(Interval.FOREVER, false), + Segment.of(bounds, false), Segment.of(activity.interval, true) ); } diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteParameter.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteParameter.java index 10409e5a1b..4c336c4219 100644 --- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteParameter.java +++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteParameter.java @@ -22,7 +22,7 @@ public DiscreteParameter(final String activityAlias, final String parameterName) public DiscreteProfile evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) { final var activity = environment.activityInstances().get(this.activityAlias); return new DiscreteProfile( - Segment.of(Interval.FOREVER, activity.parameters.get(this.parameterName)) + Segment.of(bounds, activity.parameters.get(this.parameterName)) ); } diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteProfileFromDuration.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteProfileFromDuration.java index dce82b04f9..0409afbc3f 100644 --- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteProfileFromDuration.java +++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/DiscreteProfileFromDuration.java @@ -18,7 +18,7 @@ public record DiscreteProfileFromDuration( @Override public DiscreteProfile evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) { final Duration duration = this.duration.evaluate(results, bounds, environment); - return new DiscreteProfile(Segment.of(Interval.FOREVER, SerializedValue.of(duration.in(Duration.MICROSECOND)))); + return new DiscreteProfile(Segment.of(bounds, SerializedValue.of(duration.in(Duration.MICROSECOND)))); } @Override diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/EndOf.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/EndOf.java index 77654d0967..1fd684bcd2 100644 --- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/EndOf.java +++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/EndOf.java @@ -20,7 +20,7 @@ public EndOf(final String activityAlias) { public Windows evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) { final var activity = environment.activityInstances().get(this.activityAlias); return new Windows( - Segment.of(Interval.FOREVER, false), + Segment.of(bounds, false), Segment.of(Interval.at(activity.interval.end), true) ); } diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftBy.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftBy.java index 2db8a1a1f6..903e9edf3b 100644 --- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftBy.java +++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftBy.java @@ -14,9 +14,12 @@ public record ShiftBy
>(
@Override
public P evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) {
- final var originalProfile = this.expression.evaluate(results, bounds, environment);
+ // bounds aren't shifted here because duration expressions don't care about them; durations don't exist on the timeline.
final var duration = this.duration.evaluate(results, bounds, environment);
+ final var shiftedBounds = bounds.shiftBy(Duration.negate(duration));
+ final var originalProfile = this.expression.evaluate(results, shiftedBounds, environment);
+
return originalProfile.shiftBy(duration);
}
diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftWindowsEdges.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftWindowsEdges.java
index 020a9ed560..0db61054bc 100644
--- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftWindowsEdges.java
+++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/ShiftWindowsEdges.java
@@ -22,8 +22,18 @@ public ShiftWindowsEdges(final Expression