Class ImmutableElitism
java.lang.Object
net.bmahe.genetics4j.core.spec.replacement.ImmutableElitism
- All Implemented Interfaces:
Elitism,ReplacementStrategy
@Generated(from="Elitism",
generator="Immutables")
@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
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds instances of typeElitism.private final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final intprivate ImmutableElitism.InitShimprivate final doubleprivate final SelectionPolicyprivate static final byteprivate static final byteprivate static final byteprivate final SelectionPolicyFields 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
ConstructorsModifierConstructorDescriptionprivateImmutableElitism(ImmutableElitism.Builder builder) privateImmutableElitism(SelectionPolicy offspringSelectionPolicy, int atLeastNumOffsprings, SelectionPolicy survivorSelectionPolicy, int atLeastNumSurvivors, double offspringRatio) -
Method Summary
Modifier and TypeMethodDescriptionintReturns how many offsprings that elitism will always select.private intintReturns how many survivors that elitism will always select.private intstatic ElitismCreates an immutable copy of aElitismvalue.booleanThis instance is equal to all instances ofImmutableElitismthat have equal attribute values.private booleanequalsByValue(ImmutableElitism another) inthashCode()Computes a hash code from attributes:offspringSelectionPolicy,atLeastNumOffsprings,survivorSelectionPolicy,atLeastNumSurvivors,offspringRatio.doubleReturns 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 doubleReturns 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 valueElitismwith attribute values.private static ImmutableElitismvalidate(ImmutableElitism instance) final ImmutableElitismwithAtLeastNumOffsprings(int value) Copy the current immutable object by setting a value for theatLeastNumOffspringsattribute.final ImmutableElitismwithAtLeastNumSurvivors(int value) Copy the current immutable object by setting a value for theatLeastNumSurvivorsattribute.final ImmutableElitismwithOffspringRatio(double value) Copy the current immutable object by setting a value for theoffspringRatioattribute.final ImmutableElitismCopy the current immutable object by setting a value for theoffspringSelectionPolicyattribute.final ImmutableElitismCopy the current immutable object by setting a value for thesurvivorSelectionPolicyattribute.
-
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:
offspringSelectionPolicyin 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:
atLeastNumOffspringsin interfaceElitism- Returns:
- how many offsprings that elitism will always select
-
survivorSelectionPolicy
Returns the policy used to select survivors for the next generation.- Specified by:
survivorSelectionPolicyin 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:
atLeastNumSurvivorsin 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:
offspringRatioin 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 theoffspringSelectionPolicyattribute. 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 or the
thisobject
-
withAtLeastNumOffsprings
Copy the current immutable object by setting a value for theatLeastNumOffspringsattribute. 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 or the
thisobject
-
withSurvivorSelectionPolicy
Copy the current immutable object by setting a value for thesurvivorSelectionPolicyattribute. 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 or the
thisobject
-
withAtLeastNumSurvivors
Copy the current immutable object by setting a value for theatLeastNumSurvivorsattribute. 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 or the
thisobject
-
withOffspringRatio
Copy the current immutable object by setting a value for theoffspringRatioattribute. 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 or the
thisobject
-
equals
This instance is equal to all instances ofImmutableElitismthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:offspringSelectionPolicy,atLeastNumOffsprings,survivorSelectionPolicy,atLeastNumSurvivors,offspringRatio. -
toString
Prints the immutable valueElitismwith attribute values. -
validate
-
copyOf
Creates an immutable copy of aElitismvalue. 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
-