gr-libs 0.1.7.post0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gr_libs/__init__.py +4 -1
- gr_libs/_evaluation/__init__.py +1 -0
- gr_libs/_evaluation/_analyze_results_cross_alg_cross_domain.py +260 -0
- gr_libs/_evaluation/_generate_experiments_results.py +141 -0
- gr_libs/_evaluation/_generate_task_specific_statistics_plots.py +497 -0
- gr_libs/_evaluation/_get_plans_images.py +61 -0
- gr_libs/_evaluation/_increasing_and_decreasing_.py +106 -0
- gr_libs/_version.py +2 -2
- gr_libs/all_experiments.py +294 -0
- gr_libs/environment/__init__.py +30 -9
- gr_libs/environment/_utils/utils.py +27 -0
- gr_libs/environment/environment.py +417 -54
- gr_libs/metrics/__init__.py +7 -0
- gr_libs/metrics/metrics.py +231 -54
- gr_libs/ml/__init__.py +2 -5
- gr_libs/ml/agent.py +21 -6
- gr_libs/ml/base/__init__.py +3 -1
- gr_libs/ml/base/rl_agent.py +81 -13
- gr_libs/ml/consts.py +1 -1
- gr_libs/ml/neural/__init__.py +1 -3
- gr_libs/ml/neural/deep_rl_learner.py +619 -378
- gr_libs/ml/neural/utils/__init__.py +1 -2
- gr_libs/ml/neural/utils/dictlist.py +3 -3
- gr_libs/ml/planner/mcts/{utils → _utils}/__init__.py +1 -1
- gr_libs/ml/planner/mcts/{utils → _utils}/node.py +11 -7
- gr_libs/ml/planner/mcts/{utils → _utils}/tree.py +15 -11
- gr_libs/ml/planner/mcts/mcts_model.py +571 -312
- gr_libs/ml/sequential/__init__.py +0 -1
- gr_libs/ml/sequential/_lstm_model.py +270 -0
- gr_libs/ml/tabular/__init__.py +1 -3
- gr_libs/ml/tabular/state.py +7 -7
- gr_libs/ml/tabular/tabular_q_learner.py +150 -82
- gr_libs/ml/tabular/tabular_rl_agent.py +42 -28
- gr_libs/ml/utils/__init__.py +2 -3
- gr_libs/ml/utils/format.py +28 -97
- gr_libs/ml/utils/math.py +5 -3
- gr_libs/ml/utils/other.py +3 -3
- gr_libs/ml/utils/storage.py +88 -81
- gr_libs/odgr_executor.py +268 -0
- gr_libs/problems/consts.py +1549 -1227
- gr_libs/recognizer/_utils/__init__.py +0 -0
- gr_libs/recognizer/_utils/format.py +18 -0
- gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +233 -88
- gr_libs/recognizer/graml/_gr_dataset.py +233 -0
- gr_libs/recognizer/graml/graml_recognizer.py +586 -252
- gr_libs/recognizer/recognizer.py +90 -30
- gr_libs/tutorials/draco_panda_tutorial.py +58 -0
- gr_libs/tutorials/draco_parking_tutorial.py +56 -0
- gr_libs/tutorials/gcdraco_panda_tutorial.py +62 -0
- gr_libs/tutorials/gcdraco_parking_tutorial.py +57 -0
- gr_libs/tutorials/graml_minigrid_tutorial.py +64 -0
- gr_libs/tutorials/graml_panda_tutorial.py +57 -0
- gr_libs/tutorials/graml_parking_tutorial.py +52 -0
- gr_libs/tutorials/graml_point_maze_tutorial.py +60 -0
- gr_libs/tutorials/graql_minigrid_tutorial.py +50 -0
- {gr_libs-0.1.7.post0.dist-info → gr_libs-0.2.2.dist-info}/METADATA +84 -29
- gr_libs-0.2.2.dist-info/RECORD +71 -0
- {gr_libs-0.1.7.post0.dist-info → gr_libs-0.2.2.dist-info}/WHEEL +1 -1
- gr_libs-0.2.2.dist-info/top_level.txt +2 -0
- tests/test_draco.py +14 -0
- tests/test_gcdraco.py +10 -0
- tests/test_graml.py +12 -8
- tests/test_graql.py +3 -2
- evaluation/analyze_results_cross_alg_cross_domain.py +0 -277
- evaluation/create_minigrid_map_image.py +0 -34
- evaluation/file_system.py +0 -42
- evaluation/generate_experiments_results.py +0 -92
- evaluation/generate_experiments_results_new_ver1.py +0 -254
- evaluation/generate_experiments_results_new_ver2.py +0 -331
- evaluation/generate_task_specific_statistics_plots.py +0 -272
- evaluation/get_plans_images.py +0 -47
- evaluation/increasing_and_decreasing_.py +0 -63
- gr_libs/environment/utils/utils.py +0 -17
- gr_libs/ml/neural/utils/penv.py +0 -57
- gr_libs/ml/sequential/lstm_model.py +0 -192
- gr_libs/recognizer/graml/gr_dataset.py +0 -134
- gr_libs/recognizer/utils/__init__.py +0 -1
- gr_libs/recognizer/utils/format.py +0 -13
- gr_libs-0.1.7.post0.dist-info/RECORD +0 -67
- gr_libs-0.1.7.post0.dist-info/top_level.txt +0 -4
- tutorials/graml_minigrid_tutorial.py +0 -34
- tutorials/graml_panda_tutorial.py +0 -41
- tutorials/graml_parking_tutorial.py +0 -39
- tutorials/graml_point_maze_tutorial.py +0 -39
- tutorials/graql_minigrid_tutorial.py +0 -34
- /gr_libs/environment/{utils → _utils}/__init__.py +0 -0
gr_libs/__init__.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
"""gr_libs: Baselines for goal recognition executions on gym environments."""
|
2
|
+
|
3
|
+
from gr_libs.recognizer.gr_as_rl.gr_as_rl_recognizer import Draco, GCDraco, Graql
|
1
4
|
from gr_libs.recognizer.graml.graml_recognizer import ExpertBasedGraml, GCGraml
|
2
|
-
|
5
|
+
|
3
6
|
try:
|
4
7
|
from ._version import version as __version__
|
5
8
|
except ImportError:
|
@@ -0,0 +1 @@
|
|
1
|
+
""" This is a directory that includes scripts for analysis of GR results. """
|
@@ -0,0 +1,260 @@
|
|
1
|
+
import copy
|
2
|
+
import os
|
3
|
+
|
4
|
+
import dill
|
5
|
+
import matplotlib.pyplot as plt
|
6
|
+
import numpy as np
|
7
|
+
from scipy.interpolate import make_interp_spline
|
8
|
+
from scipy.ndimage import gaussian_filter1d
|
9
|
+
|
10
|
+
from gr_libs.ml.utils.storage import get_experiment_results_path
|
11
|
+
|
12
|
+
|
13
|
+
def smooth_line(x, y, num_points=300):
|
14
|
+
x_smooth = np.linspace(np.min(x), np.max(x), num_points)
|
15
|
+
spline = make_interp_spline(x, y, k=3) # Cubic spline
|
16
|
+
y_smooth = spline(x_smooth)
|
17
|
+
return x_smooth, y_smooth
|
18
|
+
|
19
|
+
|
20
|
+
if __name__ == "__main__":
|
21
|
+
|
22
|
+
fragmented_accuracies = {
|
23
|
+
"ExpertBasedGraml": {
|
24
|
+
"minigrid": {
|
25
|
+
"obstacles": {"0.3": [], "0.5": [], "0.7": [], "0.9": [], "1": []},
|
26
|
+
"lava_crossing": {"0.3": [], "0.5": [], "0.7": [], "0.9": [], "1": []},
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"Graql": {
|
30
|
+
"minigrid": {
|
31
|
+
"obstacles": {"0.3": [], "0.5": [], "0.7": [], "0.9": [], "1": []},
|
32
|
+
"lava_crossing": {"0.3": [], "0.5": [], "0.7": [], "0.9": [], "1": []},
|
33
|
+
}
|
34
|
+
},
|
35
|
+
}
|
36
|
+
|
37
|
+
continuing_accuracies = copy.deepcopy(fragmented_accuracies)
|
38
|
+
|
39
|
+
# domains = ['panda', 'minigrid', 'point_maze', 'parking']
|
40
|
+
domains = ["minigrid"]
|
41
|
+
tasks = ["L1", "L2", "L3", "L4", "L5"]
|
42
|
+
percentages = ["0.3", "0.5", "1"]
|
43
|
+
|
44
|
+
for partial_obs_type, accuracies, is_same_learn in zip(
|
45
|
+
["fragmented", "continuing"],
|
46
|
+
[fragmented_accuracies, continuing_accuracies],
|
47
|
+
[False, True],
|
48
|
+
):
|
49
|
+
for domain in domains:
|
50
|
+
for env in accuracies["ExpertBasedGraml"][domain].keys():
|
51
|
+
for task in tasks:
|
52
|
+
graml_res_file_path = f"{get_experiment_results_path(domain, env, task, 'ExpertBasedGraml')}.pkl"
|
53
|
+
graql_res_file_path = (
|
54
|
+
f"{get_experiment_results_path(domain, env, task, 'Graql')}.pkl"
|
55
|
+
)
|
56
|
+
if os.path.exists(graml_res_file_path):
|
57
|
+
with open(graml_res_file_path, "rb") as results_file:
|
58
|
+
results = dill.load(results_file)
|
59
|
+
for percentage in accuracies["expertbasedgraml"][domain][
|
60
|
+
env
|
61
|
+
].keys():
|
62
|
+
accuracies["expertbasedgraml"][domain][env][
|
63
|
+
percentage
|
64
|
+
].append(results[percentage]["accuracy"])
|
65
|
+
else:
|
66
|
+
assert False, f"no file for {graml_res_file_path}"
|
67
|
+
if os.path.exists(graql_res_file_path):
|
68
|
+
with open(graql_res_file_path, "rb") as results_file:
|
69
|
+
results = dill.load(results_file)
|
70
|
+
for percentage in accuracies["expertbasedgraml"][domain][
|
71
|
+
env
|
72
|
+
].keys():
|
73
|
+
accuracies["Graql"][domain][env][percentage].append(
|
74
|
+
results[percentage]["accuracy"]
|
75
|
+
)
|
76
|
+
else:
|
77
|
+
assert False, f"no file for {graql_res_file_path}"
|
78
|
+
|
79
|
+
plot_styles = {
|
80
|
+
(
|
81
|
+
"expertbasedgraml",
|
82
|
+
"fragmented",
|
83
|
+
0.3,
|
84
|
+
): "g--o", # Green dashed line with circle markers
|
85
|
+
(
|
86
|
+
"expertbasedgraml",
|
87
|
+
"fragmented",
|
88
|
+
0.5,
|
89
|
+
): "g--s", # Green dashed line with square markers
|
90
|
+
(
|
91
|
+
"expertbasedgraml",
|
92
|
+
"fragmented",
|
93
|
+
0.7,
|
94
|
+
): "g--^", # Green dashed line with triangle-up markers
|
95
|
+
(
|
96
|
+
"expertbasedgraml",
|
97
|
+
"fragmented",
|
98
|
+
0.9,
|
99
|
+
): "g--d", # Green dashed line with diamond markers
|
100
|
+
(
|
101
|
+
"expertbasedgraml",
|
102
|
+
"fragmented",
|
103
|
+
1.0,
|
104
|
+
): "g--*", # Green dashed line with star markers
|
105
|
+
(
|
106
|
+
"expertbasedgraml",
|
107
|
+
"continuing",
|
108
|
+
0.3,
|
109
|
+
): "g-o", # Green solid line with circle markers
|
110
|
+
(
|
111
|
+
"expertbasedgraml",
|
112
|
+
"continuing",
|
113
|
+
0.5,
|
114
|
+
): "g-s", # Green solid line with square markers
|
115
|
+
(
|
116
|
+
"expertbasedgraml",
|
117
|
+
"continuing",
|
118
|
+
0.7,
|
119
|
+
): "g-^", # Green solid line with triangle-up markers
|
120
|
+
(
|
121
|
+
"expertbasedgraml",
|
122
|
+
"continuing",
|
123
|
+
0.9,
|
124
|
+
): "g-d", # Green solid line with diamond markers
|
125
|
+
(
|
126
|
+
"expertbasedgraml",
|
127
|
+
"continuing",
|
128
|
+
1.0,
|
129
|
+
): "g-*", # Green solid line with star markers
|
130
|
+
("Graql", "fragmented", 0.3): "b--o", # Blue dashed line with circle markers
|
131
|
+
("Graql", "fragmented", 0.5): "b--s", # Blue dashed line with square markers
|
132
|
+
(
|
133
|
+
"Graql",
|
134
|
+
"fragmented",
|
135
|
+
0.7,
|
136
|
+
): "b--^", # Blue dashed line with triangle-up markers
|
137
|
+
("Graql", "fragmented", 0.9): "b--d", # Blue dashed line with diamond markers
|
138
|
+
("Graql", "fragmented", 1.0): "b--*", # Blue dashed line with star markers
|
139
|
+
("Graql", "continuing", 0.3): "b-o", # Blue solid line with circle markers
|
140
|
+
("Graql", "continuing", 0.5): "b-s", # Blue solid line with square markers
|
141
|
+
("Graql", "continuing", 0.7): "b-^", # Blue solid line with triangle-up markers
|
142
|
+
("Graql", "continuing", 0.9): "b-d", # Blue solid line with diamond markers
|
143
|
+
("Graql", "continuing", 1.0): "b-*", # Blue solid line with star markers
|
144
|
+
}
|
145
|
+
|
146
|
+
def average_accuracies(accuracies, domain):
|
147
|
+
avg_acc = {
|
148
|
+
algo: {perc: [] for perc in percentages}
|
149
|
+
for algo in ["ExpertBasedGraml", "Graql"]
|
150
|
+
}
|
151
|
+
|
152
|
+
for algo in avg_acc.keys():
|
153
|
+
for perc in percentages:
|
154
|
+
for env in accuracies[algo][domain].keys():
|
155
|
+
env_acc = accuracies[algo][domain][env][
|
156
|
+
perc
|
157
|
+
] # list of 5, averages for L111 to L555.
|
158
|
+
if env_acc:
|
159
|
+
avg_acc[algo][perc].append(np.array(env_acc))
|
160
|
+
|
161
|
+
for algo in avg_acc.keys():
|
162
|
+
for perc in percentages:
|
163
|
+
if avg_acc[algo][perc]:
|
164
|
+
avg_acc[algo][perc] = np.mean(np.array(avg_acc[algo][perc]), axis=0)
|
165
|
+
|
166
|
+
return avg_acc
|
167
|
+
|
168
|
+
def plot_domain_accuracies(
|
169
|
+
ax,
|
170
|
+
fragmented_accuracies,
|
171
|
+
continuing_accuracies,
|
172
|
+
domain,
|
173
|
+
sigma=1,
|
174
|
+
line_width=1.5,
|
175
|
+
):
|
176
|
+
fragmented_avg_acc = average_accuracies(fragmented_accuracies, domain)
|
177
|
+
continuing_avg_acc = average_accuracies(continuing_accuracies, domain)
|
178
|
+
|
179
|
+
x_vals = np.arange(1, 6) # Number of goals
|
180
|
+
|
181
|
+
# Create "waves" (shaded regions) for each algorithm
|
182
|
+
for algo in ["ExpertBasedGraml", "Graql"]:
|
183
|
+
fragmented_y_vals_by_percentage = []
|
184
|
+
continuing_y_vals_by_percentage = []
|
185
|
+
|
186
|
+
for perc in percentages:
|
187
|
+
fragmented_y_vals = np.array(fragmented_avg_acc[algo][perc])
|
188
|
+
continuing_y_vals = np.array(continuing_avg_acc[algo][perc])
|
189
|
+
|
190
|
+
# Smooth the trends using Gaussian filtering
|
191
|
+
fragmented_y_smoothed = gaussian_filter1d(
|
192
|
+
fragmented_y_vals, sigma=sigma
|
193
|
+
)
|
194
|
+
continuing_y_smoothed = gaussian_filter1d(
|
195
|
+
continuing_y_vals, sigma=sigma
|
196
|
+
)
|
197
|
+
|
198
|
+
fragmented_y_vals_by_percentage.append(fragmented_y_smoothed)
|
199
|
+
continuing_y_vals_by_percentage.append(continuing_y_smoothed)
|
200
|
+
|
201
|
+
ax.plot(
|
202
|
+
x_vals,
|
203
|
+
fragmented_y_smoothed,
|
204
|
+
plot_styles[(algo, "fragmented", float(perc))],
|
205
|
+
label=f"{algo}, non-consecutive, {perc}",
|
206
|
+
linewidth=0.5, # Control line thickness here
|
207
|
+
)
|
208
|
+
ax.plot(
|
209
|
+
x_vals,
|
210
|
+
continuing_y_smoothed,
|
211
|
+
plot_styles[(algo, "continuing", float(perc))],
|
212
|
+
label=f"{algo}, consecutive, {perc}",
|
213
|
+
linewidth=0.5, # Control line thickness here
|
214
|
+
)
|
215
|
+
|
216
|
+
ax.set_xticks(x_vals)
|
217
|
+
ax.set_yticks(np.linspace(0, 1, 6))
|
218
|
+
ax.set_ylim([0, 1])
|
219
|
+
ax.set_title(f"{domain.capitalize()} Domain", fontsize=16)
|
220
|
+
ax.grid(True)
|
221
|
+
|
222
|
+
fig, axes = plt.subplots(
|
223
|
+
1, 4, figsize=(24, 6)
|
224
|
+
) # Increase the figure size for better spacing (width 24, height 6)
|
225
|
+
|
226
|
+
# Generate each plot in a subplot, including both fragmented and continuing accuracies
|
227
|
+
for i, domain in enumerate(domains):
|
228
|
+
plot_domain_accuracies(
|
229
|
+
axes[i], fragmented_accuracies, continuing_accuracies, domain
|
230
|
+
)
|
231
|
+
|
232
|
+
# Set a single x-axis and y-axis label for the entire figure
|
233
|
+
fig.text(
|
234
|
+
0.5, 0.04, "Number of Goals", ha="center", fontsize=20
|
235
|
+
) # Centered x-axis label
|
236
|
+
fig.text(
|
237
|
+
0.04, 0.5, "Accuracy", va="center", rotation="vertical", fontsize=20
|
238
|
+
) # Reduced spacing for y-axis label
|
239
|
+
|
240
|
+
# Adjust subplot layout to avoid overlap
|
241
|
+
plt.subplots_adjust(
|
242
|
+
left=0.09, right=0.91, top=0.79, bottom=0.21, wspace=0.3
|
243
|
+
) # More space on top (top=0.82)
|
244
|
+
|
245
|
+
# Place the legend above the plots with more space between legend and plots
|
246
|
+
handles, labels = axes[0].get_legend_handles_labels()
|
247
|
+
fig.legend(
|
248
|
+
handles,
|
249
|
+
labels,
|
250
|
+
loc="upper center",
|
251
|
+
ncol=4,
|
252
|
+
bbox_to_anchor=(0.5, 1.05),
|
253
|
+
fontsize=12,
|
254
|
+
) # Moved above with bbox_to_anchor
|
255
|
+
|
256
|
+
# Save the figure and show it
|
257
|
+
save_dir = os.path.join("figures", "all_domains_accuracy_plots")
|
258
|
+
if not os.path.exists(save_dir):
|
259
|
+
os.makedirs(save_dir)
|
260
|
+
plt.savefig(os.path.join(save_dir, "accuracy_plots_smooth.png"), dpi=300)
|
@@ -0,0 +1,141 @@
|
|
1
|
+
import copy
|
2
|
+
import os
|
3
|
+
|
4
|
+
import dill
|
5
|
+
import matplotlib.pyplot as plt
|
6
|
+
import numpy as np
|
7
|
+
|
8
|
+
from gr_libs.ml.utils.storage import (
|
9
|
+
get_experiment_results_path,
|
10
|
+
set_global_storage_configs,
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
def gen_graph(
|
15
|
+
graph_name,
|
16
|
+
x_label_str,
|
17
|
+
tasks,
|
18
|
+
panda_env,
|
19
|
+
minigrid_env,
|
20
|
+
parking_env,
|
21
|
+
maze_env,
|
22
|
+
percentage,
|
23
|
+
):
|
24
|
+
|
25
|
+
fragmented_accuracies = {
|
26
|
+
"graml": {
|
27
|
+
#'panda': [],
|
28
|
+
#'minigrid': [],
|
29
|
+
#'point_maze': [],
|
30
|
+
"parking": []
|
31
|
+
},
|
32
|
+
"graql": {
|
33
|
+
#'panda': [],
|
34
|
+
#'minigrid': [],
|
35
|
+
#'point_maze': [],
|
36
|
+
"parking": []
|
37
|
+
},
|
38
|
+
}
|
39
|
+
|
40
|
+
continuing_accuracies = copy.deepcopy(fragmented_accuracies)
|
41
|
+
|
42
|
+
# domains_envs = [('minigrid', minigrid_env), ('point_maze', maze_env), ('parking', parking_env)]
|
43
|
+
domains_envs = [("parking", parking_env)]
|
44
|
+
|
45
|
+
for partial_obs_type, accuracies, is_same_learn in zip(
|
46
|
+
["fragmented", "continuing"],
|
47
|
+
[fragmented_accuracies, continuing_accuracies],
|
48
|
+
[False, True],
|
49
|
+
):
|
50
|
+
for domain, env in domains_envs:
|
51
|
+
for task in tasks:
|
52
|
+
set_global_storage_configs(
|
53
|
+
recognizer_str="graml",
|
54
|
+
is_fragmented=partial_obs_type,
|
55
|
+
is_inference_same_length_sequences=True,
|
56
|
+
is_learn_same_length_sequences=is_same_learn,
|
57
|
+
)
|
58
|
+
graml_res_file_path = (
|
59
|
+
f"{get_experiment_results_path(domain, env, task)}.pkl"
|
60
|
+
)
|
61
|
+
set_global_storage_configs(
|
62
|
+
recognizer_str="graql", is_fragmented=partial_obs_type
|
63
|
+
)
|
64
|
+
graql_res_file_path = (
|
65
|
+
f"{get_experiment_results_path(domain, env, task)}.pkl"
|
66
|
+
)
|
67
|
+
if os.path.exists(graml_res_file_path):
|
68
|
+
with open(graml_res_file_path, "rb") as results_file:
|
69
|
+
results = dill.load(results_file)
|
70
|
+
accuracies["graml"][domain].append(
|
71
|
+
results[percentage]["accuracy"]
|
72
|
+
)
|
73
|
+
else:
|
74
|
+
assert False, f"no file for {graml_res_file_path}"
|
75
|
+
if os.path.exists(graql_res_file_path):
|
76
|
+
with open(graql_res_file_path, "rb") as results_file:
|
77
|
+
results = dill.load(results_file)
|
78
|
+
accuracies["graql"][domain].append(
|
79
|
+
results[percentage]["accuracy"]
|
80
|
+
)
|
81
|
+
else:
|
82
|
+
assert False, f"no file for {graql_res_file_path}"
|
83
|
+
|
84
|
+
def plot_accuracies(accuracies, partial_obs_type):
|
85
|
+
plt.figure(figsize=(10, 6))
|
86
|
+
colors = plt.cm.get_cmap(
|
87
|
+
"tab10", len(accuracies["graml"]) * len(accuracies["graml"]["parking"])
|
88
|
+
)
|
89
|
+
|
90
|
+
# Define different line styles for each algorithm
|
91
|
+
line_styles = {"graml": "-", "graql": "--"}
|
92
|
+
x_vals = np.arange(3, 8)
|
93
|
+
plt.xticks(x_vals)
|
94
|
+
plt.yticks(np.linspace(0, 1, 6))
|
95
|
+
plt.ylim([0, 1])
|
96
|
+
# Plot each domain-env pair's accuracies with different line styles for each algorithm
|
97
|
+
for alg in ["graml", "graql"]:
|
98
|
+
for idx, (domain, acc_values) in enumerate(accuracies[alg].items()):
|
99
|
+
if acc_values and len(acc_values) > 0: # Only plot if there are values
|
100
|
+
x_values = np.arange(3, len(acc_values) + 3)
|
101
|
+
plt.plot(
|
102
|
+
x_values,
|
103
|
+
acc_values,
|
104
|
+
marker="o",
|
105
|
+
linestyle=line_styles[alg],
|
106
|
+
color=colors(idx),
|
107
|
+
label=f"{alg}-{domain}-{partial_obs_type}-{percentage}",
|
108
|
+
)
|
109
|
+
|
110
|
+
# Set labels, title, and grid
|
111
|
+
plt.xlabel(x_label_str)
|
112
|
+
plt.ylabel("Accuracy")
|
113
|
+
plt.grid(True)
|
114
|
+
|
115
|
+
# Add legend to differentiate between domain-env pairs
|
116
|
+
plt.legend()
|
117
|
+
|
118
|
+
# Save the figure
|
119
|
+
fig_path = os.path.join(f"{graph_name}_{partial_obs_type}.png")
|
120
|
+
plt.savefig(fig_path)
|
121
|
+
print(f"Accuracies figure saved at: {fig_path}")
|
122
|
+
|
123
|
+
print(f"fragmented_accuracies: {fragmented_accuracies}")
|
124
|
+
plot_accuracies(fragmented_accuracies, "fragmented")
|
125
|
+
print(f"continuing_accuracies: {continuing_accuracies}")
|
126
|
+
plot_accuracies(continuing_accuracies, "continuing")
|
127
|
+
|
128
|
+
|
129
|
+
if __name__ == "__main__":
|
130
|
+
# gen_graph("increasing_base_goals", "Number of base goals", ['L1', 'L2', 'L3', 'L4', 'L5'], panda_env='gd_agent', minigrid_env='obstacles', parking_env='gd_agent', maze_env='obstacles')
|
131
|
+
# gen_graph("increasing_dynamic_goals", "Number of dynamic goals", ['L1', 'L2', 'L3', 'L4', 'L5'], panda_env='gc_agent', minigrid_env='lava_crossing', parking_env='gc_agent', maze_env='four_rooms')
|
132
|
+
gen_graph(
|
133
|
+
"base_problems",
|
134
|
+
"Number of goals",
|
135
|
+
["L111", "L222", "L333", "L444", "L555"],
|
136
|
+
panda_env="gd_agent",
|
137
|
+
minigrid_env="obstacles",
|
138
|
+
parking_env="gc_agent",
|
139
|
+
maze_env="obstacles",
|
140
|
+
percentage="0.7",
|
141
|
+
)
|