Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfred committed Dec 6, 2024
1 parent 78f6431 commit b9d4c98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void ensurePreviewFeature(PreviewFeature previewFeature) {
throw new IllegalStateException(
"""
The preview feature %s is not enabled.
Maybe add %s to <enablePreviewFeatureList> in your configuration file?"""
Maybe add %s to <enablePreviewFeature> in your configuration file?"""
.formatted(previewFeature, previewFeature));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@ private void validate() {
public boolean isAccepted(LocalSearchMoveScope<Solution_> moveScope) {
// The acceptance and replacement strategies are based on the work:
// Diversified Late Acceptance Search by M. Namazi, C. Sanderson, M. A. H. Newton, M. M. A. Polash, and A. Sattar
var lateScore = previousScores[lateScoreIndex];
var moveScore = moveScope.getScore();
var current = (Score) moveScope.getStepScope().getPhaseScope().getLastCompletedStepScope().getScore();
var previous = current;
var accept = moveScore.compareTo(current) == 0 || moveScore.compareTo(lateWorse) > 0;
if (accept) {
current = moveScore;
}
var lateScore = previousScores[lateScoreIndex];
// Improves the diversification to allow the next iterations to find a better solution
var currentScoreWorse = current.compareTo(lateScore) < 0;
var currentScoreCmp = current.compareTo(lateScore);
var currentScoreWorse = currentScoreCmp < 0;
// Improves the intensification but avoids replacing values when the search falls into a plateau or local minima
var currentScoreBetter = current.compareTo(lateScore) > 0 && current.compareTo(previous) > 0;
var currentScoreBetter = currentScoreCmp > 0 && current.compareTo(previous) > 0;
if (currentScoreWorse || currentScoreBetter) {
updateLateScore(current);
}
Expand All @@ -72,16 +73,15 @@ public boolean isAccepted(LocalSearchMoveScope<Solution_> moveScope) {

@SuppressWarnings({ "rawtypes", "unchecked" })
private void updateLateScore(Score newScore) {
var newScoreWorse = newScore.compareTo(lateWorse) < 0;
var newScoreEqual = newScore.compareTo(lateWorse) == 0;
var newScoreWorseCmp = newScore.compareTo(lateWorse);
var lateScore = (Score) previousScores[lateScoreIndex];
var lateScoreEqual = lateScore.compareTo(lateWorse) == 0;
if (newScoreWorse) {
if (newScoreWorseCmp < 0) {
this.lateWorse = newScore;
this.lateWorseOccurrences = 1;
} else if (lateScoreEqual && !newScoreEqual) {
} else if (lateScoreEqual && newScoreWorseCmp != 0) {
this.lateWorseOccurrences--;
} else if (!lateScoreEqual && newScoreEqual) {
} else if (!lateScoreEqual && newScoreWorseCmp == 0) {
this.lateWorseOccurrences++;
}
previousScores[lateScoreIndex] = newScore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ but it offers different acceptance and replacement strategies.
A move is accepted if its score matches the current solution score
or is better than the late score (which is the winning score of a fixed number of steps ago).

Scientific paper: https://arxiv.org/pdf/1806.09328[Diversified Late Acceptance Search by M. Namazi, C. Sanderson, M. A. H. Newton, M. M. A. Polash, and A. Sattar]
Diversified Late Acceptance was first proposed in
https://arxiv.org/pdf/1806.09328[Diversified Late Acceptance Search by M. Namazi, C. Sanderson, M. A. H. Newton, M. M. A. Polash, and A. Sattar]

[#diversifiedLateAcceptanceConfiguration]
=== Configuration
Expand Down

0 comments on commit b9d4c98

Please sign in to comment.