Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor parameter and variable names for clarity in the future-genetic benchmark #463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class JavaJenetics {

private final int geneCount;

private final int chromosomeCount;
private final int populationSize;

private final int generationCount;

Expand All @@ -45,13 +45,13 @@ public final class JavaJenetics {
//

public JavaJenetics(
int geneMinValue, int geneMaxValue, int geneCount, int chromosomeCount,
int geneMinValue, int geneMaxValue, int geneCount, int populationSize,
int generationCount, int threadCount, int randomSeed
) {
this.geneMinValue = geneMinValue;
this.geneMaxValue = geneMaxValue;
this.geneCount = geneCount;
this.chromosomeCount = chromosomeCount;
this.populationSize = populationSize;
this.generationCount = generationCount;
this.randomSeed = randomSeed;
this.threadCount = threadCount;
Expand Down Expand Up @@ -82,9 +82,9 @@ private Chromosome<DoubleGene> evolveChromosome() {
//
final long seed = initialSeed.getAndIncrement();

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

final Random altererRandom = new Random(seed + 15);
Alterer<DoubleGene, Double> singlePointCrossover = new SinglePointCrossover<DoubleGene, Double>(0.2);
Expand All @@ -110,7 +110,7 @@ private Chromosome<DoubleGene> evolveChromosome() {
.alterers(alterer)
.offspringSelector(offSpringSelector)
.survivorsSelector(survivorsSelector)
.populationSize(chromosomeCount)
.populationSize(populationSize)
.build();

final Genotype<DoubleGene> result = engine.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import java.util.concurrent.TimeUnit
@Summary("Runs a genetic algorithm using the Jenetics library and futures.")
@Licenses(Array(License.APACHE2))
@Repetitions(50)
@Parameter(name = "chromosome_count", defaultValue = "50")
@Parameter(name = "population_size", defaultValue = "50")
@Parameter(name = "generation_count", defaultValue = "5000")
@Parameter(name = "expected_sum", defaultValue = "-10975.2462578835")
@Parameter(name = "expected_sum_squares", defaultValue = "130336964.45529507")
@Configuration(
name = "test",
settings = Array(
"chromosome_count = 10",
"population_size = 10",
"generation_count = 200",
"expected_sum = -1857.224767254019",
"expected_sum_squares = 135348190.4555571"
Expand All @@ -38,7 +38,7 @@ final class FutureGenetic extends Benchmark {
// TODO: Consolidate benchmark parameters across the suite.
// See: https://github.com/renaissance-benchmarks/renaissance/issues/27

private var chromosomeCountParam: Int = _
private var populationSizeParam: Int = _

private var generationCountParam: Int = _

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

override def setUpBeforeAll(c: BenchmarkContext): Unit = {
chromosomeCountParam = c.parameter("chromosome_count").toPositiveInteger
populationSizeParam = c.parameter("population_size").toPositiveInteger
generationCountParam = c.parameter("generation_count").toPositiveInteger
expectedSum = c.parameter("expected_sum").toDouble
expectedSumSquares = c.parameter("expected_sum_squares").toDouble
Expand All @@ -75,7 +75,7 @@ final class FutureGenetic extends Benchmark {
GENE_MIN_VALUE,
GENE_MAX_VALUE,
GENE_COUNT,
chromosomeCountParam,
populationSizeParam,
generationCountParam,
THREAD_COUNT,
RANDOM_SEED
Expand Down