Skip to content

Commit

Permalink
fix: Lukas' comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfred committed Mar 5, 2024
1 parent 3235cd0 commit 5e3375f
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ThreadFactory;

import ai.timefold.solver.core.config.heuristic.selector.entity.EntitySorterManner;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class HeuristicConfigPolicy<Solution_> {
private final boolean initializedChainedValueFilterEnabled;
private final boolean unassignedValuesAllowed;
private final Class<? extends NearbyDistanceMeter<?, ?>> nearbyDistanceMeterClass;
private final Random random;

private final Map<String, EntityMimicRecorder<Solution_>> entityMimicRecorderMap = new HashMap<>();
private final Map<String, SubListMimicRecorder<Solution_>> subListMimicRecorderMap = new HashMap<>();
Expand All @@ -58,6 +60,7 @@ private HeuristicConfigPolicy(Builder<Solution_> builder) {
this.initializedChainedValueFilterEnabled = builder.initializedChainedValueFilterEnabled;
this.unassignedValuesAllowed = builder.unassignedValuesAllowed;
this.nearbyDistanceMeterClass = builder.nearbyDistanceMeterClass;
this.random = builder.random;
}

public EnvironmentMode getEnvironmentMode() {
Expand Down Expand Up @@ -116,13 +119,17 @@ public Class<? extends NearbyDistanceMeter> getNearbyDistanceMeterClass() {
return nearbyDistanceMeterClass;
}

public Random getRandom() {
return random;
}

// ************************************************************************
// Builder methods
// ************************************************************************

public Builder<Solution_> cloneBuilder() {
return new Builder<>(environmentMode, moveThreadCount, moveThreadBufferSize, threadFactoryClass,
nearbyDistanceMeterClass, initializingScoreTrend, solutionDescriptor, classInstanceCache)
nearbyDistanceMeterClass, random, initializingScoreTrend, solutionDescriptor, classInstanceCache)
.withLogIndentation(logIndentation);
}

Expand Down Expand Up @@ -223,17 +230,19 @@ public static class Builder<Solution_> {
private boolean unassignedValuesAllowed = false;

private final Class<? extends NearbyDistanceMeter<?, ?>> nearbyDistanceMeterClass;
private final Random random;

public Builder(EnvironmentMode environmentMode, Integer moveThreadCount, Integer moveThreadBufferSize,
Class<? extends ThreadFactory> threadFactoryClass,
Class<? extends NearbyDistanceMeter<?, ?>> nearbyDistanceMeterClass,
Class<? extends NearbyDistanceMeter<?, ?>> nearbyDistanceMeterClass, Random random,
InitializingScoreTrend initializingScoreTrend, SolutionDescriptor<Solution_> solutionDescriptor,
ClassInstanceCache classInstanceCache) {
this.environmentMode = environmentMode;
this.moveThreadCount = moveThreadCount;
this.moveThreadBufferSize = moveThreadBufferSize;
this.threadFactoryClass = threadFactoryClass;
this.nearbyDistanceMeterClass = nearbyDistanceMeterClass;
this.random = random;
this.initializingScoreTrend = initializingScoreTrend;
this.solutionDescriptor = solutionDescriptor;
this.classInstanceCache = classInstanceCache;
Expand Down
Loading

0 comments on commit 5e3375f

Please sign in to comment.