Class AbstractStateSpaceSearch

java.lang.Object
fr.uga.pddl4j.planners.statespace.search.AbstractStateSpaceSearch
All Implemented Interfaces:
SearchStrategy, StateSpaceSearch, Serializable
Direct Known Subclasses:
AStar, BreadthFirstSearch, DepthFirstSearch, EnforcedHillClimbing, GreedyBestFirstSearch, HillClimbing

public abstract class AbstractStateSpaceSearch extends Object implements StateSpaceSearch
This abstract class defines the main methods for search strategies.
Since:
3.6
See Also:
Serialized Form
  • Constructor Details

    • AbstractStateSpaceSearch

      public AbstractStateSpaceSearch()
      Create a new search strategy.
    • AbstractStateSpaceSearch

      public AbstractStateSpaceSearch(int timeout)
      Create a new search strategy.
      Parameters:
      timeout - the time out of the planner in seconds.
    • AbstractStateSpaceSearch

      public AbstractStateSpaceSearch(int timeout, StateHeuristic.Name heuristic, double weight)
      Create a new search strategy.
      Parameters:
      timeout - the time out of the planner in seconds.
      heuristic - the heuristicType to use to solve the planning problem.
      weight - the weight set to the heuristic.
  • Method Details

    • getHeuristic

      public final StateHeuristic.Name getHeuristic()
      Returns the heuristic to use to solve the planning problem.
      Specified by:
      getHeuristic in interface StateSpaceSearch
      Returns:
      the heuristic to use to solve the planning problem.
    • setHeuristic

      public final void setHeuristic(StateHeuristic.Name heuristic)
      Sets the heuristic to use to solved the problem.
      Specified by:
      setHeuristic in interface StateSpaceSearch
      Parameters:
      heuristic - the heuristic to use to solved the problem. The heuristic cannot be null.
    • getWeight

      public final double getWeight()
      Returns the weight set to the heuristic.
      Specified by:
      getWeight in interface StateSpaceSearch
      Returns:
      the weight set to the heuristic.
    • setWeight

      public final void setWeight(double weight)
      Sets the wight of the heuristic.
      Specified by:
      setWeight in interface StateSpaceSearch
      Parameters:
      weight - the weight of the heuristic. The weight must be positive.
    • setTimeOut

      public final void setTimeOut(int timeout)
      Sets the time out of the planner in second.
      Specified by:
      setTimeOut in interface StateSpaceSearch
      Parameters:
      timeout - the time allocated to the search in second. Timeout must be positive.
    • getTimeout

      public int getTimeout()
      Returns the time out of the planner in second.
      Specified by:
      getTimeout in interface StateSpaceSearch
      Returns:
      the time out of the planner, i.e., the time allocated to the search in second.
    • getSearchingTime

      public long getSearchingTime()
      Returns the time spend to find a solution.
      Specified by:
      getSearchingTime in interface StateSpaceSearch
      Returns:
      the time spend to find a solution.
    • setSearchingTime

      public void setSearchingTime(long searchingTime)
      Sets the time out of the planner.
      Specified by:
      setSearchingTime in interface StateSpaceSearch
      Parameters:
      searchingTime - the time allocated to the search in second. Timeout mus be positive.
    • getMemoryUsed

      public long getMemoryUsed()
      Returns the amount of memory used for the search.
      Specified by:
      getMemoryUsed in interface StateSpaceSearch
      Returns:
      the amount of memory used for the search.
    • setMemoryUsed

      public void setMemoryUsed(long memoryUsed)
      Sets the amount of memory used for the search.
      Specified by:
      setMemoryUsed in interface StateSpaceSearch
      Parameters:
      memoryUsed - the amount of memory used for the search.
    • getExploredNodes

      public int getExploredNodes()
      Returns the number of explored nodes.
      Specified by:
      getExploredNodes in interface StateSpaceSearch
      Returns:
      the number of explored nodes.
    • setExploredNodes

      public void setExploredNodes(int exploredNodes)
      Sets the number of explored nodes.
      Specified by:
      setExploredNodes in interface StateSpaceSearch
      Parameters:
      exploredNodes - the number of explored nodes.
    • getPendingNodes

      public int getPendingNodes()
      Returns the number of pending nodes.
      Specified by:
      getPendingNodes in interface StateSpaceSearch
      Returns:
      the number of pending nodes.
    • setPendingNodes

      public void setPendingNodes(int pendingNodes)
      Sets the number of pending nodes.
      Specified by:
      setPendingNodes in interface StateSpaceSearch
      Parameters:
      pendingNodes - the number of pending nodes.
    • getCreatedNodes

      public int getCreatedNodes()
      Returns the number of created nodes.
      Specified by:
      getCreatedNodes in interface StateSpaceSearch
      Returns:
      the number of created nodes.
    • setCreatedNodes

      public void setCreatedNodes(int createdNodes)
      Sets the number of created nodes.
      Specified by:
      setCreatedNodes in interface StateSpaceSearch
      Parameters:
      createdNodes - the number of created nodes.
    • searchSolutionNode

      public Node searchSolutionNode(Problem codedProblem)
      Search a solution node to a specified domain and problem.
      Specified by:
      searchSolutionNode in interface StateSpaceSearch
      Parameters:
      codedProblem - the problem to be solved. The problem cannot be null.
      Returns:
      the solution node or null.
    • searchPlan

      public Plan searchPlan(Problem codedProblem)
      Search a solution plan to a specified domain and problem.
      Specified by:
      searchPlan in interface StateSpaceSearch
      Parameters:
      codedProblem - the problem to be solved. The problem cannot be null.
      Returns:
      the solution plan or null.
    • extractPlan

      public SequentialPlan extractPlan(Node node, Problem problem)
      Extract a plan from a solution node for the specified planning problem.
      Specified by:
      extractPlan in interface StateSpaceSearch
      Parameters:
      node - the solution node.
      problem - the problem to be solved.
      Returns:
      the solution plan or null is no solution was found.
    • resetNodesStatistics

      protected void resetNodesStatistics()
      Reset Nodes statistics.