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
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gr_libs
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.2
|
4
4
|
Summary: Package with goal recognition frameworks baselines
|
5
5
|
Author: Ben Nageris
|
6
6
|
Author-email: Matan Shamir <matan.shamir@live.biu.ac.il>, Osher Elhadad <osher.elhadad@live.biu.ac.il>
|
@@ -106,6 +106,25 @@ If you prefer using Conda, follow these steps:
|
|
106
106
|
|
107
107
|
For any issues or troubleshooting, please refer to the repository's issue tracker.
|
108
108
|
|
109
|
+
## Supported Algorithms
|
110
|
+
|
111
|
+
Successors of algorithms that don't differ in their specifics are added in parentheses after the algorithm name. For example, since GC-DRACO and DRACO share the same column values, they're written on one line as DRACO (GC).
|
112
|
+
|
113
|
+
| **Algorithm** | **Supervised** | **Reinforcement Learning** | **Discrete States** | **Continuous States** | **Discrete Actions** | **Continuous Actions** | **Model-Based** | **Model-Free** | **Action-Only** |
|
114
|
+
|--------------|--------------|------------------------|------------------|------------------|--------------|--------------|--------------|--------------|--------------|
|
115
|
+
| GRAQL | ❌ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ |
|
116
|
+
| DRACO (GC) | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
|
117
|
+
| GRAML (GC, BG) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
|
118
|
+
|
119
|
+
## Supported Domains
|
120
|
+
|
121
|
+
| **Domain** | **Action Space** | **State Space** |
|
122
|
+
|------------|----------------|----------------|
|
123
|
+
| Minigrid | Discrete | Discrete |
|
124
|
+
| PointMaze | Continuous | Continuous |
|
125
|
+
| Parking | Continuous | Continuous |
|
126
|
+
| Panda | Continuous | Continuous |
|
127
|
+
|
109
128
|
## Usage Guide
|
110
129
|
|
111
130
|
After installing GRLib, you will have access to custom Gym environments, allowing you to set up and execute an Online Dynamic Goal Recognition (ODGR) scenario with the algorithm of your choice.
|
@@ -116,9 +135,10 @@ Tutorials demonstrating basic ODGR scenarios is available in the sub-package `tu
|
|
116
135
|
gr_libs also includes a library of trained agents for the various supported environments within the package.
|
117
136
|
To get the dataset of trained agents, you can run:
|
118
137
|
```sh
|
138
|
+
pip install gdown
|
119
139
|
python download_dataset.py
|
120
140
|
```
|
121
|
-
|
141
|
+
Alternatively, you can visit the google-drive links where download_dataset.py points to and manually download the zipped folders, and unzip them into the project directory.
|
122
142
|
An alternative is to use our docker image, which includes the dataset in it.
|
123
143
|
You can:
|
124
144
|
1. pull the image:
|
@@ -191,42 +211,77 @@ docker run -it ghcr.io/MatanShamir1/gr_test_base:latest bash
|
|
191
211
|
|
192
212
|
The `consts.py` file contains predefined ODGR problem configurations. You can use existing configurations or define new ones.
|
193
213
|
|
194
|
-
To execute
|
214
|
+
To execute an ODGR problem using the configuration file, you specify a recognizer, a domain, a gym environment within that domain and the task:
|
195
215
|
```sh
|
196
|
-
python odgr_executor.py --recognizer
|
216
|
+
python odgr_executor.py --recognizer ExpertBasedGraml --domain minigrid --task L1 --env_name MiniGrid-SimpleCrossingS13N4
|
197
217
|
```
|
198
218
|
|
199
|
-
|
219
|
+
If you also add the flag:
|
220
|
+
```sh
|
221
|
+
--collect_stats
|
222
|
+
```
|
223
|
+
to the cmd, 3 kinds of outputs will be generated from the ODGR problem's execution:
|
224
|
+
a. Into:
|
225
|
+
```sh
|
226
|
+
outputs\\minigrid\MiniGrid-SimpleCrossingS13N4\MiniGrid-SimpleCrossingS13N4\L1\experiment_results
|
227
|
+
```
|
228
|
+
a .pkl and a .txt summary in a dictionary format will be generated, including the summary of all ODGR executions, including runtime and overall accuracies for all lengths and types of input sequences.
|
200
229
|
|
201
|
-
|
230
|
+
b. Into:
|
231
|
+
```sh
|
232
|
+
outputs\ExpertBasedGraml\minigrid\MiniGrid-SimpleCrossingS13N4\policy_sequences\MiniGrid-SimpleCrossingS13N4-DynamicGoal-1x11-v0_inference_seq/plan_image.png
|
233
|
+
```
|
234
|
+
a visulzation of the sequence the agent generated will be dumped, either in a png or an mp4 format, depending on the domain, for debugability.
|
202
235
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
236
|
+
c. Into:
|
237
|
+
either:
|
238
|
+
```sh
|
239
|
+
outputs\ExpertBasedGraml\minigrid\MiniGrid-SimpleCrossingS13N4\goal_embeddings
|
240
|
+
```
|
241
|
+
In Graml algorithms, or:
|
242
|
+
```sh
|
243
|
+
outputs\Graql\minigrid\MiniGrid-SimpleCrossingS13N4\confidence
|
244
|
+
```
|
245
|
+
In GRAsRL algorithms,
|
246
|
+
pickled results from which confidence of the results can be obtained, for offline analysis.
|
208
247
|
|
209
|
-
|
248
|
+
For GRAsRL outputs, for every possible goal, the likelihood of it being the true goal from the input sequence, based on the policy distance metric.
|
210
249
|
|
211
|
-
|
212
|
-
|------------|----------------|----------------|
|
213
|
-
| Minigrid | Discrete | Discrete |
|
214
|
-
| PointMaze | Continuous | Continuous |
|
215
|
-
| Parking | Continuous | Continuous |
|
216
|
-
| Panda | Continuous | Continuous |
|
250
|
+
For GRAML outputs, the embeddings of the sequences are pickled for every goal-directed sequence. Offline, since, since in the embdding space of GRAML's metric model- sequences towards the same sequences are close and vice versa, one could reproduce the most likely goal by measuring the elementwise vector distance of the embeddings, and retrieve a confidence of it.
|
217
251
|
|
218
252
|
## Running Experiments
|
219
253
|
|
220
|
-
|
254
|
+
In light of the previous section, the user should already know how to scale the experiments using odgr_executor, and they should also understand how to use the 3 types of outputs for offline analysis of the algorithms.
|
255
|
+
gr_libs also provides another scaling method to run odgr_executor on multiple domains and environments, for many ODGR problems, as well as python scripts for analysis of these results, to create plots and statistics over the executions.
|
256
|
+
|
257
|
+
### Scaling odgr_executor runs
|
258
|
+
A part of the contribution of this package is standardizing the evaluations of MDP-based GR frameworks.
|
259
|
+
consts.py provides a set of ODGR problems on which the framework can be evaluated.
|
260
|
+
The 'evaluations' sub-package provides scripts to analyze the results of the all_experiments.py execution, done over the ODGR the problems defined at consts.py.
|
221
261
|
|
222
|
-
|
223
|
-
|
224
|
-
- Reads data from `get_experiment_results_path` (e.g., `dataset/graml/minigrid/continuing/.../experiment_results.pkl`).
|
225
|
-
- Generates plots comparing algorithm performance across domains.
|
262
|
+
In order to parallelize executions of odgr_executor.py, you can edit all_experiments.py with your combination of domains, environments and tasks.
|
263
|
+
This script use multiprocessing to simultaniously execute many odgr_executor.py python executions as child processes.
|
226
264
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
265
|
+
It logs failures and successful executions for debugability.
|
266
|
+
|
267
|
+
After execution, another level of abstraction for the results is created. For example, when running for Graql in the minigrid domain:
|
268
|
+
```sh
|
269
|
+
outputs\summaries\detailed_summary_minigrid_Graql.txt
|
270
|
+
```
|
271
|
+
Will show the accuracies for every ODGR problem, for every percentage and type of input in a table-like .txt format, whike:
|
272
|
+
```sh
|
273
|
+
outputs\summaries\compiled_summary_minigrid_Graql.txt
|
274
|
+
```
|
275
|
+
Will show the same results in a more compact summary.
|
276
|
+
|
277
|
+
### Using analysis scripts
|
278
|
+
The repository provides benchmark domains and scripts for analyzing experimental results. The `evaluation` directory contains tools for processing and visualizing the results from odgr_executor.py and all_experiments.py.
|
279
|
+
Please follow the README.md file in the 'evaluation' directory for more details.
|
280
|
+
|
281
|
+
## For Developers
|
282
|
+
Developers will need to work slightly different: instead of installing the packages, they need to clone the repos and either install them as editables or add their paths to PYTHONPATH so they will function as packages effectively.
|
283
|
+
Additional packages to install as a developer:
|
284
|
+
```sh
|
285
|
+
pip install pre-commit
|
286
|
+
pre-commit install
|
287
|
+
```
|
@@ -0,0 +1,71 @@
|
|
1
|
+
gr_libs/__init__.py,sha256=XGx0_nWGgy-1zEQUXHRBs3TTb13jX9yOxVvSaavCkBk,376
|
2
|
+
gr_libs/_version.py,sha256=OjGGK5TcHVG44Y62aAqeJH4CskkZoY9ydbHOtCDew50,511
|
3
|
+
gr_libs/all_experiments.py,sha256=0Xm1KZ1YDWGcAiYKc6IilZ-UyVuxm77iZNsUVzTURqY,11357
|
4
|
+
gr_libs/odgr_executor.py,sha256=AdO5qpQ6fZcVRxJg0O-mSKDXim3gVQbq8vSmfx0AjQk,10615
|
5
|
+
gr_libs/_evaluation/__init__.py,sha256=trZ-4PyOhzEEK_TvQLfbnNFcqYuN6SdRjDkkAdW6MW8,78
|
6
|
+
gr_libs/_evaluation/_analyze_results_cross_alg_cross_domain.py,sha256=ksguC1zeokjpd_ItC5e6MX8HE9qEtjw-uxCXzwGsO88,9863
|
7
|
+
gr_libs/_evaluation/_generate_experiments_results.py,sha256=Nj2XLDJ-g9Vn_3oA3tEDu8qWQcIT25Hf_tRySm00oGc,5163
|
8
|
+
gr_libs/_evaluation/_generate_task_specific_statistics_plots.py,sha256=Jgst3PW-XTu1JHWhyl73zi4mqoUI3U3dHLIUemKSx7c,19051
|
9
|
+
gr_libs/_evaluation/_get_plans_images.py,sha256=a_e97aOMiZ8toBiAIzJCx75lF9RLiVfxROYvcoNy6rM,2729
|
10
|
+
gr_libs/_evaluation/_increasing_and_decreasing_.py,sha256=1VOHrriv9mdhc1fxNjVAsu-sO77KRnscbmFXNUub0YU,3868
|
11
|
+
gr_libs/environment/__init__.py,sha256=xCCzTFDrj_ijdLoZ-PzGyyYDeU2aoW19X1da76_x9iM,1458
|
12
|
+
gr_libs/environment/environment.py,sha256=G3XXuhJDtduOtNeMCbwbMAygfP55AI07Aufs9QrggWQ,16389
|
13
|
+
gr_libs/environment/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
+
gr_libs/environment/_utils/utils.py,sha256=dKuWoUpyuGSJL6qHQfvvJnFf4g-Rh1t2ykuRNrsIvP8,614
|
15
|
+
gr_libs/metrics/__init__.py,sha256=dQo4cMqrOB2-VLDxTIGryCm14mUnmEXs4F8jqcgNsY4,145
|
16
|
+
gr_libs/metrics/metrics.py,sha256=tpjr4hKt5AGft5H2YxkbF0O8La5JZQaOmnkyjptD2M8,13430
|
17
|
+
gr_libs/ml/__init__.py,sha256=xX9InKnWhYm8e0Lhsnnm0H68yBPTNEfq756w95xv-98,83
|
18
|
+
gr_libs/ml/agent.py,sha256=ea1yRltKX0LSpRMnpAQLRKvvKoLMQz9MgMeWBPhQISw,2095
|
19
|
+
gr_libs/ml/consts.py,sha256=vsEB1nk5V_qP3FjNlv4vBKeTTFngV3RNaNp6fWnmEz0,366
|
20
|
+
gr_libs/ml/base/__init__.py,sha256=f63VN3Lv4tQp3dAZjtT78PGV5XuOD8WlU4svy43LZrU,123
|
21
|
+
gr_libs/ml/base/rl_agent.py,sha256=Ewqu583gUkgRmeGWCJgkyDBKxTqQnN4qa2vxq0-ydoE,3843
|
22
|
+
gr_libs/ml/neural/__init__.py,sha256=vGdjx1KzlB9UxNRwkAeYBEoYdVtRdhj0M4mtWuzqvU8,55
|
23
|
+
gr_libs/ml/neural/deep_rl_learner.py,sha256=iy0N0BaUW3jRttLYUteApNWBI5pIYZTjJn2v32UVUQ4,26950
|
24
|
+
gr_libs/ml/neural/utils/__init__.py,sha256=Av5wB2eSHR7spHqZFdgau_9EJV0FmijaYqXeyGMwktQ,69
|
25
|
+
gr_libs/ml/neural/utils/dictlist.py,sha256=ORFez_KmaCzraStF97hxdgCAAALP4Er8u3e9RcqlvhM,1030
|
26
|
+
gr_libs/ml/planner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
+
gr_libs/ml/planner/mcts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
|
+
gr_libs/ml/planner/mcts/mcts_model.py,sha256=Cv9hDrxTSK5tiaqPqp6-oO68EbETWlvRFweVRfwfjgg,27827
|
29
|
+
gr_libs/ml/planner/mcts/_utils/__init__.py,sha256=0ccEf23-6VIenUSrlVFCq0VNVDkCHHNzBw7jR09UiO4,46
|
30
|
+
gr_libs/ml/planner/mcts/_utils/node.py,sha256=LcbBjzURMDF4v_Lvz24dyhhW5xb1xQKWdPkue-2lNLM,1056
|
31
|
+
gr_libs/ml/planner/mcts/_utils/tree.py,sha256=ua_7pN00K7ECm6fk0TdRpDTe-z4J4iC6f84GCC0ceKc,3399
|
32
|
+
gr_libs/ml/sequential/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
|
+
gr_libs/ml/sequential/_lstm_model.py,sha256=3fXduJt1BkA2dPzA_jKInmZvUd1UpThHE8kqNCDCul0,10693
|
34
|
+
gr_libs/ml/tabular/__init__.py,sha256=yzHIPrn1lqVEDJbLbSz7RzNSr8IjU4TBdP0pqzQSFGU,32
|
35
|
+
gr_libs/ml/tabular/state.py,sha256=ImpIrYWF80PB-4EeQ2Q9nO7jMZ2s0hGbgsir1ZtsO88,700
|
36
|
+
gr_libs/ml/tabular/tabular_q_learner.py,sha256=eZ4Db-YgzQd4DIpFl4DvO7zVM-w2mHGFNk18-5ZmB4c,20122
|
37
|
+
gr_libs/ml/tabular/tabular_rl_agent.py,sha256=bL8Rk4dMY5HmeyVVmo986ZOizISfArskxLjf5DL87Uk,4205
|
38
|
+
gr_libs/ml/utils/__init__.py,sha256=-shnIzZCGBxZfcpep39bIoBKYED-SIN8I_HFUkVjay0,164
|
39
|
+
gr_libs/ml/utils/env.py,sha256=AWVN0OXYmFU-J3FUiwvEAIY93Suf1oL6VNcxtyWJraM,171
|
40
|
+
gr_libs/ml/utils/format.py,sha256=Vn2l7zmfqZ9Hq2pk2nlzQuVElmVyXr6nME6GsVNvVPE,1068
|
41
|
+
gr_libs/ml/utils/math.py,sha256=7Au9L-FHE7eB1ygLbbuR6AhZK6kq8D_9srVtu4iDMPk,429
|
42
|
+
gr_libs/ml/utils/other.py,sha256=93oaveiHUzWt_rCDVqybrpHdAfI3UBPCto31Nm5yT0Y,506
|
43
|
+
gr_libs/ml/utils/storage.py,sha256=CgZHWcC3GovKe-U3Cvwz0s5qCbBrYHY6w_CV-LnTquc,3791
|
44
|
+
gr_libs/problems/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
|
+
gr_libs/problems/consts.py,sha256=kgmaUi3wbHvcBfnIaXT8D79J_cD1yTrwgha6k3Y429Y,62096
|
46
|
+
gr_libs/recognizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
|
+
gr_libs/recognizer/recognizer.py,sha256=gtUttI1473co5ZHgO7-wQ7HL-aYJp0S4X6goqVYyT24,3091
|
48
|
+
gr_libs/recognizer/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
|
+
gr_libs/recognizer/_utils/format.py,sha256=eCoqEwv7YdLrF5nb-xAbDXxQ-ogvq_DHf9I2uwdfv-0,512
|
50
|
+
gr_libs/recognizer/gr_as_rl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
|
+
gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py,sha256=ztucO7YRZ3mZDGdt98OUAu_DJHVgUhUEvIngL2swfCE,9705
|
52
|
+
gr_libs/recognizer/graml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
|
+
gr_libs/recognizer/graml/_gr_dataset.py,sha256=JChqXOh7TP8yu-zQPCQ34ghw7iJFnAzd2FkeOyndvFk,10038
|
54
|
+
gr_libs/recognizer/graml/graml_recognizer.py,sha256=M-tvipAMn_tiWbM3M74D5zH8yKbPEwR-sKTQy3FZT3E,26058
|
55
|
+
gr_libs/tutorials/draco_panda_tutorial.py,sha256=9_scjcyMjkjw8l6g9E-GKOrFTxsIIndW_J1WKjE6-wo,2146
|
56
|
+
gr_libs/tutorials/draco_parking_tutorial.py,sha256=jjbNzSv5l4EvjydwslNYh51xHoIkNmcjPbi0YL6WAeA,1896
|
57
|
+
gr_libs/tutorials/gcdraco_panda_tutorial.py,sha256=KsYStJPk9vI7PUuJrwBaMcQ5a9GT-00-DGJgqRmYvgs,2230
|
58
|
+
gr_libs/tutorials/gcdraco_parking_tutorial.py,sha256=wvhwIwXw_h_VP4OBdsnv2rn9WTTaXJXA_xZ8mLHxcmg,2053
|
59
|
+
gr_libs/tutorials/graml_minigrid_tutorial.py,sha256=msw19nRKAFUJGZy0JNym1At3Zoe5cGxppt24xcElLTQ,2205
|
60
|
+
gr_libs/tutorials/graml_panda_tutorial.py,sha256=DC0AyiZswc5zOKFd0xTYU72ugaCLlf7xtnOGFsmv7MQ,2140
|
61
|
+
gr_libs/tutorials/graml_parking_tutorial.py,sha256=Qf39bdpF4lgppKlDO3qa1CfswmbubqKBXJlPMn2PfhI,1941
|
62
|
+
gr_libs/tutorials/graml_point_maze_tutorial.py,sha256=L95_2u1SA1aZJS-C4dQdq-97Sv6nFYNve2FAX2p5_Mc,2188
|
63
|
+
gr_libs/tutorials/graql_minigrid_tutorial.py,sha256=HT8kCFNbZXAraIau9wtgC_aW8xg-QNRZB2lcpGm3yWk,1941
|
64
|
+
tests/test_draco.py,sha256=oIeTDgn6pt3RfTC-RPX3Bw5cG4BThxRGH3z8en3TX0M,385
|
65
|
+
tests/test_gcdraco.py,sha256=vV6rp7PkJJk_WpAfRekb197QiMHjXXApqrBiLG9RTwo,308
|
66
|
+
tests/test_graml.py,sha256=amSikMWrGS9BNVSXGNKc1n5tfRl-FfgCsyHYsJtduD4,608
|
67
|
+
tests/test_graql.py,sha256=KxVKx6rcSCbN-PjxR2DFoKcILRUmMDz0dTM5SvJZMXg,154
|
68
|
+
gr_libs-0.2.2.dist-info/METADATA,sha256=0hqzG9XaGJmqfJ36sKLPnlU1lFUqHdOr7if1icu1sV0,12992
|
69
|
+
gr_libs-0.2.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
70
|
+
gr_libs-0.2.2.dist-info/top_level.txt,sha256=Yzc_VSW3gzbVM7ZtlV4r6VXmfAC8WXqGVUgK1r6JcLs,14
|
71
|
+
gr_libs-0.2.2.dist-info/RECORD,,
|
tests/test_draco.py
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
from gr_libs.tutorials.draco_panda_tutorial import run_draco_panda_tutorial
|
2
|
+
from gr_libs.tutorials.draco_parking_tutorial import run_draco_parking_tutorial
|
3
|
+
|
4
|
+
|
5
|
+
def test_draco_panda_tutorial():
|
6
|
+
run_draco_panda_tutorial()
|
7
|
+
|
8
|
+
|
9
|
+
def test_draco_parking_tutorial():
|
10
|
+
run_draco_parking_tutorial()
|
11
|
+
|
12
|
+
if __name__ == "__main__":
|
13
|
+
test_draco_panda_tutorial()
|
14
|
+
test_draco_parking_tutorial()
|
tests/test_gcdraco.py
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
from gr_libs.tutorials.gcdraco_panda_tutorial import run_gcdraco_panda_tutorial
|
2
|
+
from gr_libs.tutorials.gcdraco_parking_tutorial import run_gcdraco_parking_tutorial
|
3
|
+
|
4
|
+
|
5
|
+
def test_gcdraco_panda_tutorial():
|
6
|
+
run_gcdraco_panda_tutorial()
|
7
|
+
|
8
|
+
|
9
|
+
def test_gcdraco_parking_tutorial():
|
10
|
+
run_gcdraco_parking_tutorial()
|
tests/test_graml.py
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
from tutorials.graml_minigrid_tutorial import run_graml_minigrid_tutorial
|
2
|
-
from tutorials.graml_panda_tutorial import run_graml_panda_tutorial
|
3
|
-
from tutorials.graml_parking_tutorial import run_graml_parking_tutorial
|
4
|
-
from tutorials.graml_point_maze_tutorial import run_graml_point_maze_tutorial
|
1
|
+
from gr_libs.tutorials.graml_minigrid_tutorial import run_graml_minigrid_tutorial
|
2
|
+
from gr_libs.tutorials.graml_panda_tutorial import run_graml_panda_tutorial
|
3
|
+
from gr_libs.tutorials.graml_parking_tutorial import run_graml_parking_tutorial
|
4
|
+
from gr_libs.tutorials.graml_point_maze_tutorial import run_graml_point_maze_tutorial
|
5
|
+
|
5
6
|
|
6
7
|
def test_graml_minigrid_tutorial():
|
7
|
-
|
8
|
+
run_graml_minigrid_tutorial()
|
9
|
+
|
8
10
|
|
9
11
|
def test_graml_panda_tutorial():
|
10
|
-
|
12
|
+
run_graml_panda_tutorial()
|
13
|
+
|
11
14
|
|
12
15
|
def test_graml_parking_tutorial():
|
13
|
-
|
16
|
+
run_graml_parking_tutorial()
|
17
|
+
|
14
18
|
|
15
19
|
def test_graml_point_maze_tutorial():
|
16
|
-
|
20
|
+
run_graml_point_maze_tutorial()
|
tests/test_graql.py
CHANGED
@@ -1,277 +0,0 @@
|
|
1
|
-
import copy
|
2
|
-
import sys
|
3
|
-
import matplotlib.pyplot as plt
|
4
|
-
import numpy as np
|
5
|
-
import os
|
6
|
-
import dill
|
7
|
-
from scipy.interpolate import make_interp_spline
|
8
|
-
from scipy.ndimage import gaussian_filter1d
|
9
|
-
from gr_libs.ml.utils.storage import get_experiment_results_path, set_global_storage_configs
|
10
|
-
from scripts.generate_task_specific_statistics_plots import get_figures_dir_path
|
11
|
-
|
12
|
-
def smooth_line(x, y, num_points=300):
|
13
|
-
x_smooth = np.linspace(np.min(x), np.max(x), num_points)
|
14
|
-
spline = make_interp_spline(x, y, k=3) # Cubic spline
|
15
|
-
y_smooth = spline(x_smooth)
|
16
|
-
return x_smooth, y_smooth
|
17
|
-
|
18
|
-
if __name__ == "__main__":
|
19
|
-
|
20
|
-
fragmented_accuracies = {
|
21
|
-
'graml': {
|
22
|
-
'panda': {'gd_agent': {
|
23
|
-
'0.3': [], # every list here should have number of tasks accuracies in it, since we done experiments for L111-L555. remember each accuracy is an average of #goals different tasks.
|
24
|
-
'0.5': [],
|
25
|
-
'0.7': [],
|
26
|
-
'0.9': [],
|
27
|
-
'1' : []
|
28
|
-
},
|
29
|
-
'gc_agent': {
|
30
|
-
'0.3': [],
|
31
|
-
'0.5': [],
|
32
|
-
'0.7': [],
|
33
|
-
'0.9': [],
|
34
|
-
'1' : []
|
35
|
-
}},
|
36
|
-
'minigrid': {'obstacles': {
|
37
|
-
'0.3': [],
|
38
|
-
'0.5': [],
|
39
|
-
'0.7': [],
|
40
|
-
'0.9': [],
|
41
|
-
'1' : []
|
42
|
-
},
|
43
|
-
'lava_crossing': {
|
44
|
-
'0.3': [],
|
45
|
-
'0.5': [],
|
46
|
-
'0.7': [],
|
47
|
-
'0.9': [],
|
48
|
-
'1' : []
|
49
|
-
}},
|
50
|
-
'point_maze': {'obstacles': {
|
51
|
-
'0.3': [],
|
52
|
-
'0.5': [],
|
53
|
-
'0.7': [],
|
54
|
-
'0.9': [],
|
55
|
-
'1' : []
|
56
|
-
},
|
57
|
-
'four_rooms': {
|
58
|
-
'0.3': [],
|
59
|
-
'0.5': [],
|
60
|
-
'0.7': [],
|
61
|
-
'0.9': [],
|
62
|
-
'1' : []
|
63
|
-
}},
|
64
|
-
'parking': {'gd_agent': {
|
65
|
-
'0.3': [],
|
66
|
-
'0.5': [],
|
67
|
-
'0.7': [],
|
68
|
-
'0.9': [],
|
69
|
-
'1' : []
|
70
|
-
},
|
71
|
-
'gc_agent': {
|
72
|
-
'0.3': [],
|
73
|
-
'0.5': [],
|
74
|
-
'0.7': [],
|
75
|
-
'0.9': [],
|
76
|
-
'1' : []
|
77
|
-
}},
|
78
|
-
},
|
79
|
-
'graql': {
|
80
|
-
'panda': {'gd_agent': {
|
81
|
-
'0.3': [],
|
82
|
-
'0.5': [],
|
83
|
-
'0.7': [],
|
84
|
-
'0.9': [],
|
85
|
-
'1' : []
|
86
|
-
},
|
87
|
-
'gc_agent': {
|
88
|
-
'0.3': [],
|
89
|
-
'0.5': [],
|
90
|
-
'0.7': [],
|
91
|
-
'0.9': [],
|
92
|
-
'1' : []
|
93
|
-
}},
|
94
|
-
'minigrid': {'obstacles': {
|
95
|
-
'0.3': [],
|
96
|
-
'0.5': [],
|
97
|
-
'0.7': [],
|
98
|
-
'0.9': [],
|
99
|
-
'1' : []
|
100
|
-
},
|
101
|
-
'lava_crossing': {
|
102
|
-
'0.3': [],
|
103
|
-
'0.5': [],
|
104
|
-
'0.7': [],
|
105
|
-
'0.9': [],
|
106
|
-
'1' : []
|
107
|
-
}},
|
108
|
-
'point_maze': {'obstacles': {
|
109
|
-
'0.3': [],
|
110
|
-
'0.5': [],
|
111
|
-
'0.7': [],
|
112
|
-
'0.9': [],
|
113
|
-
'1' : []
|
114
|
-
},
|
115
|
-
'four_rooms': {
|
116
|
-
'0.3': [],
|
117
|
-
'0.5': [],
|
118
|
-
'0.7': [],
|
119
|
-
'0.9': [],
|
120
|
-
'1' : []
|
121
|
-
}},
|
122
|
-
'parking': {'gd_agent': {
|
123
|
-
'0.3': [],
|
124
|
-
'0.5': [],
|
125
|
-
'0.7': [],
|
126
|
-
'0.9': [],
|
127
|
-
'1' : []
|
128
|
-
},
|
129
|
-
'gc_agent': {
|
130
|
-
'0.3': [],
|
131
|
-
'0.5': [],
|
132
|
-
'0.7': [],
|
133
|
-
'0.9': [],
|
134
|
-
'1' : []
|
135
|
-
}},
|
136
|
-
}
|
137
|
-
}
|
138
|
-
|
139
|
-
continuing_accuracies = copy.deepcopy(fragmented_accuracies)
|
140
|
-
|
141
|
-
#domains = ['panda', 'minigrid', 'point_maze', 'parking']
|
142
|
-
domains = ['minigrid', 'point_maze', 'parking']
|
143
|
-
tasks = ['L111', 'L222', 'L333', 'L444', 'L555']
|
144
|
-
percentages = ['0.3', '0.5', '1']
|
145
|
-
|
146
|
-
for partial_obs_type, accuracies, is_same_learn in zip(['fragmented', 'continuing'], [fragmented_accuracies, continuing_accuracies], [False, True]):
|
147
|
-
for domain in domains:
|
148
|
-
for env in accuracies['graml'][domain].keys():
|
149
|
-
for task in tasks:
|
150
|
-
set_global_storage_configs(recognizer_str='graml', is_fragmented=partial_obs_type,
|
151
|
-
is_inference_same_length_sequences=True, is_learn_same_length_sequences=is_same_learn)
|
152
|
-
graml_res_file_path = f'{get_experiment_results_path(domain, env, task)}.pkl'
|
153
|
-
set_global_storage_configs(recognizer_str='graql', is_fragmented=partial_obs_type)
|
154
|
-
graql_res_file_path = f'{get_experiment_results_path(domain, env, task)}.pkl'
|
155
|
-
if os.path.exists(graml_res_file_path):
|
156
|
-
with open(graml_res_file_path, 'rb') as results_file:
|
157
|
-
results = dill.load(results_file)
|
158
|
-
for percentage in accuracies['graml'][domain][env].keys():
|
159
|
-
accuracies['graml'][domain][env][percentage].append(results[percentage]['accuracy'])
|
160
|
-
else:
|
161
|
-
assert(False, f"no file for {graml_res_file_path}")
|
162
|
-
if os.path.exists(graql_res_file_path):
|
163
|
-
with open(graql_res_file_path, 'rb') as results_file:
|
164
|
-
results = dill.load(results_file)
|
165
|
-
for percentage in accuracies['graml'][domain][env].keys():
|
166
|
-
accuracies['graql'][domain][env][percentage].append(results[percentage]['accuracy'])
|
167
|
-
else:
|
168
|
-
assert(False, f"no file for {graql_res_file_path}")
|
169
|
-
|
170
|
-
plot_styles = {
|
171
|
-
('graml', 'fragmented', 0.3): 'g--o', # Green dashed line with circle markers
|
172
|
-
('graml', 'fragmented', 0.5): 'g--s', # Green dashed line with square markers
|
173
|
-
('graml', 'fragmented', 0.7): 'g--^', # Green dashed line with triangle-up markers
|
174
|
-
('graml', 'fragmented', 0.9): 'g--d', # Green dashed line with diamond markers
|
175
|
-
('graml', 'fragmented', 1.0): 'g--*', # Green dashed line with star markers
|
176
|
-
|
177
|
-
('graml', 'continuing', 0.3): 'g-o', # Green solid line with circle markers
|
178
|
-
('graml', 'continuing', 0.5): 'g-s', # Green solid line with square markers
|
179
|
-
('graml', 'continuing', 0.7): 'g-^', # Green solid line with triangle-up markers
|
180
|
-
('graml', 'continuing', 0.9): 'g-d', # Green solid line with diamond markers
|
181
|
-
('graml', 'continuing', 1.0): 'g-*', # Green solid line with star markers
|
182
|
-
|
183
|
-
('graql', 'fragmented', 0.3): 'b--o', # Blue dashed line with circle markers
|
184
|
-
('graql', 'fragmented', 0.5): 'b--s', # Blue dashed line with square markers
|
185
|
-
('graql', 'fragmented', 0.7): 'b--^', # Blue dashed line with triangle-up markers
|
186
|
-
('graql', 'fragmented', 0.9): 'b--d', # Blue dashed line with diamond markers
|
187
|
-
('graql', 'fragmented', 1.0): 'b--*', # Blue dashed line with star markers
|
188
|
-
|
189
|
-
('graql', 'continuing', 0.3): 'b-o', # Blue solid line with circle markers
|
190
|
-
('graql', 'continuing', 0.5): 'b-s', # Blue solid line with square markers
|
191
|
-
('graql', 'continuing', 0.7): 'b-^', # Blue solid line with triangle-up markers
|
192
|
-
('graql', 'continuing', 0.9): 'b-d', # Blue solid line with diamond markers
|
193
|
-
('graql', 'continuing', 1.0): 'b-*', # Blue solid line with star markers
|
194
|
-
}
|
195
|
-
|
196
|
-
def average_accuracies(accuracies, domain):
|
197
|
-
avg_acc = {algo: {perc: [] for perc in percentages}
|
198
|
-
for algo in ['graml', 'graql']}
|
199
|
-
|
200
|
-
for algo in avg_acc.keys():
|
201
|
-
for perc in percentages:
|
202
|
-
for env in accuracies[algo][domain].keys():
|
203
|
-
env_acc = accuracies[algo][domain][env][perc] # list of 5, averages for L111 to L555.
|
204
|
-
if env_acc:
|
205
|
-
avg_acc[algo][perc].append(np.array(env_acc))
|
206
|
-
|
207
|
-
for algo in avg_acc.keys():
|
208
|
-
for perc in percentages:
|
209
|
-
if avg_acc[algo][perc]:
|
210
|
-
avg_acc[algo][perc] = np.mean(np.array(avg_acc[algo][perc]), axis=0)
|
211
|
-
|
212
|
-
return avg_acc
|
213
|
-
|
214
|
-
def plot_domain_accuracies(ax, fragmented_accuracies, continuing_accuracies, domain, sigma=1, line_width=1.5):
|
215
|
-
fragmented_avg_acc = average_accuracies(fragmented_accuracies, domain)
|
216
|
-
continuing_avg_acc = average_accuracies(continuing_accuracies, domain)
|
217
|
-
|
218
|
-
x_vals = np.arange(1, 6) # Number of goals
|
219
|
-
|
220
|
-
# Create "waves" (shaded regions) for each algorithm
|
221
|
-
for algo in ['graml', 'graql']:
|
222
|
-
fragmented_y_vals_by_percentage = []
|
223
|
-
continuing_y_vals_by_percentage = []
|
224
|
-
|
225
|
-
for perc in percentages:
|
226
|
-
fragmented_y_vals = np.array(fragmented_avg_acc[algo][perc])
|
227
|
-
continuing_y_vals = np.array(continuing_avg_acc[algo][perc])
|
228
|
-
|
229
|
-
# Smooth the trends using Gaussian filtering
|
230
|
-
fragmented_y_smoothed = gaussian_filter1d(fragmented_y_vals, sigma=sigma)
|
231
|
-
continuing_y_smoothed = gaussian_filter1d(continuing_y_vals, sigma=sigma)
|
232
|
-
|
233
|
-
fragmented_y_vals_by_percentage.append(fragmented_y_smoothed)
|
234
|
-
continuing_y_vals_by_percentage.append(continuing_y_smoothed)
|
235
|
-
|
236
|
-
ax.plot(
|
237
|
-
x_vals, fragmented_y_smoothed,
|
238
|
-
plot_styles[(algo, 'fragmented', float(perc))],
|
239
|
-
label=f"{algo}, non-consecutive, {perc}",
|
240
|
-
linewidth=0.5 # Control line thickness here
|
241
|
-
)
|
242
|
-
ax.plot(
|
243
|
-
x_vals, continuing_y_smoothed,
|
244
|
-
plot_styles[(algo, 'continuing', float(perc))],
|
245
|
-
label=f"{algo}, consecutive, {perc}",
|
246
|
-
linewidth=0.5 # Control line thickness here
|
247
|
-
)
|
248
|
-
|
249
|
-
ax.set_xticks(x_vals)
|
250
|
-
ax.set_yticks(np.linspace(0, 1, 6))
|
251
|
-
ax.set_ylim([0, 1])
|
252
|
-
ax.set_title(f'{domain.capitalize()} Domain', fontsize=16)
|
253
|
-
ax.grid(True)
|
254
|
-
|
255
|
-
fig, axes = plt.subplots(1, 4, figsize=(24, 6)) # Increase the figure size for better spacing (width 24, height 6)
|
256
|
-
|
257
|
-
# Generate each plot in a subplot, including both fragmented and continuing accuracies
|
258
|
-
for i, domain in enumerate(domains):
|
259
|
-
plot_domain_accuracies(axes[i], fragmented_accuracies, continuing_accuracies, domain)
|
260
|
-
|
261
|
-
# Set a single x-axis and y-axis label for the entire figure
|
262
|
-
fig.text(0.5, 0.04, 'Number of Goals', ha='center', fontsize=20) # Centered x-axis label
|
263
|
-
fig.text(0.04, 0.5, 'Accuracy', va='center', rotation='vertical', fontsize=20) # Reduced spacing for y-axis label
|
264
|
-
|
265
|
-
# Adjust subplot layout to avoid overlap
|
266
|
-
plt.subplots_adjust(left=0.09, right=0.91, top=0.79, bottom=0.21, wspace=0.3) # More space on top (top=0.82)
|
267
|
-
|
268
|
-
# Place the legend above the plots with more space between legend and plots
|
269
|
-
handles, labels = axes[0].get_legend_handles_labels()
|
270
|
-
fig.legend(handles, labels, loc='upper center', ncol=4, bbox_to_anchor=(0.5, 1.05), fontsize=12) # Moved above with bbox_to_anchor
|
271
|
-
|
272
|
-
# Save the figure and show it
|
273
|
-
save_dir = os.path.join('figures', 'all_domains_accuracy_plots')
|
274
|
-
if not os.path.exists(save_dir):
|
275
|
-
os.makedirs(save_dir)
|
276
|
-
plt.savefig(os.path.join(save_dir, 'accuracy_plots_smooth.png'), dpi=300)
|
277
|
-
|
@@ -1,34 +0,0 @@
|
|
1
|
-
from minigrid.wrappers import RGBImgPartialObsWrapper, ImgObsWrapper
|
2
|
-
import numpy as np
|
3
|
-
import gr_libs.ml as ml
|
4
|
-
from minigrid.core.world_object import Wall
|
5
|
-
#from q_table_plot import save_q_table_plot_image
|
6
|
-
from gymnasium.envs.registration import register
|
7
|
-
|
8
|
-
env_name = "MiniGrid-SimpleCrossingS13N4-DynamicGoal-5x9-v0"
|
9
|
-
# create an agent and train it (if it is already trained, it will get q-table from cache)
|
10
|
-
agent = ml.TabularQLearner(env_name='MiniGrid-Walls-13x13-v0',problem_name = "MiniGrid-SimpleCrossingS13N4-DynamicGoal-5x9-v0")
|
11
|
-
# agent.learn()
|
12
|
-
|
13
|
-
# save_q_table_plot_image(agent.q_table, 15, 15, (10,7))
|
14
|
-
|
15
|
-
# add to the steps list the step the trained agent would take on the env in every state according to the q_table
|
16
|
-
env = agent.env
|
17
|
-
env = RGBImgPartialObsWrapper(env) # Get pixel observations
|
18
|
-
env = ImgObsWrapper(env) # Get rid of the 'mission' field
|
19
|
-
obs, _ = env.reset() # This now produces an RGB tensor only
|
20
|
-
|
21
|
-
img = env.get_frame()
|
22
|
-
|
23
|
-
####### save image to file
|
24
|
-
from PIL import Image
|
25
|
-
import numpy as np
|
26
|
-
|
27
|
-
image_pil = Image.fromarray(np.uint8(img)).convert('RGB')
|
28
|
-
image_pil.save(r"{}.png".format(env_name))
|
29
|
-
|
30
|
-
# ####### show image
|
31
|
-
# from gym_minigrid.window import Window
|
32
|
-
# window = Window(r"z")
|
33
|
-
# window.show_img(img=img)
|
34
|
-
# window.close()
|
evaluation/file_system.py
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import dill
|
3
|
-
import random
|
4
|
-
import hashlib
|
5
|
-
from typing import List
|
6
|
-
|
7
|
-
def get_observations_path(env_name: str):
|
8
|
-
return f"dataset/{env_name}/observations"
|
9
|
-
|
10
|
-
def get_observations_paths(path: str):
|
11
|
-
return [os.path.join(path, file_name) for file_name in os.listdir(path)]
|
12
|
-
|
13
|
-
def create_partial_observabilities_files(env_name: str, observabilities: List[float]):
|
14
|
-
with open(r"dataset/{env_name}/observations/obs1.0.pkl".format(env_name=env_name), "rb") as f:
|
15
|
-
step_1_0 = dill.load(f)
|
16
|
-
|
17
|
-
number_of_items_to_randomize = [int(observability * len(step_1_0)) for observability in observabilities]
|
18
|
-
obs = []
|
19
|
-
for items_to_randomize in number_of_items_to_randomize:
|
20
|
-
obs.append(random.sample(step_1_0, items_to_randomize))
|
21
|
-
for index, observability in enumerate(observabilities):
|
22
|
-
partial_steps = obs[index]
|
23
|
-
file_path = r"dataset/{env_name}/observations/obs{obs}.pkl".format(env_name=env_name, obs=observability)
|
24
|
-
with open(file_path, "wb+") as f:
|
25
|
-
dill.dump(partial_steps, f)
|
26
|
-
|
27
|
-
def md5(file_path: str):
|
28
|
-
hash_md5 = hashlib.md5()
|
29
|
-
with open(file_path, "rb") as f:
|
30
|
-
for chunk in iter(lambda: f.read(4096), b""):
|
31
|
-
hash_md5.update(chunk)
|
32
|
-
return hash_md5.hexdigest()
|
33
|
-
|
34
|
-
def get_md5(file_path_list: List[str]):
|
35
|
-
return [(file_path, md5(file_path=file_path)) for file_path in file_path_list]
|
36
|
-
|
37
|
-
|
38
|
-
def print_md5(file_path_list: List[str]):
|
39
|
-
md5_of_observations = get_md5(file_path_list=file_path_list)
|
40
|
-
for file_name, file_md5 in md5_of_observations:
|
41
|
-
print(f"{file_name}:{file_md5}")
|
42
|
-
print("")
|