Package fr.uga.pddl4j.planners
Class AbstractPlanner
java.lang.Object
fr.uga.pddl4j.planners.AbstractPlanner
- All Implemented Interfaces:
Planner
,Serializable
,Callable<Integer>
- Direct Known Subclasses:
AbstractHTNPlanner
,AbstractStateSpacePlanner
,ASP
This abstract class defines the main methods to access a planner.
- Since:
- 3.0
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface fr.uga.pddl4j.planners.Planner
Planner.Name
-
Field Summary
Fields inherited from interface fr.uga.pddl4j.planners.Planner
DEFAULT_DOMAIN, DEFAULT_LOG_LEVEL, DEFAULT_PROBLEM, DEFAULT_TIME_OUT, DOMAIN_SETTING, LOG_LEVEL_SETTING, PROBLEM_SETTING, TIME_OUT_SETTING
-
Constructor Summary
ConstructorDescriptionCreates a new planner.AbstractPlanner(PlannerConfiguration configuration)
Creates a new planner with a specific configuration. -
Method Summary
Modifier and TypeMethodDescriptioncall()
This method contains the code called by the main method of the planner when planner are launched from command line.Returns the configuration of the planner.Returns the path to the PDDL domain file.Returns the domain file containing the PDDL domain description.Returns the log of the planner.protected Parser
Returns the parser used by the planner to parse PDDL domain and problem files.Returns the parser error manager to get the messages generated while parsing.Returns the path to the PDDL problem description.Returns the problem file containing the PDDL problem description.Returns the statistics of the planner.int
Returns the timeout of the planner.boolean
Checks the planner configuration and returns if the configuration is valid.parse()
Parses the domain and the problem description using the configuration of the planner.Parses the domain and the problem description from the specified parameters.void
setConfiguration(PlannerConfiguration configuration)
Sets the configuration of the planner.void
Sets the domain of the planner.void
setLogLevel(LogLevel log)
Sets the log level of the planner.void
setProblem(String problem)
Sets the path to the PDDL problem description.void
setTimeout(int timeout)
Sets the timeout of the planner.solve()
Solves the problem as defined by the planner configuration.protected void
Throws aInvalidPlannerConfigurationException
with the appropriated message or do nothing if the planner has a valid configuration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface fr.uga.pddl4j.planners.Planner
instantiate, isSupported, solve
-
Constructor Details
-
AbstractPlanner
public AbstractPlanner()Creates a new planner. -
AbstractPlanner
Creates a new planner with a specific configuration.- Parameters:
configuration
- the configuration of the planner.
-
-
Method Details
-
setDomain
Sets the domain of the planner. -
getDomain
Returns the path to the PDDL domain file. -
getDomainFile
Returns the domain file containing the PDDL domain description.- Specified by:
getDomainFile
in interfacePlanner
- Returns:
- the domain file containing the PDDL domain description or null if the domain is not initialized.
-
setProblem
Sets the path to the PDDL problem description.- Specified by:
setProblem
in interfacePlanner
- Parameters:
problem
- the path to the PDDL problem description.
-
getProblem
Returns the path to the PDDL problem description.- Specified by:
getProblem
in interfacePlanner
- Returns:
- the path to the PDDL problem description or null if the problem is not initialized.
-
getProblemFile
Returns the problem file containing the PDDL problem description.- Specified by:
getProblemFile
in interfacePlanner
- Returns:
- the problem file containing the PDDL problem description or null if the problem is not initialized.
-
setLogLevel
Sets the log level of the planner.- Specified by:
setLogLevel
in interfacePlanner
- Parameters:
log
- the log of the planner.- See Also:
Level
-
getLogLevel
Returns the log of the planner.- Specified by:
getLogLevel
in interfacePlanner
- 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 interfacePlanner
- 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 interfacePlanner
- Returns:
- the timeout of the planner
-
parse
Parses the domain and the problem description from the specified parameters.- Specified by:
parse
in interfacePlanner
- 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
Parses the domain and the problem description using the configuration of the planner.- Specified by:
parse
in interfacePlanner
- Returns:
- the problem parsed.
- Throws:
FileNotFoundException
- if the domain or the problem file was not found.IOException
- if an error occur during parsing.
-
getParserErrorManager
Description copied from interface:Planner
Returns the parser error manager to get the messages generated while parsing.- Specified by:
getParserErrorManager
in interfacePlanner
- 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 interfacePlanner
- Returns:
true
if the configuration is validfalse
otherwise.
-
throwInvalidConfigurationException
Throws aInvalidPlannerConfigurationException
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
Returns the configuration of the planner.- Specified by:
getConfiguration
in interfacePlanner
- Returns:
- the configuration of the planner.
-
setConfiguration
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 interfacePlanner
- Parameters:
configuration
- the configuration to set.
-
getParser
Returns the parser used by the planner to parse PDDL domain and problem files.- Returns:
- the parser used by the planner.
-
getStatistics
Returns the statistics of the planner.- Specified by:
getStatistics
in interfacePlanner
- Returns:
- the statistics of the planner or null if no problem was solved.
- See Also:
Statistics
-
solve
Solves the problem as defined by the planner configuration.- Specified by:
solve
in interfacePlanner
- Returns:
- the solution plan found or null is no solution was found.
- Throws:
InvalidConfigurationException
- if the planner configuration is invalid.
-
call
This method contains the code called by the main method of the planner when planner are launched from command line.
-