R
- the representation type of the solution to be mutatedpublic abstract class StochasticMutate<T,S extends Solution<io.vavr.collection.Array<T>>> extends java.lang.Object implements Mutation<S>
Abstract implementation of IMutateSolution
. Features are not mutated independently. Instead, a random subset of features is first selected (the size of this subset is proportional to the chance to mutate). Then these features are mutated.
Concrete subclasses are supposed to provide the actual mutation computation.
Modifier and Type | Class and Description |
---|---|
static interface |
io.vavr.Lambda.Memoized |
Modifier and Type | Field and Description |
---|---|
private double |
chanceToMutate |
private static double |
DEFAULT_CHANCE_TO_MUTATE |
private DoubleRandomGenerator |
doubleRand |
private IntRandomGenerator |
intRand |
Modifier | Constructor and Description |
---|---|
protected |
StochasticMutate(DoubleRandomGenerator doubleRand,
IntRandomGenerator intRand) |
protected |
StochasticMutate(DoubleRandomGenerator doubleRand,
IntRandomGenerator intRand,
double chanceToMutate) |
Modifier and Type | Method and Description |
---|---|
protected abstract io.vavr.collection.Array<T> |
doMutate(io.vavr.collection.Array<T> representation,
int index)
Mutate the representation at the given index.
|
default boolean |
isMemoized() |
S |
mutate(S solution) |
private static final double DEFAULT_CHANCE_TO_MUTATE
private final DoubleRandomGenerator doubleRand
private final IntRandomGenerator intRand
private final double chanceToMutate
protected StochasticMutate(DoubleRandomGenerator doubleRand, IntRandomGenerator intRand)
protected StochasticMutate(DoubleRandomGenerator doubleRand, IntRandomGenerator intRand, double chanceToMutate)
protected abstract io.vavr.collection.Array<T> doMutate(io.vavr.collection.Array<T> representation, int index)
Mutate the representation at the given index.
This method purpose is to allow efficient unboxing in case of representations of primitives.
representation
- the representation to be mutatedindex
- the index at which mutation should occurpublic boolean isMemoized()