Class AbstractPlanner

java.lang.Object
fr.uga.pddl4j.planners.AbstractPlanner
All Implemented Interfaces:
Planner, Serializable, Callable<Integer>
Direct Known Subclasses:
AbstractHTNPlanner, AbstractStateSpacePlanner, ASP

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

    • AbstractPlanner

      public AbstractPlanner()
      Creates a new planner.
    • AbstractPlanner

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

    • setDomain

      public final void setDomain(String domain)
      Sets the domain of the planner.
      Specified by:
      setDomain in interface Planner
      Parameters:
      domain - the path to the PDDL domain file.
    • getDomain

      public final String getDomain()
      Returns the path to the PDDL domain file.
      Specified by:
      getDomain in interface Planner
      Returns:
      the path to the PDDL domain file of the configuration or null if the domain is not initialized.
    • getDomainFile

      public final File getDomainFile()
      Returns the domain file containing the PDDL domain description.
      Specified by:
      getDomainFile in interface Planner
      Returns:
      the domain file containing the PDDL domain description or null if the domain is not initialized.
    • setProblem

      public final void setProblem(String problem)
      Sets the path to the PDDL problem description.
      Specified by:
      setProblem in interface Planner
      Parameters:
      problem - the path to the PDDL problem description.
    • getProblem

      public final String getProblem()
      Returns the path to the PDDL problem description.
      Specified by:
      getProblem in interface Planner
      Returns:
      the path to the PDDL problem description or null if the problem is not initialized.
    • getProblemFile

      public final File getProblemFile()
      Returns the problem file containing the PDDL problem description.
      Specified by:
      getProblemFile in interface Planner
      Returns:
      the problem file containing the PDDL problem description or null if the problem is not initialized.
    • setLogLevel

      public final void setLogLevel(LogLevel log)
      Sets the log level of the planner.
      Specified by:
      setLogLevel in interface Planner
      Parameters:
      log - the log of the planner.
      See Also:
      Level
    • getLogLevel

      public final LogLevel getLogLevel()
      Returns the log of the planner.
      Specified by:
      getLogLevel in interface Planner
      Returns:
      the trace level declared of the planner.
      See Also:
      Level
    • setTimeout

      public final void setTimeout(int timeout)
      Sets the timeout of the planner.
      Specified by:
      setTimeout in interface Planner
      Parameters:
      timeout - to use by the planner in second. The timeout must greater than 0.
      Throws:
      IllegalArgumentException - if the timeout is strictly less than 0.
    • getTimeout

      public final int getTimeout()
      Returns the timeout of the planner.
      Specified by:
      getTimeout in interface Planner
      Returns:
      the timeout of the planner
    • parse

      public DefaultParsedProblem parse(String domain, String problem) throws IOException
      Parses the domain and the problem description from the specified parameters.
      Specified by:
      parse in interface Planner
      Parameters:
      domain - the path to the PDDL domain file.
      problem - the path to the PDDL problem file.
      Returns:
      the problem parsed.
      Throws:
      FileNotFoundException - if the domain or the problem file was not found.
      IOException - if an error occur during parsing.
    • parse

      public DefaultParsedProblem parse() throws IOException
      Parses the domain and the problem description using the configuration of the planner.
      Specified by:
      parse in interface Planner
      Returns:
      the problem parsed.
      Throws:
      FileNotFoundException - if the domain or the problem file was not found.
      IOException - if an error occur during parsing.
    • getParserErrorManager

      public ErrorManager getParserErrorManager()
      Description copied from interface: Planner
      Returns the parser error manager to get the messages generated while parsing.
      Specified by:
      getParserErrorManager in interface Planner
      Returns:
      the parser error manger.
    • 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 and (2) the timeout is greater than 0.
      Specified by:
      hasValidConfiguration in interface Planner
      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.
      Throws:
      InvalidConfigurationException - if the configuration of the planner is not valid.
    • getConfiguration

      public PlannerConfiguration getConfiguration()
      Returns the configuration of the planner.
      Specified by:
      getConfiguration in interface Planner
      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
      Parameters:
      configuration - the configuration to set.
    • getParser

      protected Parser getParser()
      Returns the parser used by the planner to parse PDDL domain and problem files.
      Returns:
      the parser used by the planner.
    • getStatistics

      public final Statistics getStatistics()
      Returns the statistics of the planner.
      Specified by:
      getStatistics in interface Planner
      Returns:
      the statistics of the planner or null if no problem was solved.
      See Also:
      Statistics
    • solve

      public Plan solve() throws InvalidConfigurationException
      Solves the problem as defined by the planner configuration.
      Specified by:
      solve in interface Planner
      Returns:
      the solution plan found or null is no solution was found.
      Throws:
      InvalidConfigurationException - if the planner configuration is invalid.
    • call

      public Integer call()
      This method contains the code called by the main method of the planner when planner are launched from command line.
      Specified by:
      call in interface Callable<Integer>
      Returns:
      the exit return value of the planner: O if every thing is ok; 1 if the error due to an invalid configuration of the planner; 2 otherwise.