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 2f9c889ef1..a33d75c673 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 @@ -497,7 +497,7 @@ private void rollback(Goal goal){ plan.remove(insertedActivities); evalForGoal.removeAssociation(associatedActivities); evalForGoal.removeAssociation(insertedActivities); - evalForGoal.setScore(-(evalForGoal.getNbConflictsDetected().get())); + evalForGoal.setScore(-(evalForGoal.getNbConflictsDetected().orElse(1))); } private void satisfyCompositeGoal(CompositeAndGoal goal) { @@ -510,6 +510,13 @@ private void satisfyCompositeGoal(CompositeAndGoal goal) { if (evaluation.forGoal(subgoal).getScore() == 0) { logger.info("AND goal " + goal.getName() + ": subgoal " + subgoal.getName() + " has been satisfied, moving on to next subgoal"); nbGoalSatisfied++; + } else { + logger.info("AND goal " + goal.getName() + ": subgoal " + subgoal.getName() + " has NOT been satisfied"); + if(goal.shouldRollbackIfUnsatisfied()){ + logger.info("AND goal " + goal.getName() + ": stopping goal satisfaction after first failure, remove shouldRollbackIfUnsatisfied(true) on AND goal to maximize satisfaction instead of early termination"); + break; + } + logger.info("AND goal " + goal.getName() + ": moving on to next subgoal (trying to maximize satisfaction)"); } } final var goalIsSatisfied = (nbGoalSatisfied == goal.getSubgoals().size()); diff --git a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestUnsatisfiableCompositeGoals.java b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestUnsatisfiableCompositeGoals.java index 2298e70fba..9340efa3e3 100644 --- a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestUnsatisfiableCompositeGoals.java +++ b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/TestUnsatisfiableCompositeGoals.java @@ -137,7 +137,7 @@ public void testAndWithBackTrack(){ Assertions.assertTrue(TestUtility.activityStartingAtTime(plan, t1hr, actTypeControllable)); Assertions.assertTrue(TestUtility.activityStartingAtTime(plan, t2hr, actTypeControllable)); Assertions.assertEquals(plan.getActivities().size(), 2); - assertEquals(4, problem.getSimulationFacade().countSimulationRestarts()); + assertEquals(2, problem.getSimulationFacade().countSimulationRestarts()); } @Test