Skip to content

Commit cb64790

Browse files
authored
Merge pull request #463 from lovisek/future-genetic-refactor
Refactor parameter and variable names for clarity in the future-genetic benchmark
2 parents 18ece12 + 3966047 commit cb64790

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

benchmarks/jdk-concurrent/src/main/java/org/renaissance/jdk/concurrent/JavaJenetics.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public final class JavaJenetics {
2929

3030
private final int geneCount;
3131

32-
private final int chromosomeCount;
32+
private final int populationSize;
3333

3434
private final int generationCount;
3535

@@ -45,13 +45,13 @@ public final class JavaJenetics {
4545
//
4646

4747
public JavaJenetics(
48-
int geneMinValue, int geneMaxValue, int geneCount, int chromosomeCount,
48+
int geneMinValue, int geneMaxValue, int geneCount, int populationSize,
4949
int generationCount, int threadCount, int randomSeed
5050
) {
5151
this.geneMinValue = geneMinValue;
5252
this.geneMaxValue = geneMaxValue;
5353
this.geneCount = geneCount;
54-
this.chromosomeCount = chromosomeCount;
54+
this.populationSize = populationSize;
5555
this.generationCount = generationCount;
5656
this.randomSeed = randomSeed;
5757
this.threadCount = threadCount;
@@ -82,9 +82,9 @@ private Chromosome<DoubleGene> evolveChromosome() {
8282
//
8383
final long seed = initialSeed.getAndIncrement();
8484

85-
final Random chromosomeRandom = new Random(seed);
85+
final Random genotypeRandom = new Random(seed);
8686
Genotype<DoubleGene> genotype = Genotype.of(DoubleChromosome.of(geneMinValue, geneMaxValue, geneCount));
87-
Factory<Genotype<DoubleGene>> factory = () -> RandomRegistry.with(chromosomeRandom, r -> genotype.newInstance());
87+
Factory<Genotype<DoubleGene>> factory = () -> RandomRegistry.with(genotypeRandom, r -> genotype.newInstance());
8888

8989
final Random altererRandom = new Random(seed + 15);
9090
Alterer<DoubleGene, Double> singlePointCrossover = new SinglePointCrossover<DoubleGene, Double>(0.2);
@@ -110,7 +110,7 @@ private Chromosome<DoubleGene> evolveChromosome() {
110110
.alterers(alterer)
111111
.offspringSelector(offSpringSelector)
112112
.survivorsSelector(survivorsSelector)
113-
.populationSize(chromosomeCount)
113+
.populationSize(populationSize)
114114
.build();
115115

116116
final Genotype<DoubleGene> result = engine.stream()

benchmarks/jdk-concurrent/src/main/scala/org/renaissance/jdk/concurrent/FutureGenetic.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ import java.util.concurrent.TimeUnit
1919
@Summary("Runs a genetic algorithm using the Jenetics library and futures.")
2020
@Licenses(Array(License.APACHE2))
2121
@Repetitions(50)
22-
@Parameter(name = "chromosome_count", defaultValue = "50")
22+
@Parameter(name = "population_size", defaultValue = "50")
2323
@Parameter(name = "generation_count", defaultValue = "5000")
2424
@Parameter(name = "expected_sum", defaultValue = "-10975.2462578835")
2525
@Parameter(name = "expected_sum_squares", defaultValue = "130336964.45529507")
2626
@Configuration(
2727
name = "test",
2828
settings = Array(
29-
"chromosome_count = 10",
29+
"population_size = 10",
3030
"generation_count = 200",
3131
"expected_sum = -1857.224767254019",
3232
"expected_sum_squares = 135348190.4555571"
@@ -38,7 +38,7 @@ final class FutureGenetic extends Benchmark {
3838
// TODO: Consolidate benchmark parameters across the suite.
3939
// See: https://github.com/renaissance-benchmarks/renaissance/issues/27
4040

41-
private var chromosomeCountParam: Int = _
41+
private var populationSizeParam: Int = _
4242

4343
private var generationCountParam: Int = _
4444

@@ -64,7 +64,7 @@ final class FutureGenetic extends Benchmark {
6464
private var benchmark: JavaJenetics = _
6565

6666
override def setUpBeforeAll(c: BenchmarkContext): Unit = {
67-
chromosomeCountParam = c.parameter("chromosome_count").toPositiveInteger
67+
populationSizeParam = c.parameter("population_size").toPositiveInteger
6868
generationCountParam = c.parameter("generation_count").toPositiveInteger
6969
expectedSum = c.parameter("expected_sum").toDouble
7070
expectedSumSquares = c.parameter("expected_sum_squares").toDouble
@@ -75,7 +75,7 @@ final class FutureGenetic extends Benchmark {
7575
GENE_MIN_VALUE,
7676
GENE_MAX_VALUE,
7777
GENE_COUNT,
78-
chromosomeCountParam,
78+
populationSizeParam,
7979
generationCountParam,
8080
THREAD_COUNT,
8181
RANDOM_SEED

0 commit comments

Comments
 (0)