Class TimeAwareNodeEvaluator<T,A,V extends java.lang.Comparable<V>>
- java.lang.Object
-
- ai.libs.jaicore.search.algorithms.standard.bestfirst.nodeevaluation.TimeAwareNodeEvaluator<T,A,V>
-
- Type Parameters:
T
-V
-
- All Implemented Interfaces:
org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<T,A,V>
,org.api4.java.common.attributedobjects.IGetter<org.api4.java.datastructure.graph.ILabeledPath<T,A>,V>
,org.api4.java.common.attributedobjects.IObjectEvaluator<org.api4.java.datastructure.graph.ILabeledPath<T,A>,V>
,org.api4.java.common.control.ILoggingCustomizable
- Direct Known Subclasses:
RandomCompletionBasedNodeEvaluator
public abstract class TimeAwareNodeEvaluator<T,A,V extends java.lang.Comparable<V>> extends java.lang.Object implements org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<T,A,V>, org.api4.java.common.control.ILoggingCustomizable
This class can be used to create node evaluators with a time limit for the evaluation of each node. The remaining time for the evaluation of the node is given with the call of f. The thread will be interrupted after the timeout if it has not returned control in time.
-
-
Constructor Summary
Constructors Constructor Description TimeAwareNodeEvaluator(int pTimeoutInMS)
TimeAwareNodeEvaluator(int pTimeoutInMS, org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<T,A,V> pFallbackNodeEvaluator)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkInterruption()
V
evaluate(org.api4.java.datastructure.graph.ILabeledPath<T,A> path)
protected abstract V
evaluateTimeouted(org.api4.java.datastructure.graph.ILabeledPath<T,A> node, int timeoutInMS)
org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<T,A,V>
getFallbackNodeEvaluator()
java.lang.String
getLoggerName()
int
getTimeoutForNodeEvaluationInMS()
long
getTotalDeadline()
void
setLoggerName(java.lang.String name)
void
setTotalDeadline(long totalDeadline)
-
-
-
Method Detail
-
evaluateTimeouted
protected abstract V evaluateTimeouted(org.api4.java.datastructure.graph.ILabeledPath<T,A> node, int timeoutInMS) throws org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.PathEvaluationException, java.lang.InterruptedException
- Throws:
org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.PathEvaluationException
java.lang.InterruptedException
-
evaluate
public final V evaluate(org.api4.java.datastructure.graph.ILabeledPath<T,A> path) throws org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.PathEvaluationException, java.lang.InterruptedException
- Specified by:
evaluate
in interfaceorg.api4.java.common.attributedobjects.IObjectEvaluator<T,A>
- Specified by:
evaluate
in interfaceorg.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<T,A,V extends java.lang.Comparable<V>>
- Throws:
org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.PathEvaluationException
java.lang.InterruptedException
-
getTimeoutForNodeEvaluationInMS
public int getTimeoutForNodeEvaluationInMS()
-
getFallbackNodeEvaluator
public org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<T,A,V> getFallbackNodeEvaluator()
-
getTotalDeadline
public long getTotalDeadline()
-
setTotalDeadline
public void setTotalDeadline(long totalDeadline)
-
checkInterruption
protected void checkInterruption() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
setLoggerName
public void setLoggerName(java.lang.String name)
- Specified by:
setLoggerName
in interfaceorg.api4.java.common.control.ILoggingCustomizable
-
getLoggerName
public java.lang.String getLoggerName()
- Specified by:
getLoggerName
in interfaceorg.api4.java.common.control.ILoggingCustomizable
-
-