Class GrammarBasedGeneticProgramming

  • All Implemented Interfaces:
    java.lang.Iterable<org.api4.java.algorithm.events.IAlgorithmEvent>, java.util.concurrent.Callable<GrammarBasedGeneticProgramming.GGPSolutionCandidate>, java.util.Iterator<org.api4.java.algorithm.events.IAlgorithmEvent>, org.api4.java.algorithm.IAlgorithm<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,​GrammarBasedGeneticProgramming.GGPSolutionCandidate>, org.api4.java.algorithm.IOptimizationAlgorithm<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,​GrammarBasedGeneticProgramming.GGPSolutionCandidate,​java.lang.Double>, org.api4.java.algorithm.ISolutionCandidateIterator<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,​GrammarBasedGeneticProgramming.GGPSolutionCandidate>, org.api4.java.common.control.ICancelable, org.api4.java.common.control.ILoggingCustomizable, org.api4.java.common.event.IEventEmitter<java.lang.Object>, org.api4.java.common.event.IRelaxedEventEmitter

    public class GrammarBasedGeneticProgramming
    extends ai.libs.jaicore.basic.algorithm.AOptimizer<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,​GrammarBasedGeneticProgramming.GGPSolutionCandidate,​java.lang.Double>
    Grammar-based genetic programming is an evolutionary algorithm capable of evolving individuals in the form of trees, where the trees are derived from a context-free grammar (CFG). As in standard evolutionary algorithms (EA), a population is maintained that is evaluated by means of a fitness function and subsequently individuals are recombined with each other and mutated. In contrast to standard EAs, special operators need to be applied to adhere to the rules imposed by the CFG and therefore to not invalidate individuals. This specific implementation allows for both limiting the execution by number of evaluations (generations*population_size) or a timeout. If the number of generations is set to an infeasible value, it will be assumed that the number of generations is set to infinity and thus a timeout will be required. As soon as the timeout is hit, the best solution seen so far will be returned. If the timeout is set to an infeasible value, the number of generations will be a required configuration value. When running the algorithm, it will run to the specified number of generation and return the best result found until this point. If both stopping criterions are set, the algorithm will terminate with the criterion that is first evaluated to true. So, either the timeout is hit or the maximum number of generations reached. Early Stopping: If the algorithm is already converged early, i.e., before the timeout is hit or the maximum number of generations is reached, it will terminate if the algorithm has not seen any improvements for a specified number of generations. Random Restart: Sometimes the algorithm may get stuck in local optima. To overcome this issue and move away from the local optima, there is a soft reset option called random restart. If random restart is configured, every x generations the algorithm could not find any improvement, the current population is wiped except for the best individuals (defined via the elitism config). Then, the population is filled up with new randomly sampled individuals. Thereby, the algorithm is able to move to other areas of the search space easily (given there are better fitness values).
    • Constructor Summary

      Constructors 
      Constructor Description
      GrammarBasedGeneticProgramming​(ai.libs.jaicore.basic.IOwnerBasedAlgorithmConfig config, ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double> input, long seed)  
      GrammarBasedGeneticProgramming​(ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double> input, long seed)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IGrammarBasedGeneticProgrammingConfig getConfig()  
      java.util.List<GrammarBasedGeneticProgramming.GGPSolutionCandidate> getLastRatedPopulation()  
      org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()  
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.AOptimizer

        call, getBestScoreKnownToExist, getBestSeenSolution, getLoggerName, nextSolutionCandidate, nextSolutionCandidateEvent, setBestSeenSolution, setLoggerName, tellAboutBestScoreKnownToExist, updateBestSeenSolution
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.ASolutionCandidateIterator

        collectAllSolutions
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.AAlgorithm

        activate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, cancel, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getDeadline, getId, getInput, getListeners, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasNext, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeoutDefined, isTimeouted, iterator, next, post, registerActiveThread, registerListener, resolveShutdownInterruptOnCurrentThread, setConfig, setDeadline, setMaxNumThreads, setNumCPUs, setState, setTimeout, setTimeout, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdown
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.api4.java.algorithm.IAlgorithm

        getId, getInput, getNumCPUs, getTimeout, registerListener, setMaxNumThreads, setNumCPUs, setTimeout, setTimeout
      • Methods inherited from interface org.api4.java.common.control.ICancelable

        cancel
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, next, remove
    • Constructor Detail

      • GrammarBasedGeneticProgramming

        public GrammarBasedGeneticProgramming​(ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double> input,
                                              long seed)
      • GrammarBasedGeneticProgramming

        public GrammarBasedGeneticProgramming​(ai.libs.jaicore.basic.IOwnerBasedAlgorithmConfig config,
                                              ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double> input,
                                              long seed)
    • Method Detail

      • nextWithException

        public org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()
                                                                         throws java.lang.InterruptedException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmException
        Throws:
        java.lang.InterruptedException
        org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
        org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
        org.api4.java.algorithm.exceptions.AlgorithmException