Package ai.libs.jaicore.ml.hpo.ggp
Class GrammarBasedGeneticProgramming
- java.lang.Object
-
- ai.libs.jaicore.basic.algorithm.AAlgorithm<I,O>
-
- ai.libs.jaicore.basic.algorithm.ASolutionCandidateIterator<I,O>
-
- ai.libs.jaicore.basic.algorithm.AOptimizer<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,GrammarBasedGeneticProgramming.GGPSolutionCandidate,java.lang.Double>
-
- ai.libs.jaicore.ml.hpo.ggp.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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classGrammarBasedGeneticProgramming.GGPSolutionCandidate
-
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 IGrammarBasedGeneticProgrammingConfiggetConfig()java.util.List<GrammarBasedGeneticProgramming.GGPSolutionCandidate>getLastRatedPopulation()org.api4.java.algorithm.events.IAlgorithmEventnextWithException()-
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
-
-
-
-
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.InterruptedExceptionorg.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledExceptionorg.api4.java.algorithm.exceptions.AlgorithmTimeoutedExceptionorg.api4.java.algorithm.exceptions.AlgorithmException
-
getLastRatedPopulation
public java.util.List<GrammarBasedGeneticProgramming.GGPSolutionCandidate> getLastRatedPopulation()
-
getConfig
public IGrammarBasedGeneticProgrammingConfig getConfig()
- Specified by:
getConfigin interfaceorg.api4.java.algorithm.IAlgorithm<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,GrammarBasedGeneticProgramming.GGPSolutionCandidate>- Overrides:
getConfigin classai.libs.jaicore.basic.algorithm.AAlgorithm<ai.libs.jaicore.components.model.SoftwareConfigurationProblem<java.lang.Double>,GrammarBasedGeneticProgramming.GGPSolutionCandidate>
-
-