|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jgap.BaseGeneticOperator
org.jgap.impl.MutationOperator
org.jgap.impl.SwappingMutationOperator
public class SwappingMutationOperator
Swaps the genes instead of mutating them. This kind of operator is required by Traveling Salesman Problem. See J. Grefenstette, R. Gopal, R. Rosmaita, and D. Gucht. Genetic algorithms for the traveling salesman problem. In Proceedings of the Second International Conference on Genetic Algorithms. Lawrence Eribaum Associates, Mahwah, NJ, 1985. and also Sushil J. Louis & Gong Li }
| Constructor Summary | |
|---|---|
SwappingMutationOperator()
Constructs a new instance of this operator. |
|
SwappingMutationOperator(Configuration a_config)
|
|
SwappingMutationOperator(Configuration a_config,
int a_desiredMutationRate)
Constructs a new instance of this MutationOperator with the given mutation rate. |
|
SwappingMutationOperator(Configuration a_config,
IUniversalRateCalculator a_mutationRateCalculator)
Constructs a new instance of this operator with a specified mutation rate calculator, which results in dynamic mutation being turned on. |
|
| Method Summary | |
|---|---|
int |
getStartOffset()
Gets a number of genes at the start of chromosome, that are excluded from the swapping. |
protected IChromosome |
operate(IChromosome a_x,
int a_rate,
RandomGenerator a_generator)
Operate on the given chromosome with the given mutation rate. |
void |
operate(Population a_population,
java.util.List a_candidateChromosomes)
The operate method will be invoked on each of the genetic operators referenced by the current Configuration object during the evolution phase. |
protected Gene[] |
operate(RandomGenerator a_generator,
int a_target_gene,
Gene[] a_genes)
Operate on the given array of genes. |
void |
setStartOffset(int a_offset)
Sets a number of genes at the start of chromosome, that are excluded from the swapping. |
| Methods inherited from class org.jgap.impl.MutationOperator |
|---|
compareTo, equals, getMutationRate, getMutationRateCalc, setMutationRateCalc |
| Methods inherited from class org.jgap.BaseGeneticOperator |
|---|
getConfiguration |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SwappingMutationOperator()
throws InvalidConfigurationException
Attention: The configuration used is the one set with the static method Genotype.setConfiguration.
InvalidConfigurationException
public SwappingMutationOperator(Configuration a_config)
throws InvalidConfigurationException
a_config - the configuration to use
InvalidConfigurationException
public SwappingMutationOperator(Configuration a_config,
IUniversalRateCalculator a_mutationRateCalculator)
throws InvalidConfigurationException
a_config - the configuration to usea_mutationRateCalculator - calculator for dynamic mutation rate
computation
InvalidConfigurationException
public SwappingMutationOperator(Configuration a_config,
int a_desiredMutationRate)
throws InvalidConfigurationException
a_config - the configuration to usea_desiredMutationRate - desired rate of mutation, expressed as
the denominator of the 1 / X fraction. For example, 1000 would result
in 1/1000 genes being mutated on average. A mutation rate of zero disables
mutation entirely
InvalidConfigurationException| Method Detail |
|---|
public void operate(Population a_population,
java.util.List a_candidateChromosomes)
GeneticOperatorThe parameters a_population and a_candidateChromosomes may refer to the same list of chromosomes for performance issues. Thus would mean an in-place modification. In ealier JGAP versions it was suggested never modifying the input population. Please refer to implementations delivered with JGAP to get a picture of the way non-susceptible in-place modifications are possible. If wrongly done, ConcurrentModificationException could be risen when accessing the population by an iterator in a GeneticOperator. Or, if population.getChromosomes().size() was used inside a loop where chromosomes were added to the input population this could lead to an infinite loop in worst case.
operate in interface GeneticOperatoroperate in class MutationOperatora_population - the population of chromosomes from the current
evolution prior to exposure to any genetic operators. Chromosomes in this
array should not be modified. Please, notice, that the call in
Genotype.evolve() to the implementations of GeneticOperator overgoes this
due to performance issuesa_candidateChromosomes - the pool of chromosomes that have been
selected for the next evolved population
protected IChromosome operate(IChromosome a_x,
int a_rate,
RandomGenerator a_generator)
a_x - chromosome to operatea_rate - mutation ratea_generator - random generator to use (must not be null)
protected Gene[] operate(RandomGenerator a_generator,
int a_target_gene,
Gene[] a_genes)
a_generator - a random number generator that may be needed to
perform a mutationa_target_gene - an index of gene in the chromosome that will mutatea_genes - the array of all genes in the chromosome
public void setStartOffset(int a_offset)
a_offset - the offset to setpublic int getStartOffset()
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||