Class AbstractStateSpacePlanner

java.lang.Object
fr.uga.pddl4j.planners.AbstractPlanner
fr.uga.pddl4j.planners.statespace.AbstractStateSpacePlanner
All Implemented Interfaces:
Planner, StateSpacePlanner, Serializable, Callable<Integer>
Direct Known Subclasses:
FF, GSP, HSP

public abstract class AbstractStateSpacePlanner extends AbstractPlanner implements StateSpacePlanner
This abstract class defines the main methods to access a state based planner.
Since:
3.0
See Also:
Serialized Form
  • Constructor Details

    • AbstractStateSpacePlanner

      public AbstractStateSpacePlanner()
      Creates a new planner.
    • AbstractStateSpacePlanner

      public AbstractStateSpacePlanner(PlannerConfiguration configuration)
      Creates a new planner with a specific configuration.
      Parameters:
      configuration - the configuration of the planner.
  • Method Details

    • setSearchStrategies

      public void setSearchStrategies(List<SearchStrategy.Name> strategies)
      Sets the list of search strategies to used to solve a planning problem. The search strategies are tried in the specified order. The search stops when a search strategy succeed.
      Parameters:
      strategies - the list of search strategies to used.
    • addSearchStrategy

      public void addSearchStrategy(SearchStrategy.Name strategy)
      Adds a search strategy to the planner.
      Parameters:
      strategy - the strategy to add.
    • getSearchStrategies

      public final List<SearchStrategy.Name> getSearchStrategies()
      Returns the list of search strategies to used to solve a planning problem.
      Returns:
      the list of search strategies to used to solve a planning problem.
    • setHeuristicWeight

      public void setHeuristicWeight(double weight)
      Sets the weight of the heuristic.
      Parameters:
      weight - the weight of the heuristic. The weight must be greater than 0.
      Throws:
      IllegalArgumentException - if the weight is strictly less than 0.
    • setHeuristic

      public void setHeuristic(StateHeuristic.Name heuristic)
      Set the name of heuristic used by the planner to the solve a planning problem.
      Parameters:
      heuristic - the name of the heuristic.
    • getHeuristic

      public final StateHeuristic.Name getHeuristic()
      Returns the name of the heuristic used by the planner to solve a planning problem.
      Returns:
      the name of the heuristic used by the planner to solve a planning problem.
    • getHeuristicWeight

      public final double getHeuristicWeight()
      Returns the weight of the heuristic.
      Returns:
      the weight of the heuristic.
    • hasValidConfiguration

      public boolean hasValidConfiguration()
      Checks the planner configuration and returns if the configuration is valid. A configuration is valid if (1) the domain and the problem files exist and can be read, (2) the timeout is greater than 0, (3) the weight of the heuristic is greater than 0, (4) the heuristic is a not null and (5) the list of search strategies to use to solve a planning problem is not empty.
      Specified by:
      hasValidConfiguration in interface Planner
      Overrides:
      hasValidConfiguration in class AbstractPlanner
      Returns:
      true if the configuration is valid false otherwise.
    • throwInvalidConfigurationException

      protected void throwInvalidConfigurationException() throws InvalidConfigurationException
      Throws a InvalidPlannerConfigurationException with the appropriated message or do nothing if the planner has a valid configuration.
      Overrides:
      throwInvalidConfigurationException in class AbstractPlanner
      Throws:
      InvalidConfigurationException - if the configuration of the planner is not valid.
    • getDefaultConfiguration

      public static PlannerConfiguration getDefaultConfiguration()
      This method return the default arguments of the planner.
      Returns:
      the default arguments of the planner.
      See Also:
      PlannerConfiguration
    • getConfiguration

      public PlannerConfiguration getConfiguration()
      Returns the configuration of the planner.
      Specified by:
      getConfiguration in interface Planner
      Overrides:
      getConfiguration in class AbstractPlanner
      Returns:
      the configuration of the planner.
    • setConfiguration

      public void setConfiguration(PlannerConfiguration configuration)
      Sets the configuration of the planner. If a planner setting is not defined in the specified configuration, the setting is initialized with its default value.
      Specified by:
      setConfiguration in interface Planner
      Overrides:
      setConfiguration in class AbstractPlanner
      Parameters:
      configuration - the configuration to set.
    • solve

      public Plan solve(Problem problem) throws ProblemNotSupportedException
      Search a solution plan to a specified domain and problem. The method search a solution plan by trying iteratively all the search strategies defined.
      Specified by:
      solve in interface Planner
      Parameters:
      problem - the problem to solve.
      Returns:
      the plan found or null if no plan was found.
      Throws:
      ProblemNotSupportedException - if the problem to solve is not supported by the planner.
    • isSupported

      public boolean isSupported(Problem problem)
      Returns if a specified problem is supported by the planner.
      Specified by:
      isSupported in interface Planner
      Parameters:
      problem - the problem to test.
      Returns:
      true if the problem is supported false otherwise.