@@ -37,22 +37,27 @@ def __get_all_pddl_from_data(self):
3737 return [("data/problem.pddl" , "data/domain.pddl" )]
3838
3939 def __plot_data (self , times , total_nodes , plot_title ):
40- plt .plot (total_nodes , times , "b:o" )
40+ data = dict ()
41+ for i , val in enumerate (total_nodes ):
42+ data [val ] = times [i ]
43+ nodes_sorted = sorted (list (data .keys ()))
44+ times_y = []
45+ for node_opened in nodes_sorted :
46+ times_y .append (data [node_opened ])
47+ plt .plot (nodes_sorted , times_y , "r:o" )
4148 plt .xlabel ("Number of opened nodes" )
4249 plt .ylabel ("Planning computation time" )
50+ plt .xscale ('symlog' )
4351 plt .title (plot_title )
44- plt .xscale ("symlog" )
45- plt .yscale ("log" )
4652 plt .grid (True )
4753 plt .show (block = False )
4854
4955 def __scatter_data (self , times , total_nodes , plot_title ):
5056 plt .scatter (total_nodes , times )
5157 plt .xlabel ("Number of opened nodes" )
5258 plt .ylabel ("Planning computation time" )
59+ plt .xscale ('symlog' )
5360 plt .title (plot_title )
54- plt .xscale ("symlog" )
55- plt .yscale ("log" )
5661 plt .grid (True )
5762 plt .show (block = False )
5863
@@ -61,41 +66,46 @@ def __gather_data_astar(
6166 ):
6267 has_multiple_files_tested = True
6368 if not domain_path or not problem_path :
64- has_multiple_files_tested = False
6569 metrics = dict ()
6670 for problem , domain in self .__get_all_pddl_from_data ():
6771 logging .debug ("Loading new PDDL instance planned with A*..." )
6872 logging .debug ("Domain: " + domain )
6973 logging .debug ("Problem: " + problem )
7074 apla = AutomatedPlanner (domain , problem )
7175 if heuristic_key in apla .available_heuristics :
72- _ , total_time , opened_nodes = apla .astar_best_first_search (
76+ path , total_time , opened_nodes = apla .astar_best_first_search (
7377 heuristic = apla .available_heuristics [heuristic_key ]
7478 )
7579 else :
7680 logging .critical (
7781 "Heuristic is not implemented! (Key not found in registered heuristics dict)"
7882 )
7983 return [0 ], [0 ], has_multiple_files_tested
80- metrics [total_time ] = opened_nodes
84+ if path :
85+ metrics [total_time ] = opened_nodes
86+ else :
87+ metrics [0 ] = 0
8188
8289 total_nodes = list (metrics .values ())
8390 times = list (metrics .keys ())
8491 return times , total_nodes , has_multiple_files_tested
92+ has_multiple_files_tested = False
8593 logging .debug ("Loading new PDDL instance..." )
8694 logging .debug ("Domain: " + domain_path )
8795 logging .debug ("Problem: " + problem_path )
8896 apla = AutomatedPlanner (domain_path , problem_path )
8997 if heuristic_key in apla .available_heuristics :
90- _ , total_time , opened_nodes = apla .astar_best_first_search (
98+ path , total_time , opened_nodes = apla .astar_best_first_search (
9199 heuristic = apla .available_heuristics [heuristic_key ]
92100 )
93101 else :
94102 logging .critical (
95103 "Heuristic is not implemented! (Key not found in registered heuristics dict)"
96104 )
97105 return [0 ], [0 ], has_multiple_files_tested
98- return [total_time ], [opened_nodes ], has_multiple_files_tested
106+ if path :
107+ return [total_time ], [opened_nodes ], has_multiple_files_tested
108+ return [0 ], [0 ], has_multiple_files_tested
99109
100110 def plot_astar_data (self , heuristic_key = "goal_count" , domain = "" , problem = "" ):
101111 if bool (not problem ) != bool (not domain ):
@@ -115,25 +125,30 @@ def plot_astar_data(self, heuristic_key="goal_count", domain="", problem=""):
115125 def __gather_data_bfs (self , domain_path = "" , problem_path = "" ):
116126 has_multiple_files_tested = True
117127 if not domain_path or not problem_path :
118- has_multiple_files_tested = False
119128 metrics = dict ()
120129 for problem , domain in self .__get_all_pddl_from_data ():
121130 logging .debug ("Loading new PDDL instance planned with BFS..." )
122131 logging .debug ("Domain: " + domain )
123132 logging .debug ("Problem: " + problem )
124133 apla = AutomatedPlanner (domain , problem )
125- _ , total_time , opened_nodes = apla .breadth_first_search ()
126- metrics [total_time ] = opened_nodes
134+ path , total_time , opened_nodes = apla .breadth_first_search ()
135+ if path :
136+ metrics [total_time ] = opened_nodes
137+ else :
138+ metrics [0 ] = 0
127139
128140 total_nodes = list (metrics .values ())
129141 times = list (metrics .keys ())
130142 return times , total_nodes , has_multiple_files_tested
143+ has_multiple_files_tested = False
131144 logging .debug ("Loading new PDDL instance..." )
132145 logging .debug ("Domain: " + domain_path )
133146 logging .debug ("Problem: " + problem_path )
134147 apla = AutomatedPlanner (domain_path , problem_path )
135- _ , total_time , opened_nodes = apla .breadth_first_search ()
136- return [total_time ], [opened_nodes ], has_multiple_files_tested
148+ path , total_time , opened_nodes = apla .breadth_first_search ()
149+ if path :
150+ return [total_time ], [opened_nodes ], has_multiple_files_tested
151+ return [0 ], [0 ], has_multiple_files_tested
137152
138153 def plot_bfs (self , domain = "" , problem = "" ):
139154 title = "BFS Statistics"
@@ -153,25 +168,30 @@ def plot_bfs(self, domain="", problem=""):
153168 def __gather_data_dfs (self , domain_path = "" , problem_path = "" ):
154169 has_multiple_files_tested = True
155170 if not domain_path or not problem_path :
156- has_multiple_files_tested = False
157171 metrics = dict ()
158172 for problem , domain in self .__get_all_pddl_from_data ():
159173 logging .debug ("Loading new PDDL instance planned with DFS..." )
160174 logging .debug ("Domain: " + domain )
161175 logging .debug ("Problem: " + problem )
162176 apla = AutomatedPlanner (domain , problem )
163- _ , total_time , opened_nodes = apla .depth_first_search ()
164- metrics [total_time ] = opened_nodes
177+ path , total_time , opened_nodes = apla .depth_first_search ()
178+ if path :
179+ metrics [total_time ] = opened_nodes
180+ else :
181+ metrics [0 ] = 0
165182
166183 total_nodes = list (metrics .values ())
167184 times = list (metrics .keys ())
168185 return times , total_nodes , has_multiple_files_tested
186+ has_multiple_files_tested = False
169187 logging .debug ("Loading new PDDL instance..." )
170188 logging .debug ("Domain: " + domain_path )
171189 logging .debug ("Problem: " + problem_path )
172190 apla = AutomatedPlanner (domain_path , problem_path )
173- _ , total_time , opened_nodes = apla .depth_first_search ()
174- return [total_time ], [opened_nodes ], has_multiple_files_tested
191+ path , total_time , opened_nodes = apla .depth_first_search ()
192+ if path :
193+ return [total_time ], [opened_nodes ], has_multiple_files_tested
194+ return [0 ], [0 ], has_multiple_files_tested
175195
176196 def plot_dfs (self , problem = "" , domain = "" ):
177197 title = "DFS Statistics"
@@ -191,25 +211,30 @@ def plot_dfs(self, problem="", domain=""):
191211 def __gather_data_dijkstra (self , domain_path = "" , problem_path = "" ):
192212 has_multiple_files_tested = True
193213 if not domain_path or not problem_path :
194- has_multiple_files_tested = False
195214 metrics = dict ()
196215 for problem , domain in self .__get_all_pddl_from_data ():
197216 logging .debug ("Loading new PDDL instance planned with Dijkstra..." )
198217 logging .debug ("Domain: " + domain )
199218 logging .debug ("Problem: " + problem )
200219 apla = AutomatedPlanner (domain , problem )
201- _ , total_time , opened_nodes = apla .dijktra_best_first_search ()
202- metrics [total_time ] = opened_nodes
220+ path , total_time , opened_nodes = apla .dijktra_best_first_search ()
221+ if path :
222+ metrics [total_time ] = opened_nodes
223+ else :
224+ metrics [0 ] = 0
203225
204226 total_nodes = list (metrics .values ())
205227 times = list (metrics .keys ())
206228 return times , total_nodes , has_multiple_files_tested
229+ has_multiple_files_tested = False
207230 logging .debug ("Loading new PDDL instance..." )
208231 logging .debug ("Domain: " + domain_path )
209232 logging .debug ("Problem: " + problem_path )
210233 apla = AutomatedPlanner (domain_path , problem_path )
211- _ , total_time , opened_nodes = apla .dijktra_best_first_search ()
212- return [total_time ], [opened_nodes ], has_multiple_files_tested
234+ path , total_time , opened_nodes = apla .dijktra_best_first_search ()
235+ if path :
236+ return [total_time ], [opened_nodes ], has_multiple_files_tested
237+ return [0 ], [0 ], has_multiple_files_tested
213238
214239 def plot_dijkstra (self , problem = "" , domain = "" ):
215240 title = "Dijkstra Statistics"
0 commit comments