gr-libs 0.1.8__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 +3 -1
- gr_libs/_evaluation/__init__.py +1 -0
- evaluation/analyze_results_cross_alg_cross_domain.py → gr_libs/_evaluation/_analyze_results_cross_alg_cross_domain.py +81 -88
- evaluation/generate_experiments_results.py → gr_libs/_evaluation/_generate_experiments_results.py +6 -6
- evaluation/generate_task_specific_statistics_plots.py → gr_libs/_evaluation/_generate_task_specific_statistics_plots.py +11 -14
- evaluation/get_plans_images.py → gr_libs/_evaluation/_get_plans_images.py +3 -4
- evaluation/increasing_and_decreasing_.py → gr_libs/_evaluation/_increasing_and_decreasing_.py +3 -1
- gr_libs/_version.py +2 -2
- gr_libs/all_experiments.py +294 -0
- gr_libs/environment/__init__.py +14 -1
- gr_libs/environment/{utils → _utils}/utils.py +1 -1
- gr_libs/environment/environment.py +257 -22
- gr_libs/metrics/__init__.py +2 -0
- gr_libs/metrics/metrics.py +166 -31
- gr_libs/ml/__init__.py +1 -6
- gr_libs/ml/base/__init__.py +3 -1
- gr_libs/ml/base/rl_agent.py +68 -3
- gr_libs/ml/neural/__init__.py +1 -3
- gr_libs/ml/neural/deep_rl_learner.py +227 -67
- gr_libs/ml/neural/utils/__init__.py +1 -2
- gr_libs/ml/planner/mcts/{utils → _utils}/tree.py +1 -1
- gr_libs/ml/planner/mcts/mcts_model.py +71 -34
- gr_libs/ml/sequential/__init__.py +0 -1
- gr_libs/ml/sequential/{lstm_model.py → _lstm_model.py} +11 -14
- gr_libs/ml/tabular/__init__.py +1 -3
- gr_libs/ml/tabular/tabular_q_learner.py +27 -9
- gr_libs/ml/tabular/tabular_rl_agent.py +22 -9
- gr_libs/ml/utils/__init__.py +2 -9
- gr_libs/ml/utils/format.py +13 -90
- gr_libs/ml/utils/math.py +3 -2
- gr_libs/ml/utils/other.py +2 -2
- gr_libs/ml/utils/storage.py +41 -94
- gr_libs/odgr_executor.py +268 -0
- gr_libs/problems/consts.py +2 -2
- gr_libs/recognizer/_utils/__init__.py +0 -0
- gr_libs/recognizer/{utils → _utils}/format.py +2 -2
- gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +116 -36
- gr_libs/recognizer/graml/{gr_dataset.py → _gr_dataset.py} +11 -11
- gr_libs/recognizer/graml/graml_recognizer.py +172 -29
- gr_libs/recognizer/recognizer.py +59 -10
- gr_libs/tutorials/draco_panda_tutorial.py +58 -0
- gr_libs/tutorials/draco_parking_tutorial.py +56 -0
- {tutorials → gr_libs/tutorials}/gcdraco_panda_tutorial.py +5 -9
- {tutorials → gr_libs/tutorials}/gcdraco_parking_tutorial.py +3 -7
- {tutorials → gr_libs/tutorials}/graml_minigrid_tutorial.py +2 -2
- {tutorials → gr_libs/tutorials}/graml_panda_tutorial.py +5 -10
- {tutorials → gr_libs/tutorials}/graml_parking_tutorial.py +5 -9
- {tutorials → gr_libs/tutorials}/graml_point_maze_tutorial.py +2 -1
- {tutorials → gr_libs/tutorials}/graql_minigrid_tutorial.py +2 -2
- {gr_libs-0.1.8.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.8.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 +2 -2
- tests/test_graml.py +4 -4
- tests/test_graql.py +1 -1
- evaluation/create_minigrid_map_image.py +0 -38
- evaluation/file_system.py +0 -53
- evaluation/generate_experiments_results_new_ver1.py +0 -238
- evaluation/generate_experiments_results_new_ver2.py +0 -331
- gr_libs/ml/neural/utils/penv.py +0 -60
- gr_libs/recognizer/utils/__init__.py +0 -1
- gr_libs-0.1.8.dist-info/RECORD +0 -70
- gr_libs-0.1.8.dist-info/top_level.txt +0 -4
- /gr_libs/environment/{utils → _utils}/__init__.py +0 -0
- /gr_libs/ml/planner/mcts/{utils → _utils}/__init__.py +0 -0
- /gr_libs/ml/planner/mcts/{utils → _utils}/node.py +0 -0
gr_libs/recognizer/recognizer.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
|
-
|
3
|
-
from gr_libs.environment.
|
4
|
-
from gr_libs.environment.
|
2
|
+
|
3
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
4
|
+
from gr_libs.environment.environment import SUPPORTED_DOMAINS
|
5
5
|
from gr_libs.ml.base.rl_agent import RLAgent
|
6
6
|
|
7
7
|
|
@@ -11,7 +11,7 @@ class Recognizer(ABC):
|
|
11
11
|
domain_name: str,
|
12
12
|
env_name: str,
|
13
13
|
collect_statistics=False,
|
14
|
-
rl_agent_type:
|
14
|
+
rl_agent_type: type[RLAgent] = None,
|
15
15
|
**kwargs,
|
16
16
|
):
|
17
17
|
assert domain_name in SUPPORTED_DOMAINS
|
@@ -27,30 +27,79 @@ class Recognizer(ABC):
|
|
27
27
|
|
28
28
|
|
29
29
|
class LearningRecognizer(Recognizer):
|
30
|
+
"""
|
31
|
+
A class that represents a learning recognizer.
|
32
|
+
|
33
|
+
Inherits from the Recognizer class.
|
34
|
+
"""
|
35
|
+
|
30
36
|
def __init__(self, *args, **kwargs):
|
31
37
|
super().__init__(*args, **kwargs)
|
32
38
|
|
33
|
-
def domain_learning_phase(self, base_goals:
|
39
|
+
def domain_learning_phase(self, base_goals: list[str], train_configs: list):
|
40
|
+
"""
|
41
|
+
Perform the domain learning phase.
|
42
|
+
|
43
|
+
Args:
|
44
|
+
base_goals (List[str]): The base goals for the learning phase.
|
45
|
+
train_configs (List): The training configurations.
|
46
|
+
|
47
|
+
"""
|
34
48
|
self.original_train_configs = train_configs
|
35
49
|
|
36
50
|
|
37
51
|
# a recognizer that needs to train agents for every new goal as part of the goal adaptation phase (that's why it needs dynamic train configs)
|
38
52
|
class GaAgentTrainerRecognizer(Recognizer):
|
53
|
+
"""
|
54
|
+
A class representing a recognizer for GaAgentTrainer.
|
55
|
+
"""
|
56
|
+
|
39
57
|
def __init__(self, *args, **kwargs):
|
40
58
|
super().__init__(*args, **kwargs)
|
41
59
|
|
42
60
|
@abstractmethod
|
43
|
-
def goals_adaptation_phase(self, dynamic_goals:
|
44
|
-
|
61
|
+
def goals_adaptation_phase(self, dynamic_goals: list[str], dynamic_train_configs):
|
62
|
+
"""
|
63
|
+
Perform the goals adaptation phase.
|
64
|
+
|
65
|
+
Args:
|
66
|
+
dynamic_goals (List[str]): The list of dynamic goals.
|
67
|
+
dynamic_train_configs: The dynamic training configurations.
|
45
68
|
|
46
|
-
|
69
|
+
Returns:
|
70
|
+
None
|
71
|
+
"""
|
72
|
+
|
73
|
+
def domain_learning_phase(self, base_goals: list[str], train_configs: list):
|
74
|
+
"""
|
75
|
+
Perform the domain learning phase.
|
76
|
+
|
77
|
+
Args:
|
78
|
+
base_goals (List[str]): List of base goals.
|
79
|
+
train_configs (List): List of training configurations.
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
None
|
83
|
+
"""
|
47
84
|
super().domain_learning_phase(base_goals, train_configs)
|
48
85
|
|
49
86
|
|
50
87
|
class GaAdaptingRecognizer(Recognizer):
|
88
|
+
"""
|
89
|
+
A recognizer that doesn't require more training given a set of new goals, hence it doesn't receive train configs in the goal adaptation phase.
|
90
|
+
"""
|
91
|
+
|
51
92
|
def __init__(self, *args, **kwargs):
|
52
93
|
super().__init__(*args, **kwargs)
|
53
94
|
|
54
95
|
@abstractmethod
|
55
|
-
def goals_adaptation_phase(self, dynamic_goals:
|
56
|
-
|
96
|
+
def goals_adaptation_phase(self, dynamic_goals: list[str]):
|
97
|
+
"""
|
98
|
+
Perform the goals adaptation phase.
|
99
|
+
|
100
|
+
Args:
|
101
|
+
dynamic_goals (List[str]): A list of dynamic goals to be adapted.
|
102
|
+
|
103
|
+
Returns:
|
104
|
+
None
|
105
|
+
"""
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import numpy as np
|
2
|
+
from stable_baselines3 import PPO
|
3
|
+
|
4
|
+
from gr_libs import Draco
|
5
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
6
|
+
from gr_libs.environment.environment import PANDA
|
7
|
+
from gr_libs.metrics import mean_wasserstein_distance
|
8
|
+
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
9
|
+
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
10
|
+
from gr_libs.ml.utils.format import random_subset_with_order
|
11
|
+
|
12
|
+
|
13
|
+
def run_draco_panda_tutorial():
|
14
|
+
recognizer = Draco(
|
15
|
+
domain_name=PANDA,
|
16
|
+
env_name="PandaMyReachDense",
|
17
|
+
evaluation_function=mean_wasserstein_distance, # or mean_p_value
|
18
|
+
)
|
19
|
+
|
20
|
+
recognizer.goals_adaptation_phase(
|
21
|
+
dynamic_goals=[
|
22
|
+
np.array([[-0.1, -0.1, 0.1]]),
|
23
|
+
np.array([[-0.1, 0.1, 0.1]]),
|
24
|
+
np.array([[0.2, 0.2, 0.1]]),
|
25
|
+
],
|
26
|
+
dynamic_train_configs=[(PPO, 200000), (PPO, 200000), (PPO, 200000)],
|
27
|
+
)
|
28
|
+
# TD3 is different from recognizer and expert algorithms, which are SAC #
|
29
|
+
property_type = domain_to_env_property(PANDA)
|
30
|
+
env_property = property_type("PandaMyReachDense")
|
31
|
+
problem_name = env_property.goal_to_problem_str(np.array([[-0.1, -0.1, 0.1]]))
|
32
|
+
actor = DeepRLAgent(
|
33
|
+
domain_name=PANDA,
|
34
|
+
problem_name=problem_name,
|
35
|
+
env_prop=env_property,
|
36
|
+
algorithm=PPO,
|
37
|
+
num_timesteps=400000,
|
38
|
+
)
|
39
|
+
actor.learn()
|
40
|
+
# sample is generated stochastically to simulate suboptimal behavior, noise is added to the actions values #
|
41
|
+
full_sequence = actor.generate_observation(
|
42
|
+
action_selection_method=stochastic_amplified_selection,
|
43
|
+
random_optimalism=True, # the noise that's added to the actions
|
44
|
+
with_dict=True,
|
45
|
+
)
|
46
|
+
partial_sequence = random_subset_with_order(
|
47
|
+
full_sequence, (int)(0.5 * len(full_sequence)), is_consecutive=False
|
48
|
+
)
|
49
|
+
closest_goal = recognizer.inference_phase(
|
50
|
+
partial_sequence, np.array([[-0.1, -0.1, 0.1]]), 0.5
|
51
|
+
)
|
52
|
+
print(
|
53
|
+
f"closest_goal returned by DRACO: {closest_goal}\nactual goal actor aimed towards: [-0.1, -0.1, 0.1]"
|
54
|
+
)
|
55
|
+
|
56
|
+
|
57
|
+
if __name__ == "__main__":
|
58
|
+
run_draco_panda_tutorial()
|
@@ -0,0 +1,56 @@
|
|
1
|
+
from stable_baselines3 import SAC, TD3
|
2
|
+
|
3
|
+
from gr_libs import Draco
|
4
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
5
|
+
from gr_libs.environment.environment import PARKING, ParkingProperty
|
6
|
+
from gr_libs.metrics import mean_wasserstein_distance
|
7
|
+
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
8
|
+
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
9
|
+
from gr_libs.ml.utils.format import random_subset_with_order
|
10
|
+
|
11
|
+
|
12
|
+
def run_draco_parking_tutorial():
|
13
|
+
recognizer = Draco(
|
14
|
+
domain_name=PARKING,
|
15
|
+
env_name="Parking-S-14-PC-",
|
16
|
+
evaluation_function=mean_wasserstein_distance, # or mean_p_value
|
17
|
+
)
|
18
|
+
|
19
|
+
recognizer.goals_adaptation_phase(
|
20
|
+
dynamic_goals=["1", "11", "21"],
|
21
|
+
dynamic_train_configs=[(SAC, 200000), (SAC, 200000), (SAC, 200000)],
|
22
|
+
)
|
23
|
+
|
24
|
+
property_type = domain_to_env_property(PARKING)
|
25
|
+
env_property = property_type("Parking-S-14-PC-")
|
26
|
+
# TD3 is different from recognizer and expert algorithms, which are SAC #
|
27
|
+
actor = DeepRLAgent(
|
28
|
+
domain_name="parking",
|
29
|
+
problem_name="Parking-S-14-PC--GI-11-v0",
|
30
|
+
env_prop=env_property,
|
31
|
+
algorithm=TD3,
|
32
|
+
num_timesteps=400000,
|
33
|
+
)
|
34
|
+
actor.learn()
|
35
|
+
|
36
|
+
full_sequence = actor.generate_observation(
|
37
|
+
action_selection_method=stochastic_amplified_selection,
|
38
|
+
random_optimalism=True, # the noise that's added to the actions
|
39
|
+
with_dict=True,
|
40
|
+
)
|
41
|
+
|
42
|
+
partial_sequence = random_subset_with_order(
|
43
|
+
full_sequence, (int)(0.5 * len(full_sequence)), is_consecutive=False
|
44
|
+
)
|
45
|
+
closest_goal = recognizer.inference_phase(
|
46
|
+
partial_sequence,
|
47
|
+
ParkingProperty("Parking-S-14-PC--GI-11-v0").str_to_goal(),
|
48
|
+
0.5,
|
49
|
+
)
|
50
|
+
print(
|
51
|
+
f"closest_goal returned by GCDRACO: {closest_goal}\nactual goal actor aimed towards: 11"
|
52
|
+
)
|
53
|
+
|
54
|
+
|
55
|
+
if __name__ == "__main__":
|
56
|
+
run_draco_parking_tutorial()
|
@@ -1,16 +1,12 @@
|
|
1
|
+
import numpy as np
|
1
2
|
from stable_baselines3 import PPO, SAC
|
2
|
-
|
3
|
-
stochastic_amplified_selection,
|
4
|
-
mean_p_value,
|
5
|
-
mean_wasserstein_distance,
|
6
|
-
)
|
3
|
+
|
7
4
|
from gr_libs import GCDraco
|
8
|
-
from gr_libs.environment.
|
9
|
-
import numpy as np
|
5
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
10
6
|
from gr_libs.environment.environment import PANDA, PandaProperty
|
7
|
+
from gr_libs.metrics import mean_wasserstein_distance, stochastic_amplified_selection
|
11
8
|
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
12
9
|
from gr_libs.ml.utils.format import random_subset_with_order
|
13
|
-
import gr_envs.panda_scripts
|
14
10
|
|
15
11
|
|
16
12
|
def run_gcdraco_panda_tutorial():
|
@@ -30,7 +26,7 @@ def run_gcdraco_panda_tutorial():
|
|
30
26
|
np.array([[-0.1, -0.1, 0.1]]),
|
31
27
|
np.array([[-0.1, 0.1, 0.1]]),
|
32
28
|
np.array([[0.2, 0.2, 0.1]]),
|
33
|
-
]
|
29
|
+
],
|
34
30
|
)
|
35
31
|
|
36
32
|
# TD3 is different from recognizer and expert algorithms, which are SAC #
|
@@ -1,15 +1,11 @@
|
|
1
1
|
from stable_baselines3 import PPO, TD3
|
2
|
-
|
3
|
-
stochastic_amplified_selection,
|
4
|
-
mean_p_value,
|
5
|
-
mean_wasserstein_distance,
|
6
|
-
)
|
2
|
+
|
7
3
|
from gr_libs import GCDraco
|
8
|
-
from gr_libs.environment.
|
4
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
9
5
|
from gr_libs.environment.environment import PARKING, ParkingProperty
|
6
|
+
from gr_libs.metrics import mean_wasserstein_distance, stochastic_amplified_selection
|
10
7
|
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
11
8
|
from gr_libs.ml.utils.format import random_subset_with_order
|
12
|
-
import gr_envs
|
13
9
|
|
14
10
|
|
15
11
|
def run_gcdraco_parking_tutorial():
|
@@ -1,9 +1,9 @@
|
|
1
|
+
from gr_libs import ExpertBasedGraml
|
2
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
1
3
|
from gr_libs.environment.environment import MINIGRID, QLEARNING
|
2
|
-
from gr_libs.environment.utils.utils import domain_to_env_property
|
3
4
|
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
4
5
|
from gr_libs.ml.tabular.tabular_q_learner import TabularQLearner
|
5
6
|
from gr_libs.ml.utils.format import random_subset_with_order
|
6
|
-
from gr_libs import ExpertBasedGraml
|
7
7
|
|
8
8
|
|
9
9
|
def run_graml_minigrid_tutorial():
|
@@ -1,17 +1,12 @@
|
|
1
1
|
import numpy as np
|
2
2
|
from stable_baselines3 import PPO, SAC
|
3
|
-
|
4
|
-
from gr_libs
|
5
|
-
|
6
|
-
|
7
|
-
GCEnvProperty,
|
8
|
-
PandaProperty,
|
9
|
-
)
|
10
|
-
from gr_libs.environment.utils.utils import domain_to_env_property
|
3
|
+
|
4
|
+
from gr_libs import GCGraml
|
5
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
6
|
+
from gr_libs.environment.environment import PANDA, PandaProperty
|
11
7
|
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
12
|
-
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
8
|
+
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
13
9
|
from gr_libs.ml.utils.format import random_subset_with_order
|
14
|
-
from gr_libs import GCGraml
|
15
10
|
|
16
11
|
|
17
12
|
def run_graml_panda_tutorial():
|
@@ -1,15 +1,11 @@
|
|
1
|
-
from stable_baselines3 import PPO,
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
GCEnvProperty,
|
6
|
-
ParkingProperty,
|
7
|
-
)
|
8
|
-
from gr_libs.environment.utils.utils import domain_to_env_property
|
1
|
+
from stable_baselines3 import PPO, TD3
|
2
|
+
|
3
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
4
|
+
from gr_libs.environment.environment import PARKING, ParkingProperty
|
9
5
|
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
10
6
|
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
11
7
|
from gr_libs.ml.utils.format import random_subset_with_order
|
12
|
-
from gr_libs.recognizer.graml.graml_recognizer import
|
8
|
+
from gr_libs.recognizer.graml.graml_recognizer import GCGraml
|
13
9
|
|
14
10
|
|
15
11
|
def run_graml_parking_tutorial():
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from stable_baselines3 import SAC, TD3
|
2
|
+
|
3
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
2
4
|
from gr_libs.environment.environment import POINT_MAZE, PointMazeProperty
|
3
|
-
from gr_libs.environment.utils.utils import domain_to_env_property
|
4
5
|
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
5
6
|
from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
|
6
7
|
from gr_libs.ml.utils.format import random_subset_with_order
|
@@ -1,9 +1,9 @@
|
|
1
|
+
from gr_libs import Graql
|
2
|
+
from gr_libs.environment._utils.utils import domain_to_env_property
|
1
3
|
from gr_libs.environment.environment import MINIGRID, QLEARNING
|
2
|
-
from gr_libs.environment.utils.utils import domain_to_env_property
|
3
4
|
from gr_libs.metrics.metrics import stochastic_amplified_selection
|
4
5
|
from gr_libs.ml.tabular.tabular_q_learner import TabularQLearner
|
5
6
|
from gr_libs.ml.utils.format import random_subset_with_order
|
6
|
-
from gr_libs import Graql
|
7
7
|
|
8
8
|
|
9
9
|
def run_graql_minigrid_tutorial():
|
@@ -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
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
from tutorials.gcdraco_panda_tutorial import run_gcdraco_panda_tutorial
|
2
|
-
from tutorials.gcdraco_parking_tutorial import run_gcdraco_parking_tutorial
|
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
3
|
|
4
4
|
|
5
5
|
def test_gcdraco_panda_tutorial():
|
tests/test_graml.py
CHANGED
@@ -1,7 +1,7 @@
|
|
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
7
|
def test_graml_minigrid_tutorial():
|
tests/test_graql.py
CHANGED