Class Progress<A extends Action>

java.lang.Object
edu.uky.cs.nil.sabre.search.Progress<A>
Type Parameters:
A - the type of action used in plans produced by the search this progress represents

public class Progress<A extends Action> extends Object
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 Details

    • Progress

      public Progress(Search<A> search)
      Constructs a new progress object for a given search.
      Parameters:
      search - the search whose progress is being tracked
  • 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 as the number of nodes visited or amount of time allowed.
      Returns:
      true if the search is finished, false otherwise
    • getSolution

      public Solution<A> getSolution()
      Returns the best solution reported to setSolution(Solution, Number) so far or null if no solutions have been reported. If isDone() is still reporting false, the solution returned by this method will be null or will not meet or exceed the search's goal for author utility.
      Returns:
      the best solution reported so far, or null if none have been reported
    • setSolution

      public void setSolution(Solution<A> solution, Number utility)
      This method is called from this progress's search each time a plan which improves author's utility above the search's initial state is 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 above the goal. If the plan meets or exceeds the goal, isDone() will begin reporting true after that solution is reported and getMessage() will indicate success.
      Parameters:
      solution - any potential solution that improves the author's utility, even if it does not meet or exceed the goal
      utility - the author utility achieved by the solution
    • getUtility

      public Number getUtility()
      Returns the author utility achieved by the best solution reported to setSolution(Solution, Number) so far or null if no solutions have been reported. If isDone() is still reporting false, the utility returned by this method will be null or will not meet or exceed the search's goal.
      Returns:
      the author utility achieved by the best solution reported so far, or null if none have been reported
    • getMessage

      public String getMessage()
      Returns a brief message that explains the final result of the search. If the search ended because the search limit, space limit, or time limit was exceeded, the message will say so. If a solution that achieves the Search.getGoal() was reported, the message will indicate success. If a solution was reported that improves author utility but 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 of nodes visited during this search. In contrast, Search.getVisited() reports the total number of nodes visited during all searches since the last time the search was reset.
      Returns:
      the number of nodes visited during the search which uses this problem object
    • getGenerated

      public long getGenerated()
      Returns the number of nodes generated during this search. In contrast, Search.getGenerated() reports the total number of nodes generated during all searches since the last time the search 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 during this search.
      Returns:
      the number of milliseconds elapsed