pga
Class GASteadyStateGA

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--pga.GASteadyStateGA

public class GASteadyStateGA
extends java.lang.Thread

Trida geneticky algoritmus.

Definuje vlastni chovani genetickeho algoritmu. Vyuziva tridu Population pro uchovani populace.

Tento algoritmus lze pouzit jako vlakno jakehokoliv programu, pouze staci zinicializovat s pozadovanou populaci a spustit pomoci run().


Field Summary
 int bornRate
          procento narozenych v jedne generaci
 int generation
          Cislo generace
 int mutationRate
          procento pravdepodobnosti mutace
 int parentRate
          procento populace, ze ktere se vybiraji rodice
 GAStatistics stats
          Statistiky o behu GA.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GASteadyStateGA()
           
 
Method Summary
 void actionStop()
          Pozastavi geneticky algoritmus.
protected  boolean canTerminate()
          Test, zda se muze geneticky algoritmus ukocit.
protected  void countFitness()
          Vypocita ohodnoceni nove generace.
 void generationStep()
          Provede jeden vnitrni cyklus - pro jednu generaci.
 GAGenome getBestGenomeInPop()
          Vrati nejlepsi reseni v populaci
 GAGenome getBSF()
          Vrati nejlepsi dosud nalezene reseni
protected  void chooseParents()
          Vybere rodice z populace reseni.
 void init(GAPopulation population)
          Vytvori geneticky algoritmus se zadanou populaci.
protected  void initialize()
          Inicializuje geneticky algoritmus pro reseni.
protected  boolean isEnough()
          Test, zda jiz bylo dost potomku a lze ukoncit cyklus pro generaci.
protected  void mutate()
          Zmutuje potomka po rekombinaci.
 void randomize()
          Znahodni populaci reseni.
protected  void recombine()
          Zkrizi vybrane rodice.
protected  void recombine(int a, int b)
          Zkrizi vybrane rodice v danych bodech krizeni.
protected  void replaceBad()
          Nahradi vybrane reseni nove vzniklym potomkem.
 void resizePop(int newSize)
          Zmeni velikost populace
 void run()
          Spusti geneticky algoritmus.
protected  void selectBad()
          Vybere reseni, ktere se vyhodi a bude nahrazeno novym.
 
Methods inherited from class java.lang.Thread
activeCount, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, checkAccess, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bornRate

public int bornRate
procento narozenych v jedne generaci

mutationRate

public int mutationRate
procento pravdepodobnosti mutace

parentRate

public int parentRate
procento populace, ze ktere se vybiraji rodice

stats

public GAStatistics stats
Statistiky o behu GA.

generation

public int generation
Cislo generace
Constructor Detail

GASteadyStateGA

public GASteadyStateGA()
Method Detail

init

public void init(GAPopulation population)
Vytvori geneticky algoritmus se zadanou populaci.

generationStep

public void generationStep()
Provede jeden vnitrni cyklus - pro jednu generaci.

randomize

public void randomize()
Znahodni populaci reseni.

run

public void run()
Spusti geneticky algoritmus.
Overrides:
run in class java.lang.Thread
See Also:
actionStop()

initialize

protected void initialize()
Inicializuje geneticky algoritmus pro reseni.

getBestGenomeInPop

public GAGenome getBestGenomeInPop()
Vrati nejlepsi reseni v populaci

getBSF

public GAGenome getBSF()
Vrati nejlepsi dosud nalezene reseni

countFitness

protected void countFitness()
Vypocita ohodnoceni nove generace.

resizePop

public void resizePop(int newSize)
Zmeni velikost populace

chooseParents

protected void chooseParents()
Vybere rodice z populace reseni.
See Also:
recombine()

recombine

protected void recombine()
Zkrizi vybrane rodice.
See Also:
chooseParents()

recombine

protected void recombine(int a,
                         int b)
Zkrizi vybrane rodice v danych bodech krizeni.
See Also:
chooseParents(), recombine()

mutate

protected void mutate()
Zmutuje potomka po rekombinaci.
See Also:
recombine()

selectBad

protected void selectBad()
Vybere reseni, ktere se vyhodi a bude nahrazeno novym.
See Also:
replaceBad()

replaceBad

protected void replaceBad()
Nahradi vybrane reseni nove vzniklym potomkem.
See Also:
selectBad(), recombine()

isEnough

protected boolean isEnough()
Test, zda jiz bylo dost potomku a lze ukoncit cyklus pro generaci.

canTerminate

protected boolean canTerminate()
Test, zda se muze geneticky algoritmus ukocit.

Zde vraci konstantu ze tridy Globals.

See Also:
Pokud je treba, je mozne v potomcich zmenit.

actionStop

public void actionStop()
Pozastavi geneticky algoritmus.
See Also:
run()