-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
151 lines (96 loc) · 3.65 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
Graph Search Algorithms
=======================
A small collection of graph-search algorithms and analysis.
These code-block are intended to be self-contained single-script program. They
will get merged and productionized into a single planner core, for the
plan2vec paper.
Constructing and Visualizing the State Graph
--------------------------------------------
use a grid-graph.
.. _graph-search-algorithms-1:
Graph Search Algorithms
-----------------------
- *breath first*: use path_length and push order as priority.
- *heuristic*: use D(next, goal) as priority.
- *dijkstra*: use path_length as priority.
- \*a**: use d(path) + D(next, goal) as priority.
This is reflected in the implementation in
`https://github.com/geyang/graph_search/blob/master/graph_search <https://github.com/geyang/graph_search/blob/master/graph_search/__init__.py>`__.
.. raw:: html
<p align="center">
.. raw:: html
</p>
Prioritized Search and Heuristics
---------------------------------
A planning heuristic helps reduce the planning expenditure. The left
column are breath-first-search and dijkstra, both do not use a planning
heuristic. On the right are heuristic search and A*.
The blue colored dots represent the nodes the search algorithm has
“touched”. Heuristics help reduce the cost during planning.
.. raw:: html
<p align="center">
.. raw:: html
</p>
To visualize which node has been touched, we use the code-block in
`analysis.py <https://github.com/geyang/graph_search/blob/master/graph_search/analysis.py>`__. Because the heuristics is
L2 whereas the planning distance is L1, we have to scale it up to get
this result.
+------------+--------------------------------------+
| method | priority |
+============+======================================+
| dijkstra’s | ``D(next)``, the length to the node |
+------------+--------------------------------------+
| A\* | ``D(next) + H(next, goal) * scale``. |
+------------+--------------------------------------+
..
Note: in order for A\* to find the shortest path, the heuristics need
to be “admissible”. Otherwise there is no guarantee. Here our scaling
factor breaks this assumption.
Maze Environment Planning Result
--------------------------------
Now we can compare the planning cost between these algorithms on the
maze environment. We use a simple Euclidean distance as our heuristics
(axis ticks in cm).
.. raw:: html
<p align="center">
.. raw:: html
</p>
We can compare the number of distance look-ups that are required among
these methods:
.. raw:: html
<p align="center">
.. raw:: html
</p>
With a learned reacheability heuristics, ``plan2vec`` should do better
than ``A*`` with a Euclidean heuristic.
(The planning lenght is not computed using the weights)
StreetLearn Environment Planning Result
---------------------------------------
We can now apply this to the StreetLearn domain. I found using an L1
metric for the heuristic and a scaling factor of 1.2 works well. When
using an L2 heuristic the scaling need to be 1.7, and the search cost is
high.
L1 works better probably because it is Manhattan.
.. raw:: html
<p align="center">
.. raw:: html
</p>
We can compare the number of distance look-ups that are required among
these methods:
.. raw:: html
<p align="center">
.. raw:: html
</p>
With a learned reacheability heuristics, ``plan2vec`` should do better
than ``A*`` with a Euclidean heuristic.
(The planning lenght is not computed using the weights)
TODOs
-----
- [ ]
- [ ]
Graph Interface
---------------
We need three methods:
- ``get_edge_data(node, node_2)``
- ``neighbors(node)``
- ``heuristics(next, goal)``