pga
Class GAParallelGA

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

public class GAParallelGA
extends java.lang.Thread

Trida geneticky algoritmus.

Definuje vlastni chovani genetickeho algoritmu. Vyuziva pole trid Population pro uchovani kmenu.

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 migrationRate
          pocet jedincu migrujicich mezi populacemi
 int mutationRate
          procento pravdepodobnosti mutace
 int nDemes
          pocet kmenu
 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
GAParallelGA()
           
 
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 genom v populaci
 GAGenome getBSF()
          Vrati nejlepsi dosud nalezene reseni
 void changeNDemes(int newNDemes)
          Zmeni pocet subpopulaci algoritmu
protected  void chooseParents(int deme)
          Vybere rodice z populace reseni.
 void init(int i, GAPopulation pop, PGAPresentationCanvas c)
          Vytvori geneticky algoritmus se zadanou populaci.
protected  void initialize()
          Inicializuje geneticky algoritmus pro reseni.
 void migrate()
          Provede migraci mezi subpopulacemi
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(int deme)
          Nahradi vybrane reseni novym vzniklym potomkem.
 void resizeDemes(int newSize)
          Zmeni velikost subpopulaci
 void run()
          Spusti geneticky algoritmus.
protected  void selectBad(int deme)
          Vybere reseni, ktere se vyhodi a bude nahrazeno novym.
 void setMigrationRate(int newRate)
          Nastavi pocet migrujicich jedincu
 
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

migrationRate

public int migrationRate
pocet jedincu migrujicich mezi populacemi

nDemes

public int nDemes
pocet kmenu

stats

public GAStatistics stats
Statistiky o behu GA.

generation

public int generation
Cislo generace
Constructor Detail

GAParallelGA

public GAParallelGA()
Method Detail

init

public void init(int i,
                 GAPopulation pop,
                 PGAPresentationCanvas c)
Vytvori geneticky algoritmus se zadanou populaci.

setMigrationRate

public void setMigrationRate(int newRate)
Nastavi pocet migrujicich jedincu

generationStep

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

randomize

public void randomize()
Znahodni populaci reseni.

migrate

public void migrate()
Provede migraci mezi subpopulacemi

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 genom v populaci

getBSF

public GAGenome getBSF()
Vrati nejlepsi dosud nalezene reseni

countFitness

protected void countFitness()
Vypocita ohodnoceni nove generace.

changeNDemes

public void changeNDemes(int newNDemes)
Zmeni pocet subpopulaci algoritmu

resizeDemes

public void resizeDemes(int newSize)
Zmeni velikost subpopulaci

chooseParents

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

recombine

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

recombine

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

mutate

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

selectBad

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

replaceBad

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

canTerminate

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

Zde vraci konstantu zadanou ve tride Globals

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

actionStop

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