diff --git a/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java b/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java index d36cbb37..74ebd8e9 100644 --- a/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java +++ b/src/main/java/org/matsim/run/scoring/IndividualPersonScoringParameters.java @@ -64,7 +64,7 @@ public class IndividualPersonScoringParameters implements ScoringParametersForPe /** * Thread-local random number generator. */ - private final ThreadLocal rnd = ThreadLocal.withInitial(Context::new); + private final ThreadLocal rnd; private final Scenario scenario; private final ScoringConfigGroup basicScoring; private final TransitConfigGroup transitConfig; @@ -83,6 +83,7 @@ public IndividualPersonScoringParameters(Scenario scenario) { this.globalAvgIncome = computeAvgIncome(scenario.getPopulation()); this.categories = Category.fromConfigParams(this.scoring.getScoringParameters()); this.cache = new IdMap<>(Person.class, scenario.getPopulation().getPersons().size()); + this.rnd = ThreadLocal.withInitial(() -> new Context(scenario.getConfig().global().getRandomSeed())); } static DistanceGroup[] calcDistanceGroups(List dists, DoubleList distUtils) { @@ -278,10 +279,10 @@ private void addDeltaParams(DistanceGroupModeUtilityParameters.DeltaBuilder delt private record Context(ContinuousDistribution.Sampler normal, ContinuousDistribution.Sampler tn) { - Context() { - this(NormalDistribution.of(0, 1).createSampler(RandomSource.KISS.create(123L)), + Context(long seed) { + this(NormalDistribution.of(0, 1).createSampler(RandomSource.KISS.create(seed)), TruncatedNormalDistribution.of(0, 1, 0, Double.POSITIVE_INFINITY) - .createSampler(RandomSource.KISS.create(123L)) + .createSampler(RandomSource.KISS.create(seed)) ); } }