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.
-
adf
- Parameters for each ADF to be evolved.
-
creationIndex
- Used during the generation of the initial popupation.
-
fitness
- The Fitness definition for the problem.
-
generations
- The number of generations to evolve.
-
observer
- The object monitoring the GP system.
-
pMutation
- The probability of mutation.
-
population
- The population.
-
populationSize
- How many Individuals there are in the population.
-
rng
- The random number generator.
-
rngSeed
- The random number generator seed.
-
tournamentSize
- The tournament size to be used for tournament selection during crossover
and mutation.
-
GPParameters()
-
-
load(InputStream)
- Load a GPParameters object from the InputStream.
-
load(String)
- Loads a previously saved GPParameters object from the file specified.
-
save(OutputStream)
- Write this object to an OutputStream compressing it using gzip as it
is written.
-
save(String)
- Save this object to a file compressing it using gzip during the save.
-
writeReport(PrintWriter, boolean)
- Write a report of the current generation to the PrintWriter.
-
writeReport(String, boolean)
- Write a report of the current generation to a file.
observer
public transient GPObserver observer
- The object monitoring the GP system.
rngSeed
public long rngSeed
- The random number generator seed.
rng
public Random rng
- The random number generator. This should have been created with the
above seed.
pMutation
public double pMutation
- The probability of mutation. This needs to be a number between 0 and 1.
tournamentSize
public int tournamentSize
- The tournament size to be used for tournament selection during crossover
and mutation.
populationSize
public int populationSize
- How many Individuals there are in the population.
generations
public int generations
- The number of generations to evolve.
adf
public ChromosomeParameters adf[]
- Parameters for each ADF to be evolved. The length of this array is
effectively the number of ADFs required.
fitness
public Fitness fitness
- The Fitness definition for the problem.
population
public Population population
- The population. This field is filled in automatically by the GP system.
creationIndex
protected int creationIndex
- Used during the generation of the initial popupation. It is the index
of the current Individual being created.
GPParameters
public GPParameters()
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
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.
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.
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.
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.
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