@Test
public void solveTermination() {
FeasibilityScoreDefinition scoreDefinition = mock(FeasibilityScoreDefinition.class);
when(scoreDefinition.getFeasibleLevelsSize()).thenReturn(1);
Termination termination = new BestScoreFeasibleTermination(scoreDefinition, new double[]{});
DefaultSolverScope solverScope = mock(DefaultSolverScope.class);
when(solverScope.getScoreDefinition()).thenReturn(new HardSoftScoreDefinition());
when(solverScope.getStartingInitializedScore()).thenReturn(HardSoftScore.valueOf(-100, -100));
when(solverScope.isBestSolutionInitialized()).thenReturn(true);
when(solverScope.getBestScore()).thenReturn(HardSoftScore.valueOf(-100, -100));
assertEquals(false, termination.isSolverTerminated(solverScope));
assertEquals(0.0, termination.calculateSolverTimeGradient(solverScope), 0.0);
when(solverScope.getBestScore()).thenReturn(HardSoftScore.valueOf(-80, -100));
assertEquals(false, termination.isSolverTerminated(solverScope));
assertEquals(0.2, termination.calculateSolverTimeGradient(solverScope), 0.0);
when(solverScope.getBestScore()).thenReturn(HardSoftScore.valueOf(-60, -100));
assertEquals(false, termination.isSolverTerminated(solverScope));
assertEquals(0.4, termination.calculateSolverTimeGradient(solverScope), 0.0);
when(solverScope.getBestScore()).thenReturn(HardSoftScore.valueOf(-40, -100));
assertEquals(false, termination.isSolverTerminated(solverScope));
assertEquals(0.6, termination.calculateSolverTimeGradient(solverScope), 0.0);
when(solverScope.getBestScore()).thenReturn(HardSoftScore.valueOf(-20, -100));
assertEquals(false, termination.isSolverTerminated(solverScope));
assertEquals(0.8, termination.calculateSolverTimeGradient(solverScope), 0.0);
when(solverScope.getBestScore()).thenReturn(HardSoftScore.valueOf(0, -100));
assertEquals(true, termination.isSolverTerminated(solverScope));
assertEquals(1.0, termination.calculateSolverTimeGradient(solverScope), 0.0);
}