In mathematical terminology, total order, linear order or simple order refers to a set X which is said to be totally ordered under ≤ if the following statements hold for all a, b and c in X:
If a ≤ b and b ≤ a, then a = b (antisymmetry).
If a ≤ b and b ≤ c, then a ≤ c (transitivity).
a ≤ b or b ≤ a (connex relation).
In simpler terms, a total order plan is a linear ordering of actions to be taken to reach the goal state.
There may be several different total-order plans for a particular goal depending on the problem.
In the module, the Linearize
class solves problems using this paradigm.
At its core, the Linearize
uses a solved planning graph from GraphPlan
and finds a valid total-order solution for it.
Let's have a look at the class.
In [1]:
from planning import *
from notebook import psource
In [2]:
psource(Linearize)
The filter
method removes the persistence actions (if any) from the planning graph representation.
The orderlevel
method finds a valid total-ordering of a specified level of the planning-graph, given the state of the graph after the previous level.
The execute
method sequentially calls orderlevel
for all the levels in the planning-graph and returns the final total-order solution.
Let's look at some examples.
In [3]:
# total-order solution for air_cargo problem
Linearize(air_cargo()).execute()
Out[3]:
In [4]:
# total-order solution for spare_tire problem
Linearize(spare_tire()).execute()
Out[4]:
In [5]:
# total-order solution for three_block_tower problem
Linearize(three_block_tower()).execute()
Out[5]:
In [6]:
# total-order solution for simple_blocks_world problem
Linearize(simple_blocks_world()).execute()
Out[6]:
In [7]:
# total-order solution for socks_and_shoes problem
Linearize(socks_and_shoes()).execute()
Out[7]: