pga
Class GATSPGenome

java.lang.Object
  |
  +--pga.GAGenome
        |
        +--pga.GATSPGenome

public class GATSPGenome
extends GAGenome

Třída představující genom (chromozom) pro problém obchodního cestujícího.

Implementuje abstraktni metody tridy GAGenome.

Zmenou operatoru makeCrossover a makeMutation lze dosahnout zlepseni algoritmu.

See Also:
makeCrossover(GAGenome gen), makeMutation()

Fields inherited from class pga.GAGenome
fitness
 
Constructor Summary
GATSPGenome(TSPProblem TSP)
          Vytvori nove reseni instance TSP dle parametru.
 
Method Summary
 java.lang.Object clone()
          Vrati svoji kopii.
 GAGenome cloneGen()
          Vrati svoji kopii.
protected  void evaluate()
          Spocita kvalitu genomu.
 int getCityAtIndex(int i)
          Vrati cislo mesta i-teho v poradi
 int getCount()
          Vrati pocet mest v TSP.
 int getCrossoverPoint()
          Vrati vhodny bod rekombinace.
 TSPProblem getTSP()
          Vrati instanci problemu TSP
protected  void makeCrossover(GAGenome gen)
          Provede krizeni se zadanym resenim.
protected  void makeCrossover(GAGenome secGen, int a, int b)
          Provede krizeni.
protected  void makeMutation()
          Provede mutaci reseni.
 GAGenome newRandom()
          Vytvori nove reseni.
 void randomize()
          Znahodni reseni.
 java.lang.String toString()
          Vrati textovou reprezentaci reseni se zobrazenymi body rekombinace.
 java.lang.String toString(int point1, int point2)
          Vrati textovou reprezentaci reseni se zobrazenymi body rekombinace.
 
Methods inherited from class pga.GAGenome
cross, cross, getFitness, mutate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GATSPGenome

public GATSPGenome(TSPProblem TSP)
Vytvori nove reseni instance TSP dle parametru.

Nastavi trivialni reseni.

Parameters:
TSP - instance problemu obchodniho cestujiciho
Method Detail

getTSP

public TSPProblem getTSP()
Vrati instanci problemu TSP

getCount

public int getCount()
Vrati pocet mest v TSP.

getCityAtIndex

public int getCityAtIndex(int i)
Vrati cislo mesta i-teho v poradi

newRandom

public GAGenome newRandom()
Vytvori nove reseni.
Overrides:
newRandom in class GAGenome
Returns:
nove (obecne jine) reseni

cloneGen

public GAGenome cloneGen()
Vrati svoji kopii.

Narozdil od clone() nevraci Object ale GAGenome. Zkopiruje poradi mest.

Overrides:
cloneGen in class GAGenome
See Also:
clone()

clone

public java.lang.Object clone()
Vrati svoji kopii.

Overrides:
clone in class GAGenome
See Also:
cloneGen()

evaluate

protected void evaluate()
Spocita kvalitu genomu. Vysledek je ve fitnessValue.
Overrides:
evaluate in class GAGenome
Returns:
vhodnost = delka cesty
See Also:
GAGenome.getFitness()

makeCrossover

protected void makeCrossover(GAGenome gen)
Provede krizeni se zadanym resenim.
Overrides:
makeCrossover in class GAGenome
Parameters:
secondSolution - reseni pro krizeni
See Also:
getCrossoverPoint(), makeCrossover(GAGenome secGen, int a, int b)

getCrossoverPoint

public int getCrossoverPoint()
Vrati vhodny bod rekombinace.
Overrides:
getCrossoverPoint in class GAGenome
Returns:
cislo mesta, kde lze rekombinovat

makeCrossover

protected void makeCrossover(GAGenome secGen,
                             int a,
                             int b)
Provede krizeni.

Ze sebe zkopiruje mesta mezi body rekombinace a pote postupne z druheho reseni vybira nepouzita mesta a od zacatku trasy je umistuje na volna mista.

Overrides:
makeCrossover in class GAGenome
Parameters:
secGen - reseni pro krizeni
a - prvni bod rekombinace
b - druhy bod rekombinace

makeMutation

protected void makeMutation()
Provede mutaci reseni. Prevrati nahodnou cast genomu.
Overrides:
makeMutation in class GAGenome

randomize

public void randomize()
Znahodni reseni.

Nekolikrat zmutuje.

Overrides:
randomize in class GAGenome
See Also:
makeMutation()

toString

public java.lang.String toString(int point1,
                                 int point2)
Vrati textovou reprezentaci reseni se zobrazenymi body rekombinace.
Overrides:
toString in class GAGenome
Parameters:
point1 - prvni bod rekombinace
point2 - druhy bod rekombinace
Returns:
zobraziteny retezec s resenim

toString

public java.lang.String toString()
Vrati textovou reprezentaci reseni se zobrazenymi body rekombinace.
Overrides:
toString in class java.lang.Object
Returns:
zobraziteny retezec s resenim
See Also:
toString(int point1, int point2)