diff --git a/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java b/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java index 1a6dbd4ec3..698ca793ba 100644 --- a/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java +++ b/scheduler-driver/src/main/java/gov/nasa/jpl/aerie/scheduler/solver/PrioritySolver.java @@ -207,6 +207,11 @@ private InsertActivityResult checkAndInsertActs(Collection new) that have been replaced in the plan due to updated durations + */ private Map synchronizeSimulationWithSchedulerPlan() { final Map replacedInPlan; try { @@ -620,6 +625,7 @@ else if(!analysisOnly && (missing instanceof MissingActivityTemplateConflict mi assert plan != null; //REVIEW: maybe should have way to request only certain kinds of conflicts final var lastSimulationResults = this.getLatestSimResultsUpTo(this.problem.getPlanningHorizon().getEndAerie()); + synchronizeSimulationWithSchedulerPlan(); final var evaluationEnvironment = new EvaluationEnvironment(this.problem.getRealExternalProfiles(), this.problem.getDiscreteExternalProfiles()); final var rawConflicts = goal.getConflicts(plan, lastSimulationResults, evaluationEnvironment); assert rawConflicts != null; @@ -771,6 +777,7 @@ private Windows narrowByResourceConstraints(Windows windows, final var totalDomain = Interval.between(windows.minTrueTimePoint().get().getKey(), windows.maxTrueTimePoint().get().getKey()); //make sure the simulation results cover the domain final var latestSimulationResults = this.getLatestSimResultsUpTo(totalDomain.end); + synchronizeSimulationWithSchedulerPlan(); //iteratively narrow the windows from each constraint //REVIEW: could be some optimization in constraint ordering (smallest domain first to fail fast) final var evaluationEnvironment = new EvaluationEnvironment(this.problem.getRealExternalProfiles(), this.problem.getDiscreteExternalProfiles()); @@ -793,7 +800,6 @@ private SimulationResults getLatestSimResultsUpTo(Duration time){ if (lastSimResultsFromFacade.isEmpty() || lastSimResultsFromFacade.get().bounds.end.shorterThan(time)) { try { this.simulationFacade.computeSimulationResultsUntil(time); - synchronizeSimulationWithSchedulerPlan(); } catch (SimulationFacade.SimulationException e) { throw new RuntimeException("Exception while running simulation before evaluating conflicts", e); } @@ -814,6 +820,7 @@ private Windows narrowGlobalConstraints( } //make sure the simulation results cover the domain final var latestSimulationResults = this.getLatestSimResultsUpTo(tmp.maxTrueTimePoint().get().getKey()); + synchronizeSimulationWithSchedulerPlan(); for (GlobalConstraint gc : constraints) { if (gc instanceof GlobalConstraintWithIntrospection c) { tmp = c.findWindows(