All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpsys.GPParameters

java.lang.Object
   |
   +----gpsys.GPParameters

public class GPParameters
extends Object
implements Serializable

This class is used to parameterise the GP system. Use this class as is or extend it for your problem, but in either case fill in the instance variables to specify your problem.

The class supports methods enabling loading and saving of a GPParameters object. The object may be written/read to/from either a file or a stream. These methods use Java Serialisable Objects and hence if you extend the class to include new instance variables, ensure that they are Serializable so that they can be saved. If any instance variables you introduce are temporary variables, declare them transient to ensure they are not saved.

There are also methods enabling a generation report to be sent to a file or an OutputStream.

Version:
1.1, 30th June '97
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.

Variable Index

 o adf
Parameters for each ADF to be evolved.
 o creationIndex
Used during the generation of the initial popupation.
 o fitness
The Fitness definition for the problem.
 o generations
The number of generations to evolve.
 o observer
The object monitoring the GP system.
 o pMutation
The probability of mutation.
 o population
The population.
 o populationSize
How many Individuals there are in the population.
 o rng
The random number generator.
 o rngSeed
The random number generator seed.
 o tournamentSize
The tournament size to be used for tournament selection during crossover and mutation.

Constructor Index

 o GPParameters()

Method Index

 o load(InputStream)
Load a GPParameters object from the InputStream.
 o load(String)
Loads a previously saved GPParameters object from the file specified.
 o save(OutputStream)
Write this object to an OutputStream compressing it using gzip as it is written.
 o save(String)
Save this object to a file compressing it using gzip during the save.
 o writeReport(PrintWriter, boolean)
Write a report of the current generation to the PrintWriter.
 o writeReport(String, boolean)
Write a report of the current generation to a file.

Variables

 o observer
 public transient GPObserver observer
The object monitoring the GP system.

 o rngSeed
 public long rngSeed
The random number generator seed.

 o rng
 public Random rng
The random number generator. This should have been created with the above seed.

 o pMutation
 public double pMutation
The probability of mutation. This needs to be a number between 0 and 1.

 o tournamentSize
 public int tournamentSize
The tournament size to be used for tournament selection during crossover and mutation.

 o populationSize
 public int populationSize
How many Individuals there are in the population.

 o generations
 public int generations
The number of generations to evolve.

 o adf
 public ChromosomeParameters adf[]
Parameters for each ADF to be evolved. The length of this array is effectively the number of ADFs required.

 o fitness
 public Fitness fitness
The Fitness definition for the problem.

 o population
 public Population population
The population. This field is filled in automatically by the GP system.

 o creationIndex
 protected int creationIndex
Used during the generation of the initial popupation. It is the index of the current Individual being created.

Constructors

 o GPParameters
 public GPParameters()

Methods

 o save
 public void save(String filePrefix) throws IOException
Save this object to a file compressing it using gzip during the save. This method is typically called by GPObservers after every generation to enable restarting from the last saved point in the event of system failure.

Parameters:
filePrefix - the file prefix to be used for save files. Two files may be created :- filePrefix.p1.gzip and filePrefix.p2.gzip
 o save
 public void save(OutputStream os) throws IOException
Write this object to an OutputStream compressing it using gzip as it is written.

Parameters:
os - the output stream to be written to.
 o load
 public static GPParameters load(String filePrefix) throws IOException, ClassNotFoundException
Loads a previously saved GPParameters object from the file specified. The GPParameters object must previously have been saved by the save() method. The save file is assumed to be gzipped and hence is decompressed during the read.

Parameters:
filePrefix - the file prefix used by the save files.
Returns:
the GPParameters object read from the file.
Throws: ClassNotFoundException
if the class definition for one of the objects being read cannot be found.
 o load
 public static GPParameters load(InputStream is) throws IOException, ClassNotFoundException
Load a GPParameters object from the InputStream. The stream is assumed to be gzipped and is hence unzipped during the load.

Parameters:
is - the input stream to read from.
Returns:
the GPParameters object read from the stream.
Throws: ClassNotFoundException
if the class definition for one of the objects being read cannot be found.
 o writeReport
 public void writeReport(PrintWriter pw,
                         boolean firstReport)
Write a report of the current generation to the PrintWriter. The first report also contains the random number generator seed, the population size and the number of generations to be evolved.

Parameters:
pw - the PrintWriter to use to print the report.
firstReport - specifies whether this the first report.
 o writeReport
 public void writeReport(String filePrefix,
                         boolean firstReport) throws IOException
Write a report of the current generation to a file. The first report also contains the random number generator seed, the population size and the number of generations to be evolved.

Parameters:
filePrefix - the filename prefix to use for the file to which the report is written. The file created is named : filePrefix.txt
firstReport - specifies whether this the first report.

All Packages  Class Hierarchy  This Package  Previous  Next  Index