gr-libs 0.1.7.post0__tar.gz → 0.2.2__tar.gz
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-0.1.7.post0 → gr_libs-0.2.2}/PKG-INFO +84 -29
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/README.md +83 -28
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/__init__.py +4 -1
- gr_libs-0.2.2/gr_libs/_evaluation/__init__.py +1 -0
- gr_libs-0.2.2/gr_libs/_evaluation/_analyze_results_cross_alg_cross_domain.py +260 -0
- gr_libs-0.2.2/gr_libs/_evaluation/_generate_experiments_results.py +141 -0
- gr_libs-0.2.2/gr_libs/_evaluation/_generate_task_specific_statistics_plots.py +497 -0
- gr_libs-0.2.2/gr_libs/_evaluation/_get_plans_images.py +61 -0
- gr_libs-0.2.2/gr_libs/_evaluation/_increasing_and_decreasing_.py +106 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/_version.py +2 -2
- gr_libs-0.2.2/gr_libs/all_experiments.py +294 -0
- gr_libs-0.2.2/gr_libs/environment/__init__.py +43 -0
- gr_libs-0.2.2/gr_libs/environment/_utils/utils.py +27 -0
- gr_libs-0.2.2/gr_libs/environment/environment.py +588 -0
- gr_libs-0.2.2/gr_libs/metrics/__init__.py +7 -0
- gr_libs-0.2.2/gr_libs/metrics/metrics.py +400 -0
- gr_libs-0.2.2/gr_libs/ml/__init__.py +3 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/agent.py +21 -6
- gr_libs-0.2.2/gr_libs/ml/base/__init__.py +3 -0
- gr_libs-0.2.2/gr_libs/ml/base/rl_agent.py +122 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/consts.py +1 -1
- gr_libs-0.2.2/gr_libs/ml/neural/__init__.py +1 -0
- gr_libs-0.2.2/gr_libs/ml/neural/deep_rl_learner.py +634 -0
- gr_libs-0.2.2/gr_libs/ml/neural/utils/__init__.py +1 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/neural/utils/dictlist.py +3 -3
- {gr_libs-0.1.7.post0/gr_libs/ml/planner/mcts/utils → gr_libs-0.2.2/gr_libs/ml/planner/mcts/_utils}/__init__.py +1 -1
- {gr_libs-0.1.7.post0/gr_libs/ml/planner/mcts/utils → gr_libs-0.2.2/gr_libs/ml/planner/mcts/_utils}/node.py +11 -7
- {gr_libs-0.1.7.post0/gr_libs/ml/planner/mcts/utils → gr_libs-0.2.2/gr_libs/ml/planner/mcts/_utils}/tree.py +15 -11
- gr_libs-0.2.2/gr_libs/ml/planner/mcts/mcts_model.py +589 -0
- gr_libs-0.2.2/gr_libs/ml/sequential/_lstm_model.py +270 -0
- gr_libs-0.2.2/gr_libs/ml/tabular/__init__.py +1 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/tabular/state.py +7 -7
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/tabular/tabular_q_learner.py +150 -82
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/tabular/tabular_rl_agent.py +42 -28
- gr_libs-0.2.2/gr_libs/ml/utils/__init__.py +5 -0
- gr_libs-0.2.2/gr_libs/ml/utils/format.py +31 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/utils/math.py +5 -3
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/utils/other.py +3 -3
- gr_libs-0.2.2/gr_libs/ml/utils/storage.py +141 -0
- gr_libs-0.2.2/gr_libs/odgr_executor.py +268 -0
- gr_libs-0.2.2/gr_libs/problems/consts.py +1566 -0
- gr_libs-0.2.2/gr_libs/recognizer/_utils/format.py +18 -0
- gr_libs-0.2.2/gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +247 -0
- gr_libs-0.2.2/gr_libs/recognizer/graml/__init__.py +0 -0
- gr_libs-0.2.2/gr_libs/recognizer/graml/_gr_dataset.py +233 -0
- gr_libs-0.2.2/gr_libs/recognizer/graml/graml_recognizer.py +608 -0
- gr_libs-0.2.2/gr_libs/recognizer/recognizer.py +105 -0
- gr_libs-0.2.2/gr_libs/tutorials/draco_panda_tutorial.py +58 -0
- gr_libs-0.2.2/gr_libs/tutorials/draco_parking_tutorial.py +56 -0
- gr_libs-0.2.2/gr_libs/tutorials/gcdraco_panda_tutorial.py +62 -0
- gr_libs-0.2.2/gr_libs/tutorials/gcdraco_parking_tutorial.py +57 -0
- gr_libs-0.2.2/gr_libs/tutorials/graml_minigrid_tutorial.py +64 -0
- gr_libs-0.2.2/gr_libs/tutorials/graml_panda_tutorial.py +57 -0
- gr_libs-0.2.2/gr_libs/tutorials/graml_parking_tutorial.py +52 -0
- gr_libs-0.2.2/gr_libs/tutorials/graml_point_maze_tutorial.py +60 -0
- gr_libs-0.2.2/gr_libs/tutorials/graql_minigrid_tutorial.py +50 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs.egg-info/PKG-INFO +84 -29
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs.egg-info/SOURCES.txt +29 -25
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs.egg-info/top_level.txt +1 -2
- gr_libs-0.2.2/tests/test_draco.py +14 -0
- gr_libs-0.2.2/tests/test_gcdraco.py +10 -0
- gr_libs-0.2.2/tests/test_graml.py +20 -0
- gr_libs-0.2.2/tests/test_graql.py +5 -0
- gr_libs-0.1.7.post0/evaluation/analyze_results_cross_alg_cross_domain.py +0 -277
- gr_libs-0.1.7.post0/evaluation/create_minigrid_map_image.py +0 -34
- gr_libs-0.1.7.post0/evaluation/file_system.py +0 -42
- gr_libs-0.1.7.post0/evaluation/generate_experiments_results.py +0 -92
- gr_libs-0.1.7.post0/evaluation/generate_experiments_results_new_ver1.py +0 -254
- gr_libs-0.1.7.post0/evaluation/generate_experiments_results_new_ver2.py +0 -331
- gr_libs-0.1.7.post0/evaluation/generate_task_specific_statistics_plots.py +0 -272
- gr_libs-0.1.7.post0/evaluation/get_plans_images.py +0 -47
- gr_libs-0.1.7.post0/evaluation/increasing_and_decreasing_.py +0 -63
- gr_libs-0.1.7.post0/gr_libs/environment/__init__.py +0 -22
- gr_libs-0.1.7.post0/gr_libs/environment/environment.py +0 -225
- gr_libs-0.1.7.post0/gr_libs/environment/utils/utils.py +0 -17
- gr_libs-0.1.7.post0/gr_libs/metrics/metrics.py +0 -223
- gr_libs-0.1.7.post0/gr_libs/ml/__init__.py +0 -6
- gr_libs-0.1.7.post0/gr_libs/ml/base/__init__.py +0 -1
- gr_libs-0.1.7.post0/gr_libs/ml/base/rl_agent.py +0 -54
- gr_libs-0.1.7.post0/gr_libs/ml/neural/__init__.py +0 -3
- gr_libs-0.1.7.post0/gr_libs/ml/neural/deep_rl_learner.py +0 -393
- gr_libs-0.1.7.post0/gr_libs/ml/neural/utils/__init__.py +0 -2
- gr_libs-0.1.7.post0/gr_libs/ml/neural/utils/penv.py +0 -57
- gr_libs-0.1.7.post0/gr_libs/ml/planner/mcts/mcts_model.py +0 -330
- gr_libs-0.1.7.post0/gr_libs/ml/sequential/__init__.py +0 -1
- gr_libs-0.1.7.post0/gr_libs/ml/sequential/lstm_model.py +0 -192
- gr_libs-0.1.7.post0/gr_libs/ml/tabular/__init__.py +0 -3
- gr_libs-0.1.7.post0/gr_libs/ml/utils/__init__.py +0 -6
- gr_libs-0.1.7.post0/gr_libs/ml/utils/format.py +0 -100
- gr_libs-0.1.7.post0/gr_libs/ml/utils/storage.py +0 -134
- gr_libs-0.1.7.post0/gr_libs/problems/consts.py +0 -1244
- gr_libs-0.1.7.post0/gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +0 -102
- gr_libs-0.1.7.post0/gr_libs/recognizer/graml/gr_dataset.py +0 -134
- gr_libs-0.1.7.post0/gr_libs/recognizer/graml/graml_recognizer.py +0 -274
- gr_libs-0.1.7.post0/gr_libs/recognizer/recognizer.py +0 -45
- gr_libs-0.1.7.post0/gr_libs/recognizer/utils/__init__.py +0 -1
- gr_libs-0.1.7.post0/gr_libs/recognizer/utils/format.py +0 -13
- gr_libs-0.1.7.post0/tests/test_graml.py +0 -16
- gr_libs-0.1.7.post0/tests/test_graql.py +0 -4
- gr_libs-0.1.7.post0/tutorials/graml_minigrid_tutorial.py +0 -34
- gr_libs-0.1.7.post0/tutorials/graml_panda_tutorial.py +0 -41
- gr_libs-0.1.7.post0/tutorials/graml_parking_tutorial.py +0 -39
- gr_libs-0.1.7.post0/tutorials/graml_point_maze_tutorial.py +0 -39
- gr_libs-0.1.7.post0/tutorials/graql_minigrid_tutorial.py +0 -34
- {gr_libs-0.1.7.post0/gr_libs/environment/utils → gr_libs-0.2.2/gr_libs/environment/_utils}/__init__.py +0 -0
- {gr_libs-0.1.7.post0/gr_libs/metrics → gr_libs-0.2.2/gr_libs/ml/planner}/__init__.py +0 -0
- {gr_libs-0.1.7.post0/gr_libs/ml/planner → gr_libs-0.2.2/gr_libs/ml/planner/mcts}/__init__.py +0 -0
- {gr_libs-0.1.7.post0/gr_libs/ml/planner/mcts → gr_libs-0.2.2/gr_libs/ml/sequential}/__init__.py +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/ml/utils/env.py +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/problems/__init__.py +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs/recognizer/__init__.py +0 -0
- {gr_libs-0.1.7.post0/gr_libs/recognizer/gr_as_rl → gr_libs-0.2.2/gr_libs/recognizer/_utils}/__init__.py +0 -0
- {gr_libs-0.1.7.post0/gr_libs/recognizer/graml → gr_libs-0.2.2/gr_libs/recognizer/gr_as_rl}/__init__.py +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs.egg-info/dependency_links.txt +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/gr_libs.egg-info/requires.txt +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/pyproject.toml +0 -0
- {gr_libs-0.1.7.post0 → gr_libs-0.2.2}/setup.cfg +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
|
+
```
|
@@ -77,6 +77,25 @@ If you prefer using Conda, follow these steps:
|
|
77
77
|
|
78
78
|
For any issues or troubleshooting, please refer to the repository's issue tracker.
|
79
79
|
|
80
|
+
## Supported Algorithms
|
81
|
+
|
82
|
+
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).
|
83
|
+
|
84
|
+
| **Algorithm** | **Supervised** | **Reinforcement Learning** | **Discrete States** | **Continuous States** | **Discrete Actions** | **Continuous Actions** | **Model-Based** | **Model-Free** | **Action-Only** |
|
85
|
+
|--------------|--------------|------------------------|------------------|------------------|--------------|--------------|--------------|--------------|--------------|
|
86
|
+
| GRAQL | ❌ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ |
|
87
|
+
| DRACO (GC) | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
|
88
|
+
| GRAML (GC, BG) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ |
|
89
|
+
|
90
|
+
## Supported Domains
|
91
|
+
|
92
|
+
| **Domain** | **Action Space** | **State Space** |
|
93
|
+
|------------|----------------|----------------|
|
94
|
+
| Minigrid | Discrete | Discrete |
|
95
|
+
| PointMaze | Continuous | Continuous |
|
96
|
+
| Parking | Continuous | Continuous |
|
97
|
+
| Panda | Continuous | Continuous |
|
98
|
+
|
80
99
|
## Usage Guide
|
81
100
|
|
82
101
|
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.
|
@@ -87,9 +106,10 @@ Tutorials demonstrating basic ODGR scenarios is available in the sub-package `tu
|
|
87
106
|
gr_libs also includes a library of trained agents for the various supported environments within the package.
|
88
107
|
To get the dataset of trained agents, you can run:
|
89
108
|
```sh
|
109
|
+
pip install gdown
|
90
110
|
python download_dataset.py
|
91
111
|
```
|
92
|
-
|
112
|
+
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.
|
93
113
|
An alternative is to use our docker image, which includes the dataset in it.
|
94
114
|
You can:
|
95
115
|
1. pull the image:
|
@@ -162,42 +182,77 @@ docker run -it ghcr.io/MatanShamir1/gr_test_base:latest bash
|
|
162
182
|
|
163
183
|
The `consts.py` file contains predefined ODGR problem configurations. You can use existing configurations or define new ones.
|
164
184
|
|
165
|
-
To execute
|
185
|
+
To execute an ODGR problem using the configuration file, you specify a recognizer, a domain, a gym environment within that domain and the task:
|
166
186
|
```sh
|
167
|
-
python odgr_executor.py --recognizer
|
187
|
+
python odgr_executor.py --recognizer ExpertBasedGraml --domain minigrid --task L1 --env_name MiniGrid-SimpleCrossingS13N4
|
168
188
|
```
|
169
189
|
|
170
|
-
|
190
|
+
If you also add the flag:
|
191
|
+
```sh
|
192
|
+
--collect_stats
|
193
|
+
```
|
194
|
+
to the cmd, 3 kinds of outputs will be generated from the ODGR problem's execution:
|
195
|
+
a. Into:
|
196
|
+
```sh
|
197
|
+
outputs\\minigrid\MiniGrid-SimpleCrossingS13N4\MiniGrid-SimpleCrossingS13N4\L1\experiment_results
|
198
|
+
```
|
199
|
+
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.
|
171
200
|
|
172
|
-
|
201
|
+
b. Into:
|
202
|
+
```sh
|
203
|
+
outputs\ExpertBasedGraml\minigrid\MiniGrid-SimpleCrossingS13N4\policy_sequences\MiniGrid-SimpleCrossingS13N4-DynamicGoal-1x11-v0_inference_seq/plan_image.png
|
204
|
+
```
|
205
|
+
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.
|
173
206
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
207
|
+
c. Into:
|
208
|
+
either:
|
209
|
+
```sh
|
210
|
+
outputs\ExpertBasedGraml\minigrid\MiniGrid-SimpleCrossingS13N4\goal_embeddings
|
211
|
+
```
|
212
|
+
In Graml algorithms, or:
|
213
|
+
```sh
|
214
|
+
outputs\Graql\minigrid\MiniGrid-SimpleCrossingS13N4\confidence
|
215
|
+
```
|
216
|
+
In GRAsRL algorithms,
|
217
|
+
pickled results from which confidence of the results can be obtained, for offline analysis.
|
179
218
|
|
180
|
-
|
219
|
+
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.
|
181
220
|
|
182
|
-
|
183
|
-
|------------|----------------|----------------|
|
184
|
-
| Minigrid | Discrete | Discrete |
|
185
|
-
| PointMaze | Continuous | Continuous |
|
186
|
-
| Parking | Continuous | Continuous |
|
187
|
-
| Panda | Continuous | Continuous |
|
221
|
+
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.
|
188
222
|
|
189
223
|
## Running Experiments
|
190
224
|
|
191
|
-
|
225
|
+
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.
|
226
|
+
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.
|
227
|
+
|
228
|
+
### Scaling odgr_executor runs
|
229
|
+
A part of the contribution of this package is standardizing the evaluations of MDP-based GR frameworks.
|
230
|
+
consts.py provides a set of ODGR problems on which the framework can be evaluated.
|
231
|
+
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.
|
192
232
|
|
193
|
-
|
194
|
-
|
195
|
-
- Reads data from `get_experiment_results_path` (e.g., `dataset/graml/minigrid/continuing/.../experiment_results.pkl`).
|
196
|
-
- Generates plots comparing algorithm performance across domains.
|
233
|
+
In order to parallelize executions of odgr_executor.py, you can edit all_experiments.py with your combination of domains, environments and tasks.
|
234
|
+
This script use multiprocessing to simultaniously execute many odgr_executor.py python executions as child processes.
|
197
235
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
236
|
+
It logs failures and successful executions for debugability.
|
237
|
+
|
238
|
+
After execution, another level of abstraction for the results is created. For example, when running for Graql in the minigrid domain:
|
239
|
+
```sh
|
240
|
+
outputs\summaries\detailed_summary_minigrid_Graql.txt
|
241
|
+
```
|
242
|
+
Will show the accuracies for every ODGR problem, for every percentage and type of input in a table-like .txt format, whike:
|
243
|
+
```sh
|
244
|
+
outputs\summaries\compiled_summary_minigrid_Graql.txt
|
245
|
+
```
|
246
|
+
Will show the same results in a more compact summary.
|
247
|
+
|
248
|
+
### Using analysis scripts
|
249
|
+
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.
|
250
|
+
Please follow the README.md file in the 'evaluation' directory for more details.
|
251
|
+
|
252
|
+
## For Developers
|
253
|
+
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.
|
254
|
+
Additional packages to install as a developer:
|
255
|
+
```sh
|
256
|
+
pip install pre-commit
|
257
|
+
pre-commit install
|
258
|
+
```
|
@@ -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)
|