Class ImmutableElitism
java.lang.Object
net.bmahe.genetics4j.core.spec.replacement.ImmutableElitism
- All Implemented Interfaces:
Elitism
,ReplacementStrategy
@Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableElitism
extends Object
implements Elitism
Immutable implementation of
Elitism
.
Use the builder to create immutable instances:
new Elitism.Builder()
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builds instances of typeImmutableElitism
.private final class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final int
private final int
private ImmutableElitism.InitShim
private final double
private final SelectionPolicy
private static final byte
private static final byte
private static final byte
private final SelectionPolicy
Fields inherited from interface net.bmahe.genetics4j.core.spec.replacement.Elitism
DEFAULT_AT_LEAST_NUM_OFFSPRINGS, DEFAULT_AT_LEAST_NUM_SURVIVORS, DEFAULT_OFFSPRING_RATIO
-
Constructor Summary
ModifierConstructorDescriptionprivate
ImmutableElitism
(ImmutableElitism.Builder builder) private
ImmutableElitism
(SelectionPolicy offspringSelectionPolicy, int atLeastNumOffsprings, SelectionPolicy survivorSelectionPolicy, int atLeastNumSurvivors, double offspringRatio) -
Method Summary
Modifier and TypeMethodDescriptionint
Returns how many offsprings that elitism will always select.private int
int
Returns how many survivors that elitism will always select.private int
static ImmutableElitism
Creates an immutable copy of aElitism
value.boolean
This instance is equal to all instances ofImmutableElitism
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableElitism another) int
hashCode()
Computes a hash code from attributes:offspringSelectionPolicy
,atLeastNumOffsprings
,survivorSelectionPolicy
,atLeastNumSurvivors
,offspringRatio
.double
Returns how many children will be generated at each iteration. Value must be between 0 and 1 (inclusive) The number of survivor will be the complement of it, or 1 - offspringRatio().private double
Returns the policy used to select offsprings for the next generation.Returns the policy used to select survivors for the next generation.toString()
Prints the immutable valueElitism
with attribute values.private static ImmutableElitism
validate
(ImmutableElitism instance) final ImmutableElitism
withAtLeastNumOffsprings
(int value) Copy the current immutable object by setting a value for theatLeastNumOffsprings
attribute.final ImmutableElitism
withAtLeastNumSurvivors
(int value) Copy the current immutable object by setting a value for theatLeastNumSurvivors
attribute.final ImmutableElitism
withOffspringRatio
(double value) Copy the current immutable object by setting a value for theoffspringRatio
attribute.final ImmutableElitism
Copy the current immutable object by setting a value for theoffspringSelectionPolicy
attribute.final ImmutableElitism
Copy the current immutable object by setting a value for thesurvivorSelectionPolicy
attribute.
-
Field Details
-
offspringSelectionPolicy
-
atLeastNumOffsprings
private final int atLeastNumOffsprings -
survivorSelectionPolicy
-
atLeastNumSurvivors
private final int atLeastNumSurvivors -
offspringRatio
private final double offspringRatio -
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
-
ImmutableElitism
-
ImmutableElitism
private ImmutableElitism(SelectionPolicy offspringSelectionPolicy, int atLeastNumOffsprings, SelectionPolicy survivorSelectionPolicy, int atLeastNumSurvivors, double offspringRatio)
-
-
Method Details
-
atLeastNumOffspringsInitialize
private int atLeastNumOffspringsInitialize() -
atLeastNumSurvivorsInitialize
private int atLeastNumSurvivorsInitialize() -
offspringRatioInitialize
private double offspringRatioInitialize() -
offspringSelectionPolicy
Returns the policy used to select offsprings for the next generation.- Specified by:
offspringSelectionPolicy
in interfaceElitism
- Returns:
- the policy used to select offsprings for the next generation
-
atLeastNumOffsprings
public int atLeastNumOffsprings()Returns how many offsprings that elitism will always select.- Specified by:
atLeastNumOffsprings
in interfaceElitism
- Returns:
- how many offsprings that elitism will always select
-
survivorSelectionPolicy
Returns the policy used to select survivors for the next generation.- Specified by:
survivorSelectionPolicy
in interfaceElitism
- Returns:
- the policy used to select survivors for the next generation
-
atLeastNumSurvivors
public int atLeastNumSurvivors()Returns how many survivors that elitism will always select.- Specified by:
atLeastNumSurvivors
in interfaceElitism
- Returns:
- how many survivors that elitism will always select
-
offspringRatio
public double offspringRatio()Returns how many children will be generated at each iteration. Value must be between 0 and 1 (inclusive)The number of survivor will be the complement of it, or 1 - offspringRatio().
- Specified by:
offspringRatio
in interfaceElitism
- Returns:
- how many children will be generated at each iteration. Value
must be between 0 and 1 (inclusive)
The number of survivor will be the complement of it, or 1 - offspringRatio()
-
withOffspringSelectionPolicy
Copy the current immutable object by setting a value for theoffspringSelectionPolicy
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for offspringSelectionPolicy- Returns:
- A modified copy of the
this
object
-
withAtLeastNumOffsprings
Copy the current immutable object by setting a value for theatLeastNumOffsprings
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for atLeastNumOffsprings- Returns:
- A modified copy of the
this
object
-
withSurvivorSelectionPolicy
Copy the current immutable object by setting a value for thesurvivorSelectionPolicy
attribute. A shallow reference equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for survivorSelectionPolicy- Returns:
- A modified copy of the
this
object
-
withAtLeastNumSurvivors
Copy the current immutable object by setting a value for theatLeastNumSurvivors
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for atLeastNumSurvivors- Returns:
- A modified copy of the
this
object
-
withOffspringRatio
Copy the current immutable object by setting a value for theoffspringRatio
attribute. A value strict bits equality used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for offspringRatio- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofImmutableElitism
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:offspringSelectionPolicy
,atLeastNumOffsprings
,survivorSelectionPolicy
,atLeastNumSurvivors
,offspringRatio
. -
toString
Prints the immutable valueElitism
with attribute values. -
validate
-
copyOf
Creates an immutable copy of aElitism
value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable Elitism instance
-