@Override
 public void phaseStarted(AbstractPhaseScope phaseScope) {
   InnerScoreDirector scoreDirector = phaseScope.getScoreDirector();
   constraintMatchEnabled = scoreDirector.isConstraintMatchEnabled();
   if (!constraintMatchEnabled) {
     logger.warn(
         "The singleStatistic ({}) cannot function properly"
             + " because ConstraintMatches are not supported on the ScoreDirector.",
         singleStatisticType);
   }
 }
  @Test
  public void phaseTermination() {
    Termination termination = new StepCountTermination(4);
    AbstractPhaseScope phaseScope = mock(AbstractPhaseScope.class);

    when(phaseScope.getNextStepIndex()).thenReturn(0);
    assertEquals(false, termination.isPhaseTerminated(phaseScope));
    assertEquals(0.0, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
    when(phaseScope.getNextStepIndex()).thenReturn(1);
    assertEquals(false, termination.isPhaseTerminated(phaseScope));
    assertEquals(0.25, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
    when(phaseScope.getNextStepIndex()).thenReturn(2);
    assertEquals(false, termination.isPhaseTerminated(phaseScope));
    assertEquals(0.5, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
    when(phaseScope.getNextStepIndex()).thenReturn(3);
    assertEquals(false, termination.isPhaseTerminated(phaseScope));
    assertEquals(0.75, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
    when(phaseScope.getNextStepIndex()).thenReturn(4);
    assertEquals(true, termination.isPhaseTerminated(phaseScope));
    assertEquals(1.0, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
    when(phaseScope.getNextStepIndex()).thenReturn(5);
    assertEquals(true, termination.isPhaseTerminated(phaseScope));
    assertEquals(1.0, termination.calculatePhaseTimeGradient(phaseScope), 0.0);
  }
 public void phaseEnded(AbstractPhaseScope phaseScope) {
   if (cacheType == SelectionCacheType.PHASE) {
     selectionCacheLifecycleListener.disposeCache(phaseScope.getSolverScope());
   }
 }
 public void phaseStarted(AbstractPhaseScope phaseScope) {
   if (cacheType == SelectionCacheType.PHASE) {
     selectionCacheLifecycleListener.constructCache(phaseScope.getSolverScope());
   }
 }