Skip to content

Commit

Permalink
use configured seed for person scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Jun 9, 2024
1 parent 5a45d0a commit 8001a01
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class IndividualPersonScoringParameters implements ScoringParametersForPe
/**
* Thread-local random number generator.
*/
private final ThreadLocal<Context> rnd = ThreadLocal.withInitial(Context::new);
private final ThreadLocal<Context> rnd;
private final Scenario scenario;
private final ScoringConfigGroup basicScoring;
private final TransitConfigGroup transitConfig;
Expand All @@ -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<Integer> dists, DoubleList distUtils) {
Expand Down Expand Up @@ -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))
);
}
}
Expand Down

0 comments on commit 8001a01

Please sign in to comment.