gr-libs 0.1.6.post1__py3-none-any.whl → 0.1.8__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.
- evaluation/analyze_results_cross_alg_cross_domain.py +236 -246
- evaluation/create_minigrid_map_image.py +10 -6
- evaluation/file_system.py +16 -5
- evaluation/generate_experiments_results.py +123 -74
- evaluation/generate_experiments_results_new_ver1.py +227 -243
- evaluation/generate_experiments_results_new_ver2.py +317 -317
- evaluation/generate_task_specific_statistics_plots.py +481 -253
- evaluation/get_plans_images.py +41 -26
- evaluation/increasing_and_decreasing_.py +97 -56
- gr_libs/__init__.py +6 -1
- gr_libs/_version.py +2 -2
- gr_libs/environment/__init__.py +17 -9
- gr_libs/environment/environment.py +167 -39
- gr_libs/environment/utils/utils.py +22 -12
- gr_libs/metrics/__init__.py +5 -0
- gr_libs/metrics/metrics.py +76 -34
- gr_libs/ml/__init__.py +2 -0
- gr_libs/ml/agent.py +21 -6
- gr_libs/ml/base/__init__.py +1 -1
- gr_libs/ml/base/rl_agent.py +13 -10
- gr_libs/ml/consts.py +1 -1
- gr_libs/ml/neural/deep_rl_learner.py +433 -352
- gr_libs/ml/neural/utils/__init__.py +1 -1
- gr_libs/ml/neural/utils/dictlist.py +3 -3
- gr_libs/ml/neural/utils/penv.py +5 -2
- gr_libs/ml/planner/mcts/mcts_model.py +524 -302
- gr_libs/ml/planner/mcts/utils/__init__.py +1 -1
- gr_libs/ml/planner/mcts/utils/node.py +11 -7
- gr_libs/ml/planner/mcts/utils/tree.py +14 -10
- gr_libs/ml/sequential/__init__.py +1 -1
- gr_libs/ml/sequential/lstm_model.py +256 -175
- gr_libs/ml/tabular/state.py +7 -7
- gr_libs/ml/tabular/tabular_q_learner.py +123 -73
- gr_libs/ml/tabular/tabular_rl_agent.py +20 -19
- gr_libs/ml/utils/__init__.py +8 -2
- gr_libs/ml/utils/format.py +78 -70
- gr_libs/ml/utils/math.py +2 -1
- gr_libs/ml/utils/other.py +1 -1
- gr_libs/ml/utils/storage.py +95 -28
- gr_libs/problems/consts.py +1549 -1227
- gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +145 -80
- gr_libs/recognizer/graml/gr_dataset.py +209 -110
- gr_libs/recognizer/graml/graml_recognizer.py +431 -231
- gr_libs/recognizer/recognizer.py +38 -27
- gr_libs/recognizer/utils/__init__.py +1 -1
- gr_libs/recognizer/utils/format.py +8 -3
- {gr_libs-0.1.6.post1.dist-info → gr_libs-0.1.8.dist-info}/METADATA +1 -1
- gr_libs-0.1.8.dist-info/RECORD +70 -0
- {gr_libs-0.1.6.post1.dist-info → gr_libs-0.1.8.dist-info}/WHEEL +1 -1
- {gr_libs-0.1.6.post1.dist-info → gr_libs-0.1.8.dist-info}/top_level.txt +0 -1
- tests/test_gcdraco.py +10 -0
- tests/test_graml.py +8 -4
- tests/test_graql.py +2 -1
- tutorials/gcdraco_panda_tutorial.py +66 -0
- tutorials/gcdraco_parking_tutorial.py +61 -0
- tutorials/graml_minigrid_tutorial.py +42 -12
- tutorials/graml_panda_tutorial.py +35 -14
- tutorials/graml_parking_tutorial.py +37 -19
- tutorials/graml_point_maze_tutorial.py +33 -13
- tutorials/graql_minigrid_tutorial.py +31 -15
- CI/README.md +0 -12
- CI/docker_build_context/Dockerfile +0 -15
- gr_libs/recognizer/recognizer_doc.md +0 -61
- gr_libs-0.1.6.post1.dist-info/RECORD +0 -70
@@ -4,89 +4,138 @@ import matplotlib.pyplot as plt
|
|
4
4
|
import numpy as np
|
5
5
|
import os
|
6
6
|
import dill
|
7
|
-
from gr_libs.ml.utils.storage import
|
7
|
+
from gr_libs.ml.utils.storage import (
|
8
|
+
get_experiment_results_path,
|
9
|
+
set_global_storage_configs,
|
10
|
+
)
|
8
11
|
from scripts.generate_task_specific_statistics_plots import get_figures_dir_path
|
9
12
|
|
10
|
-
def gen_graph(graph_name, x_label_str, tasks, panda_env, minigrid_env, parking_env, maze_env, percentage):
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#'point_maze': [],
|
23
|
-
'parking': []
|
24
|
-
}
|
25
|
-
}
|
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
|
+
):
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
+
}
|
31
39
|
|
32
|
-
|
33
|
-
for domain, env in domains_envs:
|
34
|
-
for task in tasks:
|
35
|
-
set_global_storage_configs(recognizer_str='graml', is_fragmented=partial_obs_type,
|
36
|
-
is_inference_same_length_sequences=True, is_learn_same_length_sequences=is_same_learn)
|
37
|
-
graml_res_file_path = f'{get_experiment_results_path(domain, env, task)}.pkl'
|
38
|
-
set_global_storage_configs(recognizer_str='graql', is_fragmented=partial_obs_type)
|
39
|
-
graql_res_file_path = f'{get_experiment_results_path(domain, env, task)}.pkl'
|
40
|
-
if os.path.exists(graml_res_file_path):
|
41
|
-
with open(graml_res_file_path, 'rb') as results_file:
|
42
|
-
results = dill.load(results_file)
|
43
|
-
accuracies['graml'][domain].append(results[percentage]['accuracy'])
|
44
|
-
else:
|
45
|
-
assert(False, f"no file for {graml_res_file_path}")
|
46
|
-
if os.path.exists(graql_res_file_path):
|
47
|
-
with open(graql_res_file_path, 'rb') as results_file:
|
48
|
-
results = dill.load(results_file)
|
49
|
-
accuracies['graql'][domain].append(results[percentage]['accuracy'])
|
50
|
-
else:
|
51
|
-
assert(False, f"no file for {graql_res_file_path}")
|
40
|
+
continuing_accuracies = copy.deepcopy(fragmented_accuracies)
|
52
41
|
|
53
|
-
|
54
|
-
|
55
|
-
colors = plt.cm.get_cmap('tab10', len(accuracies['graml']) * len(accuracies['graml']['parking']))
|
42
|
+
# domains_envs = [('minigrid', minigrid_env), ('point_maze', maze_env), ('parking', parking_env)]
|
43
|
+
domains_envs = [("parking", parking_env)]
|
56
44
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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}")
|
70
83
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
+
)
|
75
89
|
|
76
|
-
|
77
|
-
|
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")
|
78
127
|
|
79
|
-
# Save the figure
|
80
|
-
fig_path = os.path.join(f"{graph_name}_{partial_obs_type}.png")
|
81
|
-
plt.savefig(fig_path)
|
82
|
-
print(f"Accuracies figure saved at: {fig_path}")
|
83
128
|
|
84
|
-
print(f'fragmented_accuracies: {fragmented_accuracies}')
|
85
|
-
plot_accuracies(fragmented_accuracies, 'fragmented')
|
86
|
-
print(f'continuing_accuracies: {continuing_accuracies}')
|
87
|
-
plot_accuracies(continuing_accuracies, 'continuing')
|
88
|
-
|
89
129
|
if __name__ == "__main__":
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
+
)
|