jas.ai.ga
Class GeneticAlgorithm

java.lang.Object
  extended by jas.ai.ga.GeneticAlgorithm
All Implemented Interfaces:
IDecoder

public class GeneticAlgorithm
extends java.lang.Object
implements IDecoder

A genetic algorithm evolver.

Title: JAS

Description: Java Agent-based Simulation library

Copyright (C) 2002 Michele Sonnessa

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

Author:
Gianluigi Ferraris (original c code), Michele Sonnessa and Gianluigi Ferraris (java porting)


Field Summary
static double DEFAULT_CROSSOVER_RATE
           
static double DEFAULT_MUTATION_RATE
           
static boolean DEFAULT_NORMALIZE_FITNESS
           
static double DEFAULT_TURNOVER_RATE
           
 
Constructor Summary
GeneticAlgorithm(int rulesNumber, int ruleLength)
           
GeneticAlgorithm(int rulesNumber, int ruleLength, double turnoverRate, double crossoverRate, double mutationRate, boolean normalizeFitness)
           
 
Method Summary
 void evolve()
           
 boolean getAutoEvolution()
           
 GARule getBestRule()
           
 double getConvergence()
           
 double getCrossoverRate()
           
 int getCrossovers()
           
 double getCurrentFitness()
           
 GARule getCurrentRule()
           
 int getEvolutions()
           
 double getMaxFitness()
           
 double getMeanFitness()
           
 double getMinFitness()
           
 GARule getMostDiffusedRule()
           
 double getMutationRate()
           
 int getMutations()
           
 boolean getNormalizeFitness()
           
 double getSumFitness()
           
 double getTurnoverRate()
           
 GARule getWorstRule()
           
 void learn()
           
 void setARule(GARule rule)
           
 void setAutoEvolution(boolean aE)
           
 void setCrossoverRate(double cR)
           
 void setMutationRate(double mR)
           
 void setNormalizeFitness(boolean nF)
           
 void setReward(double fV)
           
 void setReward(GARule rule, double fV)
           
 void setTurnoverRate(double tR)
           
 void setWorstRule(GARule rule)
           
 GARule step()
           
 void think()
           
 java.lang.String toString()
           
 void verify()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CROSSOVER_RATE

public static final double DEFAULT_CROSSOVER_RATE
See Also:
Constant Field Values

DEFAULT_MUTATION_RATE

public static final double DEFAULT_MUTATION_RATE
See Also:
Constant Field Values

DEFAULT_NORMALIZE_FITNESS

public static final boolean DEFAULT_NORMALIZE_FITNESS
See Also:
Constant Field Values

DEFAULT_TURNOVER_RATE

public static final double DEFAULT_TURNOVER_RATE
See Also:
Constant Field Values
Constructor Detail

GeneticAlgorithm

public GeneticAlgorithm(int rulesNumber,
                        int ruleLength)

GeneticAlgorithm

public GeneticAlgorithm(int rulesNumber,
                        int ruleLength,
                        double turnoverRate,
                        double crossoverRate,
                        double mutationRate,
                        boolean normalizeFitness)
Method Detail

evolve

public void evolve()
Specified by:
evolve in interface IDecoder

getAutoEvolution

public boolean getAutoEvolution()

getBestRule

public GARule getBestRule()

getConvergence

public double getConvergence()

getCrossoverRate

public double getCrossoverRate()

getCrossovers

public int getCrossovers()

getCurrentFitness

public double getCurrentFitness()

getCurrentRule

public GARule getCurrentRule()

getEvolutions

public int getEvolutions()

getMaxFitness

public double getMaxFitness()

getMeanFitness

public double getMeanFitness()

getMinFitness

public double getMinFitness()

getMostDiffusedRule

public GARule getMostDiffusedRule()

getMutationRate

public double getMutationRate()

getMutations

public int getMutations()

getNormalizeFitness

public boolean getNormalizeFitness()

getSumFitness

public double getSumFitness()

getTurnoverRate

public double getTurnoverRate()

getWorstRule

public GARule getWorstRule()

learn

public void learn()
Specified by:
learn in interface IDecoder

setARule

public void setARule(GARule rule)

setAutoEvolution

public void setAutoEvolution(boolean aE)

setCrossoverRate

public void setCrossoverRate(double cR)

setMutationRate

public void setMutationRate(double mR)

setNormalizeFitness

public void setNormalizeFitness(boolean nF)

setReward

public void setReward(double fV)

setReward

public void setReward(GARule rule,
                      double fV)

setTurnoverRate

public void setTurnoverRate(double tR)

setWorstRule

public void setWorstRule(GARule rule)

step

public GARule step()

think

public void think()
Specified by:
think in interface IDecoder

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

verify

public void verify()