Class ASP

All Implemented Interfaces:
Planner, Serializable, Callable<Integer>

public class ASP extends AbstractPlanner
The class is an example. It shows how to create a simple A* search planner able to solve an ADL problem by choosing the heuristic to used and its weight.
See Also:
Serialized Form
  • Field Details

    • HEURISTIC_SETTING

      public static final String HEURISTIC_SETTING
      The HEURISTIC property used for planner configuration.
      See Also:
      Constant Field Values
    • DEFAULT_HEURISTIC

      public static final StateHeuristic.Name DEFAULT_HEURISTIC
      The default value of the HEURISTIC property used for planner configuration.
    • WEIGHT_HEURISTIC_SETTING

      public static final String WEIGHT_HEURISTIC_SETTING
      The WEIGHT_HEURISTIC property used for planner configuration.
      See Also:
      Constant Field Values
    • DEFAULT_WEIGHT_HEURISTIC

      public static final double DEFAULT_WEIGHT_HEURISTIC
      The default value of the WEIGHT_HEURISTIC property used for planner configuration.
      See Also:
      Constant Field Values
  • Constructor Details

    • ASP

      public ASP()
      Creates a new A* search planner with the default configuration.
    • ASP

      public ASP(PlannerConfiguration configuration)
      Creates a new A* search planner with a specified configuration.
      Parameters:
      configuration - the configuration of the planner.
  • Method Details

    • 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.
    • instantiate

      public Problem instantiate(DefaultParsedProblem problem)
      Instantiates the planning problem from a parsed problem.
      Parameters:
      problem - the problem to instantiate.
      Returns:
      the instantiated planning problem or null if the problem cannot be instantiated.
    • solve

      public Plan solve(Problem problem)
      Search a solution plan to a specified domain and problem using A*.
      Parameters:
      problem - the problem to solve.
      Returns:
      the plan found or null if no plan was found.
    • 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 and (4) the heuristic is a not null.
      Specified by:
      hasValidConfiguration in interface Planner
      Overrides:
      hasValidConfiguration in class AbstractPlanner
      Returns:
      true if the configuration is valid false otherwise.
    • 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.
    • main

      public static void main(String[] args)
      The main method of the ASP planner.
      Parameters:
      args - the arguments of the command line.
    • astar

      public Plan astar(Problem problem) throws ProblemNotSupportedException
      Search a solution plan for a planning problem using an A* search strategy.
      Parameters:
      problem - the problem to solve.
      Returns:
      a plan solution for the problem or null if there is no solution
      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. Just ADL problem can be solved by this planner.
      Parameters:
      problem - the problem to test.
      Returns:
      true if the problem is supported false otherwise.