public class EvolutionState extends Object implements Singleton
The EvolutionState instance is passed around in a lot of methods, so objects can read from the parameter database, pick random numbers, and write to the output facility.
EvolutionState is a unique object in that it calls its own setup(...) method, from run(...).
An EvolutionState object contains quite a few objects, including:
Parameters
generations int >= 1 or undefined |
(maximal number of generations to run. Either this or evaluations must be set, but not both.) |
evaluations int >= 1 or undefined |
(maximal number of evaluations to run (in subpopulation 0). Either this or generations must be set, but not both.) |
checkpoint-modulo int >= 1 |
(how many generations should pass before we do a checkpoint? The definition of "generations" depends on the particular EvolutionState implementation you're using) |
checkpoint bool = true or false (default) |
(should we checkpoint?) |
prefix String |
(the prefix to prepend to checkpoint files -- see ec.util.Checkpoint) |
checkpoint-directory File (default is empty) |
(directory where the checkpoint files should be located) |
quit-on-run-complete bool = true or false (default) |
(do we prematurely quit the run when we find a perfect individual?) |
init classname, inherits and != ec.Initializer |
(the class for initializer) |
finish classname, inherits and != ec.Finisher |
(the class for finisher) |
breed classname, inherits and != ec.Breeder |
(the class for breeder) |
eval classname, inherits and != ec.Evaluator |
(the class for evaluator) |
stat classname, inherits or = ec.Statistics |
(the class for statistics) |
exch classname, inherits and != ec.Exchanger |
(the class for exchanger) |
Parameter bases
init | initializer |
finish | finisher |
breed | breeder |
eval | evaluator |
stat | statistics |
exch | exchanger |
Modifier and Type | Field and Description |
---|---|
Breeder |
breeder
The population breeder, a singleton object.
|
int |
breedthreads
The requested number of threads to be used in breeding, excepting perhaps a "parent" thread which gathers the other threads.
|
static int |
C_STARTED_FRESH
"The population has started fresh (not from a checkpoint)."
|
static int |
C_STARTED_FROM_CHECKPOINT
"The population started from a checkpoint."
|
boolean |
checkpoint
Should we checkpoint at all?
|
File |
checkpointDirectory
The requested directory where checkpoints should be located.
|
int |
checkpointModulo
The requested number of generations that should pass before we write out a checkpoint file.
|
String |
checkpointPrefix
The requested prefix to start checkpoint filenames, not including a following period.
|
HashMap[] |
data
An array of HashMaps, indexed by the thread number you were given (or, if you're not in a multithreaded area, use 0).
|
int |
evalthreads
The requested number of threads to be used in evaluation, excepting perhaps a "parent" thread which gathers the other threads.
|
int |
evaluations
The current number of evaluations which have transpired so far in the run.
|
Evaluator |
evaluator
The population evaluator, a singleton object.
|
Exchanger |
exchanger
The population exchanger, a singleton object.
|
Finisher |
finisher
The population finisher, a singleton object.
|
int |
generation
The current generation of the population in the run.
|
Initializer |
initializer
The population initializer, a singleton object.
|
long |
innovationNumber
Global birthday tracker number for genes in representations such as NEAT.
|
Object[] |
job
Current job iteration variables, set by Evolve.
|
(package private) Object[] |
lock |
long |
numEvaluations
The number of evaluations the evolutionary computation system will run until it ends (up to the next generation boundary), or UNDEFINED
|
int |
numGenerations
The number of generations the evolutionary computation system will run until it ends, or UNDEFINED
|
Output |
output
The output and logging facility (threadsafe).
|
static String |
P_BREEDER |
static String |
P_CHECKPOINT |
static String |
P_CHECKPOINTDIRECTORY |
static String |
P_CHECKPOINTMODULO |
static String |
P_CHECKPOINTPREFIX |
(package private) static String |
P_CHECKPOINTPREFIX_OLD |
static String |
P_EVALUATIONS |
static String |
P_EVALUATOR |
static String |
P_EXCHANGER |
static String |
P_FINISHER |
static String |
P_GENERATIONS |
static String |
P_INITIALIZER |
static String |
P_INNOVATIONNUMBER |
static String |
P_QUITONRUNCOMPLETE |
static String |
P_STATISTICS |
ParameterDatabase |
parameters
The parameter database (threadsafe).
|
Population |
population
The current population.
|
boolean |
quitOnRunComplete
Whether or not the system should prematurely quit when Evaluator returns true for runComplete(...) (that is, when the system found an ideal individual.
|
static int |
R_FAILURE
"The evolution run has quit, failing to find a perfect individual."
|
static int |
R_NOTDONE
"The evolution run has not quit
|
static int |
R_SUCCESS
"The evolution run has quit, finding a perfect individual."
|
MersenneTwisterFast[] |
random
An array of random number generators, indexed by the thread number you were given (or, if you're not in a multithreaded area, use 0).
|
int |
randomSeedOffset
An amount to add to each random number generator seed to "offset" it -- often this is simply the job number.
|
String[] |
runtimeArguments
The original runtime arguments passed to the Java process.
|
private static long |
serialVersionUID |
Statistics |
statistics
The population statistics, a singleton object.
|
static int |
UNDEFINED |
Constructor and Description |
---|
EvolutionState()
This will be called to create your evolution state; immediately
after the constructor is called,
the parameters, random, and output fields will be set
for you.
|
Modifier and Type | Method and Description |
---|---|
int |
evolve() |
void |
finish(int result) |
void |
incrementEvaluations(int val) |
void |
resetFromCheckpoint()
This method is called after a checkpoint
is restored from but before the run starts up again.
|
void |
run(int condition)
Starts the run.
|
void |
setup(EvolutionState state,
Parameter base)
Unlike for other setup() methods, ignore the base; it will always be null.
|
void |
startFresh() |
void |
startFromCheckpoint() |
(package private) void |
synchronizedIncrementEvaluations(int val) |
private static final long serialVersionUID
public ParameterDatabase parameters
public MersenneTwisterFast[] random
public HashMap[] data
public Output output
public int breedthreads
public int evalthreads
public boolean checkpoint
public File checkpointDirectory
public String checkpointPrefix
public int checkpointModulo
public int randomSeedOffset
public boolean quitOnRunComplete
public Object[] job
public String[] runtimeArguments
public static final int UNDEFINED
public int generation
public int evaluations
public int numGenerations
public long numEvaluations
public Population population
public Initializer initializer
public Finisher finisher
public Breeder breeder
public Evaluator evaluator
public Statistics statistics
public Exchanger exchanger
public long innovationNumber
public static final int C_STARTED_FRESH
public static final int C_STARTED_FROM_CHECKPOINT
public static final int R_SUCCESS
public static final int R_FAILURE
public static final int R_NOTDONE
public static final String P_INITIALIZER
public static final String P_FINISHER
public static final String P_BREEDER
public static final String P_EVALUATOR
public static final String P_STATISTICS
public static final String P_EXCHANGER
public static final String P_GENERATIONS
public static final String P_EVALUATIONS
public static final String P_QUITONRUNCOMPLETE
public static final String P_CHECKPOINTPREFIX
public static final String P_CHECKPOINTMODULO
public static final String P_CHECKPOINTDIRECTORY
public static final String P_CHECKPOINT
public static final String P_INNOVATIONNUMBER
static final String P_CHECKPOINTPREFIX_OLD
Object[] lock
public EvolutionState()
public void setup(EvolutionState state, Parameter base)
setup
in interface Setup
Prototype.setup(EvolutionState,Parameter)
public void resetFromCheckpoint() throws IOException
IOException
public void finish(int result)
public void startFromCheckpoint()
public void startFresh()
public int evolve() throws InternalError
InternalError
void synchronizedIncrementEvaluations(int val)
public void incrementEvaluations(int val)
public void run(int condition)
Copyright © 2019. All rights reserved.