Package fr.uga.pddl4j.examples.asp
Class ASP
java.lang.Object
fr.uga.pddl4j.planners.AbstractPlanner
fr.uga.pddl4j.examples.asp.ASP
- All Implemented Interfaces:
Planner
,Serializable
,Callable<Integer>
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface fr.uga.pddl4j.planners.Planner
Planner.Name
-
Field Summary
Modifier and TypeFieldDescriptionstatic StateHeuristic.Name
The default value of the HEURISTIC property used for planner configuration.static double
The default value of the WEIGHT_HEURISTIC property used for planner configuration.static String
The HEURISTIC property used for planner configuration.static String
The WEIGHT_HEURISTIC property used for planner configuration.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
ConstructorDescriptionASP()
Creates a new A* search planner with the default configuration.ASP(PlannerConfiguration configuration)
Creates a new A* search planner with a specified configuration. -
Method Summary
Modifier and TypeMethodDescriptionSearch a solution plan for a planning problem using an A* search strategy.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.boolean
Checks the planner configuration and returns if the configuration is valid.instantiate(DefaultParsedProblem problem)
Instantiates the planning problem from a parsed problem.boolean
isSupported(Problem problem)
Returns if a specified problem is supported by the planner.static void
The main method of theASP
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.Search a solution plan to a specified domain and problem using A*.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, throwInvalidConfigurationException
-
Field Details
-
HEURISTIC_SETTING
The HEURISTIC property used for planner configuration.- See Also:
- Constant Field Values
-
DEFAULT_HEURISTIC
The default value of the HEURISTIC property used for planner configuration. -
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_HEURISTICThe 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
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
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.
-
instantiate
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
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 interfacePlanner
- Overrides:
hasValidConfiguration
in classAbstractPlanner
- Returns:
true
if the configuration is validfalse
otherwise.
-
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.
-
main
The main method of theASP
planner.- Parameters:
args
- the arguments of the command line.
-
astar
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
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 supportedfalse
otherwise.
-