Class ImmutableGPUEAConfiguration<T extends Comparable<T>>
GPUEAConfiguration
.
Use the builder to create immutable instances:
new GPUEAConfiguration.Builder()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ImmutableGPUEAConfiguration.Builder<T extends Comparable<T>>
Builds instances of typeImmutableGPUEAConfiguration
.private final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List
<ChromosomeSpec> private final CombinationPolicy
private final OpenCLFitness
<T> private final GenotypeCombinator
private ImmutableGPUEAConfiguration<T>.InitShim
private final List
<MutationPolicy> private final double
private final Optimization
private final SelectionPolicy
private final Function
<Population<T>, Population<T>> private final Program
private final ReplacementStrategy
private final Collection
<Genotype> private static final byte
private static final byte
private static final byte
private final Termination
<T> Fields inherited from class net.bmahe.genetics4j.core.spec.AbstractEAConfiguration
DEFAULT_OFFSPRING_RATIO, DEFAULT_OPTIMIZATION
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableGPUEAConfiguration
(List<ChromosomeSpec> chromosomeSpecs, SelectionPolicy parentSelectionPolicy, CombinationPolicy combinationPolicy, List<MutationPolicy> mutationPolicies, ReplacementStrategy replacementStrategy, Function<Population<T>, Population<T>> postEvaluationProcessor, Termination<T> termination, Supplier<Genotype> genotypeGenerator, Collection<Genotype> seedPopulation, GenotypeCombinator genotypeCombinator, double offspringGeneratedRatio, Optimization optimization, Program program, OpenCLFitness<T> fitness) private
-
Method Summary
Modifier and TypeMethodDescriptionGenotype of the populationDefines the policy to generate new offsprings from two parentsstatic <T extends Comparable<T>>
ImmutableGPUEAConfiguration<T> copyOf
(GPUEAConfiguration<T> instance) Creates an immutable copy of aGPUEAConfiguration
value.private static <T> List
<T> createSafeList
(Iterable<? extends T> iterable, boolean checkNulls, boolean skipNulls) private static <T> List
<T> createUnmodifiableList
(boolean clone, List<T> list) boolean
This instance is equal to all instances ofImmutableGPUEAConfiguration
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableGPUEAConfiguration<?> another) fitness()
Defines how to combine the offspring chromosomes generatedDefines how to generate individualsint
hashCode()
Computes a hash code from attributes:chromosomeSpecs
,parentSelectionPolicy
,combinationPolicy
,mutationPolicies
,replacementStrategy
,postEvaluationProcessor
,termination
,genotypeGenerator
,seedPopulation
,genotypeCombinator
,offspringGeneratedRatio
,optimization
,program
,fitness
.Defines what mutations to be performed on the offspringsdouble
Defines how many children will be generated at each iteration.Defines the optimization goal, whether we want to maximize the fitness or minimize itDefines the policy to select the parents.Post-processing of a population after it got evaluatedprogram()
Defines the replacement strategySeed the initial population with specific individualsDefines termination conditiontoString()
Prints the immutable valueGPUEAConfiguration
with attribute values.private static <T extends Comparable<T>>
ImmutableGPUEAConfiguration<T> validate
(ImmutableGPUEAConfiguration<T> instance) final ImmutableGPUEAConfiguration
<T> withChromosomeSpecs
(Iterable<? extends ChromosomeSpec> elements) Copy the current immutable object with elements that replace the content ofchromosomeSpecs
.final ImmutableGPUEAConfiguration
<T> withChromosomeSpecs
(ChromosomeSpec... elements) Copy the current immutable object with elements that replace the content ofchromosomeSpecs
.final ImmutableGPUEAConfiguration
<T> Copy the current immutable object by setting a value for thecombinationPolicy
attribute.final ImmutableGPUEAConfiguration
<T> withFitness
(OpenCLFitness<T> value) Copy the current immutable object by setting a value for thefitness
attribute.final ImmutableGPUEAConfiguration
<T> Copy the current immutable object by setting a value for thegenotypeCombinator
attribute.final ImmutableGPUEAConfiguration
<T> withGenotypeGenerator
(Supplier<Genotype> value) Copy the current immutable object by setting a present value for the optionalgenotypeGenerator
attribute.final ImmutableGPUEAConfiguration
<T> withGenotypeGenerator
(Optional<? extends Supplier<Genotype>> optional) Copy the current immutable object by setting an optional value for thegenotypeGenerator
attribute.final ImmutableGPUEAConfiguration
<T> withMutationPolicies
(Iterable<? extends MutationPolicy> elements) Copy the current immutable object with elements that replace the content ofmutationPolicies
.final ImmutableGPUEAConfiguration
<T> withMutationPolicies
(MutationPolicy... elements) Copy the current immutable object with elements that replace the content ofmutationPolicies
.final ImmutableGPUEAConfiguration
<T> withOffspringGeneratedRatio
(double value) Copy the current immutable object by setting a value for theoffspringGeneratedRatio
attribute.final ImmutableGPUEAConfiguration
<T> withOptimization
(Optimization value) Copy the current immutable object by setting a value for theoptimization
attribute.final ImmutableGPUEAConfiguration
<T> Copy the current immutable object by setting a value for theparentSelectionPolicy
attribute.final ImmutableGPUEAConfiguration
<T> withPostEvaluationProcessor
(Function<Population<T>, Population<T>> value) Copy the current immutable object by setting a present value for the optionalpostEvaluationProcessor
attribute.final ImmutableGPUEAConfiguration
<T> withPostEvaluationProcessor
(Optional<? extends Function<Population<T>, Population<T>>> optional) Copy the current immutable object by setting an optional value for thepostEvaluationProcessor
attribute.final ImmutableGPUEAConfiguration
<T> withProgram
(Program value) Copy the current immutable object by setting a value for theprogram
attribute.final ImmutableGPUEAConfiguration
<T> Copy the current immutable object by setting a value for thereplacementStrategy
attribute.final ImmutableGPUEAConfiguration
<T> withSeedPopulation
(Collection<Genotype> value) Copy the current immutable object by setting a value for theseedPopulation
attribute.final ImmutableGPUEAConfiguration
<T> withTermination
(Termination<T> value) Copy the current immutable object by setting a value for thetermination
attribute.Methods inherited from class net.bmahe.genetics4j.gpu.spec.GPUEAConfiguration
builder
Methods inherited from class net.bmahe.genetics4j.core.spec.AbstractEAConfiguration
check, fitnessComparator, getChromosomeSpec, numChromosomes
-
Field Details
-
chromosomeSpecs
-
parentSelectionPolicy
-
combinationPolicy
-
mutationPolicies
-
replacementStrategy
-
postEvaluationProcessor
private final Function<Population<T extends Comparable<T>>,Population<T extends Comparable<T>>> postEvaluationProcessor -
termination
-
genotypeGenerator
-
seedPopulation
-
genotypeCombinator
-
offspringGeneratedRatio
private final double offspringGeneratedRatio -
optimization
-
program
-
fitness
-
STAGE_INITIALIZING
private static final byte STAGE_INITIALIZING- See Also:
-
STAGE_UNINITIALIZED
private static final byte STAGE_UNINITIALIZED- See Also:
-
STAGE_INITIALIZED
private static final byte STAGE_INITIALIZED- See Also:
-
initShim
-
-
Constructor Details
-
ImmutableGPUEAConfiguration
-
ImmutableGPUEAConfiguration
private ImmutableGPUEAConfiguration(List<ChromosomeSpec> chromosomeSpecs, SelectionPolicy parentSelectionPolicy, CombinationPolicy combinationPolicy, List<MutationPolicy> mutationPolicies, ReplacementStrategy replacementStrategy, Function<Population<T>, Population<T>> postEvaluationProcessor, Termination<T> termination, Supplier<Genotype> genotypeGenerator, Collection<Genotype> seedPopulation, GenotypeCombinator genotypeCombinator, double offspringGeneratedRatio, Optimization optimization, Program program, OpenCLFitness<T> fitness)
-
-
Method Details
-
chromosomeSpecs
Description copied from class:AbstractEAConfiguration
Genotype of the population- Specified by:
chromosomeSpecs
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
chromosomeSpecs
attribute
-
parentSelectionPolicy
Description copied from class:AbstractEAConfiguration
Defines the policy to select the parents. The selected parents will be used for generating the new offsprings- Specified by:
parentSelectionPolicy
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
parentSelectionPolicy
attribute
-
combinationPolicy
Description copied from class:AbstractEAConfiguration
Defines the policy to generate new offsprings from two parents- Specified by:
combinationPolicy
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
combinationPolicy
attribute
-
mutationPolicies
Description copied from class:AbstractEAConfiguration
Defines what mutations to be performed on the offsprings- Specified by:
mutationPolicies
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
mutationPolicies
attribute
-
replacementStrategy
Description copied from class:AbstractEAConfiguration
Defines the replacement strategyThe replacement strategy is what will determine the next population based on the generated and mutated offsprings along with the current population
If not specified, the default replacement strategy will be to use Elitism with tournament selection of 3 individuals for both offsprings and survivors. The default offspring ratio is
Elitism.DEFAULT_OFFSPRING_RATIO
- Overrides:
replacementStrategy
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
replacementStrategy
attribute
-
postEvaluationProcessor
Description copied from class:AbstractEAConfiguration
Post-processing of a population after it got evaluatedThis gives the opportunity to filter out, repair or rescore individuals
- Specified by:
postEvaluationProcessor
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
postEvaluationProcessor
attribute
-
termination
Description copied from class:AbstractEAConfiguration
Defines termination condition- Specified by:
termination
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
termination
attribute
-
genotypeGenerator
Description copied from class:AbstractEAConfiguration
Defines how to generate individualsIf not specified, the system will rely on the chromosome factories
- Specified by:
genotypeGenerator
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
genotypeGenerator
attribute
-
seedPopulation
Description copied from class:AbstractEAConfiguration
Seed the initial population with specific individuals- Overrides:
seedPopulation
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
seedPopulation
attribute
-
genotypeCombinator
Description copied from class:AbstractEAConfiguration
Defines how to combine the offspring chromosomes generatedCombination of individuals is done on a per chromosome basis. This means some parents may generate a different number of children for each chromosome. This method will therefore define how to take all these generated chromosomes and combine them into offspring individuals
The current default implementation is to generate as many individual as there are combinations of generated chromosomes
- Overrides:
genotypeCombinator
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
genotypeCombinator
attribute
-
offspringGeneratedRatio
public double offspringGeneratedRatio()Description copied from class:AbstractEAConfiguration
Defines how many children will be generated at each iteration. Value must be between 0 and 1 (inclusive) and represents a fraction of the population size- Overrides:
offspringGeneratedRatio
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
offspringGeneratedRatio
attribute
-
optimization
Description copied from class:AbstractEAConfiguration
Defines the optimization goal, whether we want to maximize the fitness or minimize it- Overrides:
optimization
in classAbstractEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
optimization
attribute
-
program
- Specified by:
program
in classGPUEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
program
attribute
-
fitness
- Specified by:
fitness
in classGPUEAConfiguration<T extends Comparable<T>>
- Returns:
- The value of the
fitness
attribute
-
withChromosomeSpecs
Copy the current immutable object with elements that replace the content ofchromosomeSpecs
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withChromosomeSpecs
public final ImmutableGPUEAConfiguration<T> withChromosomeSpecs(Iterable<? extends ChromosomeSpec> elements) Copy the current immutable object with elements that replace the content ofchromosomeSpecs
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of chromosomeSpecs elements to set- Returns:
- A modified copy of
this
object
-
withParentSelectionPolicy
Copy the current immutable object by setting a value for theparentSelectionPolicy
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for parentSelectionPolicy- Returns:
- A modified copy of the
this
object
-
withCombinationPolicy
Copy the current immutable object by setting a value for thecombinationPolicy
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for combinationPolicy- Returns:
- A modified copy of the
this
object
-
withMutationPolicies
Copy the current immutable object with elements that replace the content ofmutationPolicies
.- Parameters:
elements
- The elements to set- Returns:
- A modified copy of
this
object
-
withMutationPolicies
public final ImmutableGPUEAConfiguration<T> withMutationPolicies(Iterable<? extends MutationPolicy> elements) Copy the current immutable object with elements that replace the content ofmutationPolicies
. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
elements
- An iterable of mutationPolicies elements to set- Returns:
- A modified copy of
this
object
-
withReplacementStrategy
Copy the current immutable object by setting a value for thereplacementStrategy
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for replacementStrategy- Returns:
- A modified copy of the
this
object
-
withPostEvaluationProcessor
public final ImmutableGPUEAConfiguration<T> withPostEvaluationProcessor(Function<Population<T>, Population<T>> value) Copy the current immutable object by setting a present value for the optionalpostEvaluationProcessor
attribute.- Parameters:
value
- The value for postEvaluationProcessor- Returns:
- A modified copy of
this
object
-
withPostEvaluationProcessor
public final ImmutableGPUEAConfiguration<T> withPostEvaluationProcessor(Optional<? extends Function<Population<T>, Population<T>>> optional) Copy the current immutable object by setting an optional value for thepostEvaluationProcessor
attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for postEvaluationProcessor- Returns:
- A modified copy of
this
object
-
withTermination
Copy the current immutable object by setting a value for thetermination
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for termination- Returns:
- A modified copy of the
this
object
-
withGenotypeGenerator
Copy the current immutable object by setting a present value for the optionalgenotypeGenerator
attribute.- Parameters:
value
- The value for genotypeGenerator- Returns:
- A modified copy of
this
object
-
withGenotypeGenerator
public final ImmutableGPUEAConfiguration<T> withGenotypeGenerator(Optional<? extends Supplier<Genotype>> optional) Copy the current immutable object by setting an optional value for thegenotypeGenerator
attribute. A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for genotypeGenerator- Returns:
- A modified copy of
this
object
-
withSeedPopulation
Copy the current immutable object by setting a value for theseedPopulation
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for seedPopulation- Returns:
- A modified copy of the
this
object
-
withGenotypeCombinator
Copy the current immutable object by setting a value for thegenotypeCombinator
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for genotypeCombinator- Returns:
- A modified copy of the
this
object
-
withOffspringGeneratedRatio
Copy the current immutable object by setting a value for theoffspringGeneratedRatio
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for offspringGeneratedRatio- Returns:
- A modified copy of the
this
object
-
withOptimization
Copy the current immutable object by setting a value for theoptimization
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for optimization- Returns:
- A modified copy of the
this
object
-
withProgram
Copy the current immutable object by setting a value for theprogram
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for program- Returns:
- A modified copy of the
this
object
-
withFitness
Copy the current immutable object by setting a value for thefitness
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for fitness- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableGPUEAConfiguration
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:chromosomeSpecs
,parentSelectionPolicy
,combinationPolicy
,mutationPolicies
,replacementStrategy
,postEvaluationProcessor
,termination
,genotypeGenerator
,seedPopulation
,genotypeCombinator
,offspringGeneratedRatio
,optimization
,program
,fitness
. -
toString
Prints the immutable valueGPUEAConfiguration
with attribute values. -
validate
private static <T extends Comparable<T>> ImmutableGPUEAConfiguration<T> validate(ImmutableGPUEAConfiguration<T> instance) -
copyOf
public static <T extends Comparable<T>> ImmutableGPUEAConfiguration<T> copyOf(GPUEAConfiguration<T> instance) Creates an immutable copy of aGPUEAConfiguration
value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T
- generic parameter T- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable GPUEAConfiguration instance
-
createSafeList
-
createUnmodifiableList
-