Class RandomSearch<N,​A>

  • Type Parameters:
    N -
    A -
    All Implemented Interfaces:
    java.lang.Iterable<org.api4.java.algorithm.events.IAlgorithmEvent>, java.util.concurrent.Callable<SearchGraphPath<N,​A>>, java.util.Iterator<org.api4.java.algorithm.events.IAlgorithmEvent>, org.api4.java.ai.graphsearch.problem.IPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>,​N,​A>, org.api4.java.ai.graphsearch.problem.IPathSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>,​N,​A>, org.api4.java.algorithm.IAlgorithm<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>>, org.api4.java.algorithm.ISolutionCandidateIterator<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>>, 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 RandomSearch<N,​A>
    extends AAnyPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>,​N,​A>
    implements org.api4.java.common.control.ILoggingCustomizable
    This search randomly draws paths from the root. At every node, each successor is chosen with the same probability except if a priority predicate is defined. A priority predicate says whether or not a node lies on a path that has priority. A node only has priority until all successors that have priority are exhausted.
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem)  
      RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem, int seed)  
      RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem, java.util.function.Predicate<N> priorityPredicate, java.util.Random random)  
      RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem, java.util.Random random)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendPathToNode​(org.api4.java.datastructure.graph.ILabeledPath<N,​A> path)  
      ai.libs.jaicore.graph.Graph<N> getExploredGraph()  
      int getIterations()  
      java.lang.String getLoggerName()  
      java.util.Random getRandom()  
      boolean isExhausted()  
      boolean knowsNode​(N node)  
      SearchGraphPath<N,​A> nextSolutionUnderSubPath​(org.api4.java.datastructure.graph.ILabeledPath<N,​A> path)
      Returns a completion of the given path so that the whole path is a goal path.
      org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()  
      void setIterations​(int iterations)  
      void setLoggerName​(java.lang.String name)  
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.ASolutionCandidateIterator

        call, collectAllSolutions, nextSolutionCandidate, nextSolutionCandidateEvent
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.AAlgorithm

        activate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, cancel, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getConfig, 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

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

        cancel
      • Methods inherited from interface org.api4.java.algorithm.ISolutionCandidateIterator

        nextSolutionCandidate, nextSolutionCandidateEvent
      • Methods inherited from interface java.lang.Iterable

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

        forEachRemaining, hasNext, next, remove
    • Constructor Detail

      • RandomSearch

        public RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem)
      • RandomSearch

        public RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem,
                            int seed)
      • RandomSearch

        public RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem,
                            java.util.Random random)
      • RandomSearch

        public RandomSearch​(org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A> problem,
                            java.util.function.Predicate<N> priorityPredicate,
                            java.util.Random random)
    • 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
        Specified by:
        nextWithException in interface org.api4.java.algorithm.IAlgorithm<N,​A>
        Throws:
        java.lang.InterruptedException
        org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
        org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
        org.api4.java.algorithm.exceptions.AlgorithmException
      • knowsNode

        public boolean knowsNode​(N node)
      • appendPathToNode

        public void appendPathToNode​(org.api4.java.datastructure.graph.ILabeledPath<N,​A> path)
      • nextSolutionUnderSubPath

        public SearchGraphPath<N,​A> nextSolutionUnderSubPath​(org.api4.java.datastructure.graph.ILabeledPath<N,​A> path)
                                                            throws java.lang.InterruptedException,
                                                                   org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException,
                                                                   org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
        Returns a completion of the given path so that the whole path is a goal path. The given path is then a prefix of the returned path.
        Parameters:
        path -
        Returns:
        Throws:
        java.lang.InterruptedException
        org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
        org.api4.java.algorithm.exceptions.AlgorithmTimeoutedException
      • isExhausted

        public boolean isExhausted()
      • getExploredGraph

        public ai.libs.jaicore.graph.Graph<N> getExploredGraph()
      • setLoggerName

        public void setLoggerName​(java.lang.String name)
        Specified by:
        setLoggerName in interface org.api4.java.common.control.ILoggingCustomizable
        Overrides:
        setLoggerName in class AAnyPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>,​N,​A>
      • getLoggerName

        public java.lang.String getLoggerName()
        Specified by:
        getLoggerName in interface org.api4.java.common.control.ILoggingCustomizable
        Overrides:
        getLoggerName in class AAnyPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,​A>,​SearchGraphPath<N,​A>,​N,​A>
      • getRandom

        public java.util.Random getRandom()
      • getIterations

        public int getIterations()
      • setIterations

        public void setIterations​(int iterations)