Class AbstractStateSpacePlanner
java.lang.Object
fr.uga.pddl4j.planners.AbstractPlanner
fr.uga.pddl4j.planners.statespace.AbstractStateSpacePlanner
- All Implemented Interfaces:
Planner
,StateSpacePlanner
,Serializable
,Callable<Integer>
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
-
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
Fields inherited from interface fr.uga.pddl4j.planners.statespace.StateSpacePlanner
DEFAULT_HEURISTIC, DEFAULT_SEARCH_STRATEGIES, DEFAULT_WEIGHT_HEURISTIC, HEURISTIC_SETTING, SEARCH_STRATEGIES_SETTING, WEIGHT_HEURISTIC_SETTING
-
Constructor Summary
ConstructorDescriptionCreates a new planner.AbstractStateSpacePlanner(PlannerConfiguration configuration)
Creates a new planner with a specific configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSearchStrategy(SearchStrategy.Name strategy)
Adds a search strategy to the planner.Returns the configuration of the planner.static PlannerConfiguration
This method return the default arguments of the planner.Returns the name of the heuristic used by the planner to solve a planning problem.double
Returns the weight of the heuristic.Returns the list of search strategies to used to solve a planning problem.boolean
Checks the planner configuration and returns if the configuration is valid.boolean
isSupported(Problem problem)
Returns if a specified problem is supported by the planner.void
setConfiguration(PlannerConfiguration configuration)
Sets the configuration of the planner.void
setHeuristic(StateHeuristic.Name heuristic)
Set the name of heuristic used by the planner to the solve a planning problem.void
setHeuristicWeight(double weight)
Sets the weight of the heuristic.void
setSearchStrategies(List<SearchStrategy.Name> strategies)
Sets the list of search strategies to used to solve a planning problem.Search a solution plan to a specified domain and problem.protected void
Throws aInvalidPlannerConfigurationException
with the appropriated message or do nothing if the planner has a valid configuration.Methods inherited from class fr.uga.pddl4j.planners.AbstractPlanner
call, getDomain, getDomainFile, getLogLevel, getParser, getParserErrorManager, getProblem, getProblemFile, getStatistics, getTimeout, parse, parse, setDomain, setLogLevel, setProblem, setTimeout, solve
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
getDomain, getDomainFile, getLogLevel, getParserErrorManager, getProblem, getProblemFile, getStatistics, getTimeout, instantiate, parse, parse, setDomain, setLogLevel, setProblem, setTimeout, solve
-
Constructor Details
-
AbstractStateSpacePlanner
public AbstractStateSpacePlanner()Creates a new planner. -
AbstractStateSpacePlanner
Creates a new planner with a specific configuration.- Parameters:
configuration
- the configuration of the planner.
-
-
Method Details
-
setSearchStrategies
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
Adds a search strategy to the planner.- Parameters:
strategy
- the strategy to add.
-
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
Set the name of heuristic used by the planner to the solve a planning problem.- Parameters:
heuristic
- the name of the heuristic.
-
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 interfacePlanner
- Overrides:
hasValidConfiguration
in classAbstractPlanner
- 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.- Overrides:
throwInvalidConfigurationException
in classAbstractPlanner
- Throws:
InvalidConfigurationException
- if the configuration of the planner is not valid.
-
getDefaultConfiguration
This method return the default arguments of the planner.- Returns:
- the default arguments of the planner.
- See Also:
PlannerConfiguration
-
getConfiguration
Returns the configuration of the planner.- Specified by:
getConfiguration
in interfacePlanner
- Overrides:
getConfiguration
in classAbstractPlanner
- 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
- Overrides:
setConfiguration
in classAbstractPlanner
- Parameters:
configuration
- the configuration to set.
-
solve
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 interfacePlanner
- 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
Returns if a specified problem is supported by the planner.- Specified by:
isSupported
in interfacePlanner
- Parameters:
problem
- the problem to test.- Returns:
true
if the problem is supportedfalse
otherwise.
-