|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgap.MutationOperator
public abstract class MutationOperator
Abstract class for mutation operators. Handles iteration over population and updating
chromosome material with changes generated by subclass implementation of
mutate( final Configuration config,
final ChromosomeMaterial material, Set genesToAdd, Set genesToRemove )
.
Constructor Summary | |
---|---|
MutationOperator(float aMutationRate)
|
Method Summary | |
---|---|
protected boolean |
doesMutationOccur(java.util.Random rand)
|
protected static boolean |
doesMutationOccur(java.util.Random rand,
float mutationRate)
|
float |
getMutationRate()
|
protected abstract void |
mutate(Configuration config,
ChromosomeMaterial target,
java.util.Set allelesToAdd,
java.util.Set allelesToRemove)
Leaves material unmodified, but updates allelesToAdd and
allelesToRemove with modifications. |
void |
mutate(Configuration config,
java.util.List offspring)
The operate method will be invoked on each of the mutation operators referenced by the current Configuration object during the evolution phase. |
protected int |
numMutations(java.util.Random rand,
int numOpportunities)
|
protected void |
setMutationRate(float aMutationRate)
|
protected static void |
updateMaterial(ChromosomeMaterial material,
java.util.Set allelesToAdd,
java.util.Set allelesToRemove)
updates material with specified sets of alleles; alleles present in both lists
will be added (or replaced if the gene existed on original material) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MutationOperator(float aMutationRate)
aMutationRate
- Method Detail |
---|
protected abstract void mutate(Configuration config, ChromosomeMaterial target, java.util.Set allelesToAdd, java.util.Set allelesToRemove) throws InvalidConfigurationException
material
unmodified, but updates allelesToAdd
and
allelesToRemove
with modifications. This interface was chosen at a time when
we wanted to have the mutation operators not augment each other; i.e., each one operated on
the original material
, and the total allelesToAdd
and
allelesToRemove
from all mutations would be applied at once. We have gone back
to updating material
after each mutation operator, but left the interface this
way in case we decide to switch again.
config
- target
- chromosome material before mutationallelesToAdd
- alleles added by this mutation, Set
contains
Allele
objectsallelesToRemove
- alleles removed by this mutation, Set
contains
Allele
objects
InvalidConfigurationException
public void mutate(Configuration config, java.util.List offspring) throws InvalidConfigurationException
config
- The current active genetic configuration.offspring
- List
Contains ChromosomeMaterial
objects from
the current evolution. Material in this List
should be modified directly.
InvalidConfigurationException
protected int numMutations(java.util.Random rand, int numOpportunities)
rand
- numOpportunities
-
rand
random number generator,
numOpportunities
number of oppurtunities for the mutation to occur, and the
configured mutation rateprotected boolean doesMutationOccur(java.util.Random rand)
rand
-
true
when mutation rate and random chance dictate a mutation should
occurprotected static boolean doesMutationOccur(java.util.Random rand, float mutationRate)
rand
- mutationRate
-
true
when mutation rate and random chance dictate a mutation should
occurpublic float getMutationRate()
protected static void updateMaterial(ChromosomeMaterial material, java.util.Set allelesToAdd, java.util.Set allelesToRemove)
material
with specified sets of alleles; alleles present in both lists
will be added (or replaced if the gene existed on original material)
material
- allelesToAdd
- Set
contains Allele
objecsallelesToRemove
- Set
contains Allele
objectsprotected void setMutationRate(float aMutationRate)
aMutationRate
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |