megamek.client.bot.ga
Class GA

java.lang.Object
  extended by megamek.client.bot.ga.GA
Direct Known Subclasses:
GAAttack, GALance

public abstract class GA
extends java.lang.Object


Field Summary
protected  int best
           
(package private)  Chromosome[] chromNextGen
           
protected  int chromosomeDim
           
protected  Chromosome[] chromosomes
           
(package private)  double crossoverProb
           
(package private)  double[] genAvgDeviation
           
(package private)  double[] genAvgFitness
           
(package private)  int maxGenerations
           
(package private)  double mutationProb
           
protected  int populationDim
           
(package private)  double randomSelectionChance
           
 
Constructor Summary
GA(int chromosomeDim, int populationDim, double crossoverProb, double randomSelectionChance, int maxGenerations, double mutationProb)
           
 
Method Summary
(package private)  void computeFitnessRankings()
           
(package private)  void copyNextGenToThisGen()
           
protected  void doExhaustiveSearch()
           
(package private)  void doGeneticMating()
           
protected  void doHeuristicPass()
           
protected abstract  void doRandomMutation(int index)
           
(package private)  void doUniformCrossover(Chromosome c1, Chromosome c2)
           
 int evolve()
           
protected  double getAvgFitness()
           
protected  double getESquared()
           
protected abstract  double getFitness(int index)
           
 double getFittestChromosomesFitness()
           
(package private)  double getRandom(double upperBound)
           
(package private)  int getRandom(int upperBound)
           
protected abstract  void initPopulation()
           
protected  int[] selectTwoParents()
           
protected  boolean shouldDoExhaustive()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mutationProb

final double mutationProb

maxGenerations

final int maxGenerations

randomSelectionChance

final double randomSelectionChance

crossoverProb

final double crossoverProb

chromosomeDim

protected final int chromosomeDim

populationDim

protected final int populationDim

chromosomes

protected final Chromosome[] chromosomes

chromNextGen

Chromosome[] chromNextGen

genAvgDeviation

double[] genAvgDeviation

genAvgFitness

double[] genAvgFitness

best

protected final int best
Constructor Detail

GA

public GA(int chromosomeDim,
          int populationDim,
          double crossoverProb,
          double randomSelectionChance,
          int maxGenerations,
          double mutationProb)
Method Detail

initPopulation

protected abstract void initPopulation()

doRandomMutation

protected abstract void doRandomMutation(int index)

getFitness

protected abstract double getFitness(int index)

doHeuristicPass

protected void doHeuristicPass()

getFittestChromosomesFitness

public double getFittestChromosomesFitness()

getRandom

int getRandom(int upperBound)

getRandom

double getRandom(double upperBound)

shouldDoExhaustive

protected boolean shouldDoExhaustive()

doExhaustiveSearch

protected void doExhaustiveSearch()

evolve

public int evolve()

getAvgFitness

protected double getAvgFitness()

getESquared

protected double getESquared()

selectTwoParents

protected int[] selectTwoParents()

computeFitnessRankings

void computeFitnessRankings()

doGeneticMating

void doGeneticMating()

copyNextGenToThisGen

void copyNextGenToThisGen()

doUniformCrossover

void doUniformCrossover(Chromosome c1,
                        Chromosome c2)