Class Progress<A extends Action>
java.lang.Object
edu.uky.cs.nil.sabre.search.Progress<A>
- Type Parameters:
A- the type ofactionused in plans produced by the search this progress represents
A progress object provides a convenient way to track whether a
search has finished, its result, how many nodes it has visited and
generated, and how much time has elapsed. A new progress object should be
created for each call to Search.get(edu.uky.cs.nil.sabre.util.Worker.Status). While the search is
running, it should periodically call isDone() to check whether the
search has finished. Every time the search finds a plan which improves the
author's utility over the
search's initial state, it should report that
potential solution to this progress object via
setSolution(Solution, Number). This progress object will only report
that the search is done if the solution meets or exceeds
the search's goal, otherwise, it will track the
best solution found so far. If the search finishes without finding a
solution (perhaps because it exceeded a node or time limit), the best
solution found will be reported, even if it does not meet or exceed the
goal.- Author:
- Stephen G. Ware
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the number ofnodes generatedduringthis search.Returns a brief message that explains the final result of thesearch.Returns the best solution reported tosetSolution(Solution, Number)so far or null if no solutions have been reported.longgetTime()Returns the number of milliseconds elapsed duringthis search.Returns theauthor utilityachieved by the best solution reported tosetSolution(Solution, Number)so far or null if no solutions have been reported.longReturns the number ofnodes visitedduringthis search.booleanisDone()Checks whether a search is finished, either because a solution was found or because the search exceeded some limit, such asthe number of nodes visitedoramount of time allowed.voidsetSolution(Solution<A> solution, Number utility) This method is called fromthis progress's searcheach time a plan which improvesauthor's utilityabove thesearch's initial stateis found.
-
Constructor Details
-
Progress
-
-
Method Details
-
isDone
public boolean isDone()Checks whether a search is finished, either because a solution was found or because the search exceeded some limit, such asthe number of nodes visitedoramount of time allowed.- Returns:
- true if the search is finished, false otherwise
-
getSolution
Returns the best solution reported tosetSolution(Solution, Number)so far or null if no solutions have been reported. IfisDone()is still reporting false, the solution returned by this method will be null or will not meet or exceedthe search's goalforauthor utility.- Returns:
- the best solution reported so far, or null if none have been reported
-
setSolution
This method is called fromthis progress's searcheach time a plan which improvesauthor's utilityabove thesearch's initial stateis found. The utility reported should be the author's utility in the state immediately after the solution plan has been executed in the search's initial state. All plans which improve author utility should be reported, even if they do not improve author utility up to or abovethe goal. If the plan meets or exceeds the goal,isDone()will begin reporting true after that solution is reported andgetMessage()will indicate success.- Parameters:
solution- any potential solution that improves the author's utility, even if it does not meet or exceed the goalutility- the author utility achieved by the solution
-
getUtility
Returns theauthor utilityachieved by the best solution reported tosetSolution(Solution, Number)so far or null if no solutions have been reported. IfisDone()is still reporting false, the utility returned by this method will be null or will not meet or exceedthe search's goal.- Returns:
- the author utility achieved by the best solution reported so far, or null if none have been reported
-
getMessage
Returns a brief message that explains the final result of thesearch. If the search ended because thesearch limit,space limit, ortime limitwas exceeded, the message will say so. If a solution that achieves theSearch.getGoal()wasreported, the message will indicate success. If a solution was reported that improvesauthor utilitybut not enough to meet or exceed the goal, the message will indicate that a suboptimal solution was found. Otherwise, the message will indicate that no solution exists.- Returns:
- a brief message explaining the results of the search
-
getVisited
public long getVisited()Returns the number ofnodes visitedduringthis search. In contrast,Search.getVisited()reports the total number of nodes visited during all searches since the last time thesearch was reset.- Returns:
- the number of nodes visited during the search which uses this problem object
-
getGenerated
public long getGenerated()Returns the number ofnodes generatedduringthis search. In contrast,Search.getGenerated()reports the total number of nodes generated during all searches since the last time thesearch was reset.- Returns:
- the number of nodes generated during the search which uses this problem object
-
getTime
public long getTime()Returns the number of milliseconds elapsed duringthis search.- Returns:
- the number of milliseconds elapsed
-