Class RandomSearch<N,A>
- java.lang.Object
-
- ai.libs.jaicore.basic.algorithm.AAlgorithm<I,O>
-
- ai.libs.jaicore.basic.algorithm.ASolutionCandidateIterator<I,O>
-
- ai.libs.jaicore.search.core.interfaces.AAnyPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,A>,SearchGraphPath<N,A>,N,A>
-
- ai.libs.jaicore.search.algorithms.standard.random.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
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 voidappendPathToNode(org.api4.java.datastructure.graph.ILabeledPath<N,A> path)ai.libs.jaicore.graph.Graph<N>getExploredGraph()java.lang.StringgetLoggerName()booleanisExhausted()booleanknowsNode(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.IAlgorithmEventnextWithException()voidsetLoggerName(java.lang.String name)-
Methods inherited from class ai.libs.jaicore.search.core.interfaces.AAnyPathInORGraphSearch
getGraphGenerator, registerSolution
-
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, getId, getInput, getListeners, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasNext, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, 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
-
-
-
-
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)
-
-
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:
nextWithExceptionin interfaceorg.api4.java.algorithm.IAlgorithm<N,A>- Throws:
java.lang.InterruptedExceptionorg.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledExceptionorg.api4.java.algorithm.exceptions.AlgorithmTimeoutedExceptionorg.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.InterruptedExceptionorg.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledExceptionorg.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:
setLoggerNamein interfaceorg.api4.java.common.control.ILoggingCustomizable- Overrides:
setLoggerNamein classAAnyPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,A>,SearchGraphPath<N,A>,N,A>
-
getLoggerName
public java.lang.String getLoggerName()
- Specified by:
getLoggerNamein interfaceorg.api4.java.common.control.ILoggingCustomizable- Overrides:
getLoggerNamein classAAnyPathInORGraphSearch<org.api4.java.ai.graphsearch.problem.IPathSearchInput<N,A>,SearchGraphPath<N,A>,N,A>
-
-