public class JCGP
extends java.lang.Object
Resources
object which can be retrieved via a getter. Modules can be selected using their
respective setters.
start()
, nextGeneration()
and reset()
. Files can be loaded with their respective load methods and
chromosome configurations can be saved with saveChromosome()
.
System.console()
, so that messages
can also be printed to a GUI, for example. This extra console can be set with setConsole()
,
and must implement jcgp.resources.Console.Constructor and Description |
---|
JCGP()
Creates a new instance of JCGP.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<EvolutionaryStrategy> |
getEvolutionaryStrategies() |
EvolutionaryStrategy |
getEvolutionaryStrategy() |
Mutator |
getMutator() |
java.util.ArrayList<Mutator> |
getMutators() |
Population |
getPopulation() |
Problem |
getProblem() |
java.util.ArrayList<Problem> |
getProblems() |
ModifiableResources |
getResources()
Returns a reference to the
ModifiableResources used by the
experiment. |
boolean |
isFinished()
Returns the experiment's status.
|
void |
loadChromosome(java.io.File file,
int chromosomeIndex)
Loads a chromosome from the given file into
the specified population index.
|
void |
loadParameters(java.io.File file)
When given a .par file, this method loads the parameters into the
experiment's resources.
|
void |
loadProblemData(java.io.File file)
Parses a problem data file.
|
static void |
main(java.lang.String... args)
JCGP main method, this is used to execute JCGP from the command line.
|
void |
nextGeneration()
Performs one full generational cycle.
|
void |
reset()
Resets the experiment.
|
void |
saveChromosome(java.io.File file,
int chromosomeIndex)
Saves a copy of the specified chromosome
into the given file.
|
void |
setConsole(Console console)
Sets an extra console.
|
void |
setEvolutionaryStrategy(int index) |
void |
setMutator(int index) |
void |
setProblem(int index) |
void |
start()
This method calls
nextGeneration() in a loop
until the experiment is flagged as finished. |
public static void main(java.lang.String... args)
args
- one or more files needed to perform the experiment.public ModifiableResources getResources()
ModifiableResources
used by the
experiment. public Population getPopulation()
public java.util.ArrayList<Mutator> getMutators()
public Mutator getMutator()
public java.util.ArrayList<EvolutionaryStrategy> getEvolutionaryStrategies()
public EvolutionaryStrategy getEvolutionaryStrategy()
public java.util.ArrayList<Problem> getProblems()
public Problem getProblem()
public void setMutator(int index)
index
- the index of the desired mutator.public void setEvolutionaryStrategy(int index)
index
- the index of the desired evolutionary strategy.public void setProblem(int index)
index
- the index of the desired problem type.public void nextGeneration()
reset()
is called.public void start()
nextGeneration()
in a loop
until the experiment is flagged as finished. This is
performed on the same thread of execution, so this
method will most likely block for a significant amount
of time (problem-dependent, but anywhere from seconds to days).
reset()
is called.public void reset()
public void loadParameters(java.io.File file)
file
- the file to parse.public void loadProblemData(java.io.File file)
file
- the file to parse.public void loadChromosome(java.io.File file, int chromosomeIndex)
file
- the chromosome to parse.chromosomeIndex
- the population index into which to parse.public void saveChromosome(java.io.File file, int chromosomeIndex)
file
- the target file.chromosomeIndex
- the index of the chromosome to save.public boolean isFinished()
reset()
.public void setConsole(Console console)
System.console()
but also to an
additional console, if one is defined. This is used so
that messages are printed on a user interface as well,
or written directly to a file, for example.console
- the extra console to be used.