From 8189116ea4b5db4675e31dfd04a5687d55e29262 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Tue, 6 May 2014 14:29:37 +0100 Subject: Added javadocs, made minor changes to the comments --- doc/jcgp/backend/modules/problem/Problem.html | 508 ++++++++++++++++++++++++++ 1 file changed, 508 insertions(+) create mode 100644 doc/jcgp/backend/modules/problem/Problem.html (limited to 'doc/jcgp/backend/modules/problem/Problem.html') diff --git a/doc/jcgp/backend/modules/problem/Problem.html b/doc/jcgp/backend/modules/problem/Problem.html new file mode 100644 index 0000000..0d08b2a --- /dev/null +++ b/doc/jcgp/backend/modules/problem/Problem.html @@ -0,0 +1,508 @@ + + + + + +Problem + + + + + + + + +
+ + + + + + + +
+ + + +
+
jcgp.backend.modules.problem
+

Class Problem

+
+
+ +
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    TestCaseProblem
    +
    +
    +
    +
    public abstract class Problem
    +extends Module
    +
    Defines the general behaviour of a CGP problem. The primary function of Problem + is to evaluate a population and assign a fitness value to each chromosome. +
    + Problems are free to define whether better fitness means a higher or lower fitness value. + In some problem types, it is more convenient to treat fitness 0 as the best possible value. + This can be done by changing the fitness orientation to BestFitness.HIGH or BestFitness.LOW as appropriate. + Fitness orientation is set to high by default. +

    + When extending this class, the constructor should call a few methods in order to + properly construct the problem type: setFunctionSet(), setFileExtension() and setFitnessOrientation(), + with the respective arguments. As with all subclasses of Module, setName() and + registerParameters() should be used where appropriate as well. +

    + It is advisable to use Resources.reportln() and Resources.report() + to print any relevant information. Note that reportln() and report() are affected + by the report interval base parameter. Use Resources.println() and + Resources.print() to print information regardless of the current generation. + See Resources for more information.
    +
    +
    Author:
    +
    Eduardo Pedroni
    +
    See Also:
    +
    Module
    +
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Problem

        +
        public Problem(Resources resources)
        +
        Initialises the two problem-wide parameters, maxFitness and bestFitness.
        +
        +
        Parameters:
        +
        resources - a reference to the experiment's resources.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        evaluate

        +
        public abstract void evaluate(Population population,
        +                              Resources resources)
        +
        The most important method of the problem type. This is called once + per generation, when the new population has been generated. +

        + The basic functionality of this method is to loop through all chromosomes + in the population and decode them according to the problem type. The + fitness of each chromosome is then calculated using the problem data + or otherwise (subjective problem types such as art generation might + leave fitness evaluations up to the user) and assigned to the appropriate + chromosome. +

        + In addition, realisations of this method should update the value of + bestFitness as appropriate, since the value of this parameter is displayed + if a GUI is in use.
        +
        +
        Parameters:
        +
        population - the population to be evaluated.
        +
        resources - parameters and utilities for optional reference.
        +
        +
      • +
      + + + +
        +
      • +

        perfectSolutionFound

        +
        public abstract int perfectSolutionFound(Population population)
        +
        Used to assert whether a given population contains a perfect solution + to the problem. It is up to the problem to define what qualifies + a perfect solution, as some problems (subject ones such as music and + art evolution, for example) might not have perfect solutions at all.
        +
        +
        Parameters:
        +
        population - the population to search through for a perfect chromosome.
        +
        Returns:
        +
        the perfect solution index, if one exits, -1 if no perfect solution was found.
        +
        +
      • +
      + + + +
        +
      • +

        hasImprovement

        +
        public abstract int hasImprovement(Population population)
        +
        Used to assert whether a given population has a chromosome that is an improvement over + the current best chromosome. A typical implementation of this method + will simply compare chromosome fitness values, though the problem type + is free to implement this in any way.
        +
        +
        Parameters:
        +
        population - the population potentially containing a fitter chromosome.
        +
        Returns:
        +
        the index of the first chromosome in the population that is an improvement, -1 if none is found.
        +
        +
      • +
      + + + +
        +
      • +

        parseProblemData

        +
        public abstract void parseProblemData(java.io.File file,
        +                                      ModifiableResources resources)
        +
        Parses the specified file and uses the parsed data to + set up the problem type instance appropriately. Any necessary + resource changes can be performed using the provided ModifiableResources + instance. +

        + In addition, realisations of this method should update the value of + maxFitness where appropriate, as this may be displayed to the user + if a GUI is in use.
        +
        +
        Parameters:
        +
        file - the data file to parse.
        +
        resources - a modifiable reference to the experiment's resources.
        +
        +
      • +
      + + + +
        +
      • +

        getFunctionSet

        +
        public FunctionSet getFunctionSet()
        +
        +
        Returns:
        +
        the FunctionSet object used by this problem type.
        +
        +
      • +
      + + + +
        +
      • +

        getFileExtension

        +
        public java.lang.String getFileExtension()
        +
        +
        Returns:
        +
        the file extension accepted by this problem type for problem data files.
        +
        +
      • +
      + + + +
        +
      • +

        getFitnessOrientation

        +
        public BestFitness getFitnessOrientation()
        +
        +
        Returns:
        +
        the fitness orientation of this particular problem.
        +
        +
      • +
      + + + +
        +
      • +

        getBestFitness

        +
        public double getBestFitness()
        +
        +
        Returns:
        +
        the current best fitness, in other words, the fitness + value of the fittest chromosome in the current generation.
        +
        +
      • +
      + + + +
        +
      • +

        reset

        +
        public void reset()
        +
        Resets the bestFitness parameter.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + -- cgit v1.2.3