Skip to content

Commit 16fb3bf

Browse files
guilyxactions-user
authored andcommitted
Apply formatting changes
1 parent 74daa07 commit 16fb3bf

4 files changed

Lines changed: 91 additions & 61 deletions

File tree

jupyddl/data_analyst.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,10 @@ def comparative_astar_heuristic_plot(
509509
times_y.append(data[node_opened])
510510

511511
ax.plot(
512-
nodes_sorted, times_y, "-o", label=h,
512+
nodes_sorted,
513+
times_y,
514+
"-o",
515+
label=h,
513516
)
514517

515518
plt.title("A* heuristics complexity comparison")
@@ -541,7 +544,10 @@ def comparative_greedy_bfs_heuristic_plot(
541544
times_y.append(data[node_opened])
542545

543546
ax.plot(
544-
nodes_sorted, times_y, "-o", label=h,
547+
nodes_sorted,
548+
times_y,
549+
"-o",
550+
label=h,
545551
)
546552

547553
plt.title("Greedy Best First heuristics complexity comparison")
@@ -616,7 +622,10 @@ def comparative_data_plot(
616622
for node_opened in nodes_sorted:
617623
times_y.append(data[node_opened])
618624
ax.plot(
619-
nodes_sorted, times_y, "-o", label=planner,
625+
nodes_sorted,
626+
times_y,
627+
"-o",
628+
label=planner,
620629
)
621630
plt.title("Planners complexity comparison")
622631
plt.legend(loc="upper left")
@@ -744,7 +753,9 @@ def compute_planners_efficiency(self):
744753
plt.ylabel("Cost to goal")
745754
for key, val in costs.items():
746755
ax.plot(
747-
val, "-o", label=key,
756+
val,
757+
"-o",
758+
label=key,
748759
)
749760
costs[key] = [i for i in costs[key] if i != 0]
750761
plt.title("Planners efficiency (costs)")

jupyddl/heuristics.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ def compute(self, state):
7979
return self.heuristic_keys[self.current_h](costs)
8080

8181
for ax in self.cache.axioms:
82-
fact_costs = self.automated_planner.pddl.compute_costs_one_step_derivation(
83-
facts, fact_costs, ax, self.current_h
82+
fact_costs = (
83+
self.automated_planner.pddl.compute_costs_one_step_derivation(
84+
facts, fact_costs, ax, self.current_h
85+
)
8486
)
8587

8688
actions = self.automated_planner.available_actions(state)
@@ -209,8 +211,10 @@ def compute(self, state):
209211
return max(costs)
210212

211213
for ax in self.cache.axioms:
212-
fact_costs = self.automated_planner.pddl.compute_costs_one_step_derivation(
213-
facts, fact_costs, ax, "max"
214+
fact_costs = (
215+
self.automated_planner.pddl.compute_costs_one_step_derivation(
216+
facts, fact_costs, ax, "max"
217+
)
214218
)
215219

216220
actions = self.automated_planner.available_actions(state)
@@ -347,7 +351,8 @@ def zero_heuristic():
347351

348352
while open_nodes_n > 0:
349353
current_key = min(
350-
[n for n in nodes if nodes[n].is_open], key=(lambda k: nodes[k].f_cost),
354+
[n for n in nodes if nodes[n].is_open],
355+
key=(lambda k: nodes[k].f_cost),
351356
)
352357
current_node = nodes[current_key]
353358

jupyddl/metrics.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,14 @@ def __str__(self):
2222
else:
2323
av = 0
2424
w = 0
25-
return (
26-
"Expanded %d state(s).\nOpened %d state(s).\nReopened %d state(s).\nEvaluated %d state(s).\nGenerated %d state(s).\nDead ends: %d state(s).\nRuntime: %.2fs.\nTotal heuristic runtime: %.2fs\nComputational weight of heuristic in the search: %.2f%%"
27-
% (
28-
self.n_expended,
29-
self.n_opened,
30-
self.n_reopened,
31-
self.n_evaluated,
32-
self.n_generated,
33-
self.deadend_states,
34-
self.runtime,
35-
av,
36-
w,
37-
)
25+
return "Expanded %d state(s).\nOpened %d state(s).\nReopened %d state(s).\nEvaluated %d state(s).\nGenerated %d state(s).\nDead ends: %d state(s).\nRuntime: %.2fs.\nTotal heuristic runtime: %.2fs\nComputational weight of heuristic in the search: %.2f%%" % (
26+
self.n_expended,
27+
self.n_opened,
28+
self.n_reopened,
29+
self.n_evaluated,
30+
self.n_generated,
31+
self.deadend_states,
32+
self.runtime,
33+
av,
34+
w,
3835
)

scripts/ipc.py

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -98,45 +98,62 @@
9898
actions_str8 += str(a) + "\n"
9999

100100
dump = (
101-
"A* - Critical Path - H1\n ======PLAN (Nodes)=======\n%s\n" \
102-
"======PLAN (Actions)=======\n%s\n" \
103-
"======METRICS=======\n%s\n\n" \
104-
"A* - Critical Path - H2\n" \
105-
"======PLAN (Nodes)=======\n%s\n" \
106-
"======PLAN (Actions)=======\n%s\n" \
107-
"======METRICS=======\n%s\n\n" \
108-
"A* - Critical Path - H3\n" \
109-
"======PLAN (Nodes)=======\n%s\n" \
110-
"======PLAN (Actions)=======\n%s\n" \
111-
"======METRICS=======\n%s\n\n" \
112-
"A* - Relaxed Critical Path - H1\n" \
113-
"======PLAN (Nodes)=======\n%s\n" \
114-
"======PLAN (Actions)=======\n%s\n" \
115-
"======METRICS=======\n%s\n\n" \
116-
"A* - Relaxed Critical Path - H2\n" \
117-
"======PLAN (Nodes)=======\n%s\n" \
118-
"======PLAN (Actions)=======\n%s\n" \
119-
"======METRICS=======\n%s\n\n" \
120-
"A* - Relaxed Citical Path - H3\n" \
121-
"======PLAN (Nodes)=======\n%s\n" \
122-
"======PLAN (Actions)=======\n%s\n" \
123-
"======METRICS=======\n%s\n\n" \
124-
"A* - Delete Relaxation - H_Max\n" \
125-
"======PLAN (Nodes)=======\n%s\n" \
126-
"======PLAN (Actions)=======\n%s\n" \
127-
"======METRICS=======\n%s\n\n" \
128-
"A* - Delete Relaxation - H_Add\n" \
129-
"======PLAN (Nodes)=======\n%s\n" \
130-
"======PLAN (Actions)=======\n%s\n" \
131-
"======METRICS=======\n%s\n\n"
132-
% (str(path), actions_str, str(metrics),
133-
str(path2), actions_str2, str(metrics2),
134-
str(path3), actions_str3, str(metrics3),
135-
str(path4), actions_str4, str(metrics4),
136-
str(path5), actions_str5, str(metrics5),
137-
str(path6), actions_str6, str(metrics6),
138-
str(path7), actions_str7, str(metrics7),
139-
str(path8), actions_str8, str(metrics8)
101+
"A* - Critical Path - H1\n ======PLAN (Nodes)=======\n%s\n"
102+
"======PLAN (Actions)=======\n%s\n"
103+
"======METRICS=======\n%s\n\n"
104+
"A* - Critical Path - H2\n"
105+
"======PLAN (Nodes)=======\n%s\n"
106+
"======PLAN (Actions)=======\n%s\n"
107+
"======METRICS=======\n%s\n\n"
108+
"A* - Critical Path - H3\n"
109+
"======PLAN (Nodes)=======\n%s\n"
110+
"======PLAN (Actions)=======\n%s\n"
111+
"======METRICS=======\n%s\n\n"
112+
"A* - Relaxed Critical Path - H1\n"
113+
"======PLAN (Nodes)=======\n%s\n"
114+
"======PLAN (Actions)=======\n%s\n"
115+
"======METRICS=======\n%s\n\n"
116+
"A* - Relaxed Critical Path - H2\n"
117+
"======PLAN (Nodes)=======\n%s\n"
118+
"======PLAN (Actions)=======\n%s\n"
119+
"======METRICS=======\n%s\n\n"
120+
"A* - Relaxed Citical Path - H3\n"
121+
"======PLAN (Nodes)=======\n%s\n"
122+
"======PLAN (Actions)=======\n%s\n"
123+
"======METRICS=======\n%s\n\n"
124+
"A* - Delete Relaxation - H_Max\n"
125+
"======PLAN (Nodes)=======\n%s\n"
126+
"======PLAN (Actions)=======\n%s\n"
127+
"======METRICS=======\n%s\n\n"
128+
"A* - Delete Relaxation - H_Add\n"
129+
"======PLAN (Nodes)=======\n%s\n"
130+
"======PLAN (Actions)=======\n%s\n"
131+
"======METRICS=======\n%s\n\n"
132+
% (
133+
str(path),
134+
actions_str,
135+
str(metrics),
136+
str(path2),
137+
actions_str2,
138+
str(metrics2),
139+
str(path3),
140+
actions_str3,
141+
str(metrics3),
142+
str(path4),
143+
actions_str4,
144+
str(metrics4),
145+
str(path5),
146+
actions_str5,
147+
str(metrics5),
148+
str(path6),
149+
actions_str6,
150+
str(metrics6),
151+
str(path7),
152+
actions_str7,
153+
str(metrics7),
154+
str(path8),
155+
actions_str8,
156+
str(metrics8),
140157
)
141158
)
142159

0 commit comments

Comments
 (0)