Class PlanGraph
plan graph is a data structure that compresses the state space of a planning problem into something that represents possible future states. It is a directed, leveled graph with two kinds of nodes:
A LiteralNode
represents a fact:
- A literal node exists at level 0 iff it is true in the initial state.
- A literal node exists at level n > 0 if it exists at level n.
- A literal node exists at level n > 0 if there exists a step node a level n - 1 which has that literal as an effect.
A StepNode
represents a step:
- No step nodes exist at level 0.
- A step node exists at level n > 0 if all its preconditions appear at level n - 1.
Node that a plan graph must be initialized
to some state before it can be used. This method resets the plan graph
and determines which literals are true at level 0.
In order to save a significant amount of memory, there is only 1 object
for each literal node and each step node (rather than 1 per level at which
that literal or step appears). A node
is simply marked with
the earliest level at which it appears, since it will continue to appear
at all future levels. If a literal or step has not appeared yet, it's
level is set to -1 and it is said not to exist (even though it still resides
in memory for possible later use).
Note that a plan graph can be built with or without persistence steps and with or without mutexes.
Note that this implementation only computes static mutexes (ones that must always exist). It does not compute mytexes for competing needs or inconsistent support.
- Author:
- Stephen G. Ware
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Iterable<LiteralNode>
The literal nodes for the problem's goalsprotected final LinkedHashMap<Literal,
LiteralNode> A mapping of literal objects to their corresponding nodesfinal StateSpaceProblem
The planning problem represented by this plan graphprotected final LinkedHashMap<Step,
StepNode> A mapping of step objects to their corresponding nodes -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a plan graph using all possible steps that could occur as the step nodes.PlanGraph
(StateSpaceProblem problem, boolean persistence, boolean mutexes) Constructs a new plan graph usingall possible steps
for step nodes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
extend()
Adds one new level to the graph.Returns a literal object's node in this graph.Returns a step object's node in this graph.getLevel
(int number) Returns alevel
object for the level of the given index.boolean
Tests whether all the problem's goal literals exist at the highest level of the graph.boolean
Tests whether or not the graph has leveled off (meaning that no new literals or steps will appear if a new level is added).void
initialize
(State initial) Resets the graph to have only level 0, which will include exactly those literals which are true in the given state.int
size()
Returns the number of levels in this graph.toString()
-
Field Details
-
problem
The planning problem represented by this plan graph -
goals
The literal nodes for the problem's goals -
literalMap
A mapping of literal objects to their corresponding nodes -
stepMap
A mapping of step objects to their corresponding nodes
-
-
Constructor Details
-
PlanGraph
Constructs a new plan graph usingall possible steps
for step nodes.- Parameters:
problem
- the problem whose steps should be used as step nodespersistence
- whether or not persistence steps should be generatedmutexes
- whether or not mutexes should be calculated
-
PlanGraph
Constructs a plan graph using all possible steps that could occur as the step nodes.- Parameters:
problem
- the problempersistence
- whether or not persistence steps should be generatedmutexes
- whether or not mutexes should be calculated
-
-
Method Details
-
toString
-
get
Returns a literal object's node in this graph.- Parameters:
literal
- the literal- Returns:
- the literal's corresponding node
-
get
Returns a step object's node in this graph.- Parameters:
step
- the step- Returns:
- the step's corresponding node
-
initialize
Resets the graph to have only level 0, which will include exactly those literals which are true in the given state.- Parameters:
initial
- any state
-
extend
public void extend()Adds one new level to the graph. -
size
public int size()Returns the number of levels in this graph.- Returns:
- the number of levels
-
getLevel
Returns alevel
object for the level of the given index.- Parameters:
number
- the index of the requested level- Returns:
- the level
- Throws:
IndexOutOfBoundsException
- if the requested level does not exist in this graph
-
goalAchieved
public boolean goalAchieved()Tests whether all the problem's goal literals exist at the highest level of the graph.- Returns:
- true if all goals exist, false otherwise
-
hasLeveledOff
public boolean hasLeveledOff()Tests whether or not the graph has leveled off (meaning that no new literals or steps will appear if a new level is added).- Returns:
- true if the graph has leveled off, false otherwise
-