public boolean isAccepted(LocalSearchMoveScope moveScope) { LocalSearchSolverPhaseScope phaseScope = moveScope.getStepScope().getPhaseScope(); Score lastStepScore = phaseScope.getLastCompletedStepScope().getScore(); Score moveScore = moveScope.getScore(); if (moveScore.compareTo(lastStepScore) >= 0) { return true; } Score moveScoreDifference = lastStepScore.subtract(moveScore); double[] moveScoreDifferenceLevels = ScoreUtils.extractLevelDoubles(moveScoreDifference); double acceptChance = 1.0; for (int i = 0; i < levelsLength; i++) { double moveScoreDifferenceLevel = moveScoreDifferenceLevels[i]; double temperatureLevel = temperatureLevels[i]; double acceptChanceLevel; if (moveScoreDifferenceLevel <= 0.0) { // In this level, moveScore is better than the lastStepScore, so do not disrupt the // acceptChance acceptChanceLevel = 1.0; } else { acceptChanceLevel = Math.exp(-moveScoreDifferenceLevel / temperatureLevel); } acceptChance *= acceptChanceLevel; } if (moveScope.getWorkingRandom().nextDouble() < acceptChance) { return true; } else { return false; } }
@Override protected Collection<? extends Object> findTabu(LocalSearchMoveScope moveScope) { return moveScope.getMove().getPlanningValues(); }