gr-libs 0.1.7.post0__py3-none-any.whl → 0.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. evaluation/analyze_results_cross_alg_cross_domain.py +236 -246
  2. evaluation/create_minigrid_map_image.py +10 -6
  3. evaluation/file_system.py +16 -5
  4. evaluation/generate_experiments_results.py +123 -74
  5. evaluation/generate_experiments_results_new_ver1.py +227 -243
  6. evaluation/generate_experiments_results_new_ver2.py +317 -317
  7. evaluation/generate_task_specific_statistics_plots.py +481 -253
  8. evaluation/get_plans_images.py +41 -26
  9. evaluation/increasing_and_decreasing_.py +97 -56
  10. gr_libs/__init__.py +2 -1
  11. gr_libs/_version.py +2 -2
  12. gr_libs/environment/__init__.py +16 -8
  13. gr_libs/environment/environment.py +167 -39
  14. gr_libs/environment/utils/utils.py +22 -12
  15. gr_libs/metrics/__init__.py +5 -0
  16. gr_libs/metrics/metrics.py +76 -34
  17. gr_libs/ml/__init__.py +2 -0
  18. gr_libs/ml/agent.py +21 -6
  19. gr_libs/ml/base/__init__.py +1 -1
  20. gr_libs/ml/base/rl_agent.py +13 -10
  21. gr_libs/ml/consts.py +1 -1
  22. gr_libs/ml/neural/deep_rl_learner.py +433 -352
  23. gr_libs/ml/neural/utils/__init__.py +1 -1
  24. gr_libs/ml/neural/utils/dictlist.py +3 -3
  25. gr_libs/ml/neural/utils/penv.py +5 -2
  26. gr_libs/ml/planner/mcts/mcts_model.py +524 -302
  27. gr_libs/ml/planner/mcts/utils/__init__.py +1 -1
  28. gr_libs/ml/planner/mcts/utils/node.py +11 -7
  29. gr_libs/ml/planner/mcts/utils/tree.py +14 -10
  30. gr_libs/ml/sequential/__init__.py +1 -1
  31. gr_libs/ml/sequential/lstm_model.py +256 -175
  32. gr_libs/ml/tabular/state.py +7 -7
  33. gr_libs/ml/tabular/tabular_q_learner.py +123 -73
  34. gr_libs/ml/tabular/tabular_rl_agent.py +20 -19
  35. gr_libs/ml/utils/__init__.py +8 -2
  36. gr_libs/ml/utils/format.py +78 -70
  37. gr_libs/ml/utils/math.py +2 -1
  38. gr_libs/ml/utils/other.py +1 -1
  39. gr_libs/ml/utils/storage.py +88 -28
  40. gr_libs/problems/consts.py +1549 -1227
  41. gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +145 -80
  42. gr_libs/recognizer/graml/gr_dataset.py +209 -110
  43. gr_libs/recognizer/graml/graml_recognizer.py +431 -240
  44. gr_libs/recognizer/recognizer.py +38 -27
  45. gr_libs/recognizer/utils/__init__.py +1 -1
  46. gr_libs/recognizer/utils/format.py +8 -3
  47. {gr_libs-0.1.7.post0.dist-info → gr_libs-0.1.8.dist-info}/METADATA +1 -1
  48. gr_libs-0.1.8.dist-info/RECORD +70 -0
  49. {gr_libs-0.1.7.post0.dist-info → gr_libs-0.1.8.dist-info}/WHEEL +1 -1
  50. tests/test_gcdraco.py +10 -0
  51. tests/test_graml.py +8 -4
  52. tests/test_graql.py +2 -1
  53. tutorials/gcdraco_panda_tutorial.py +66 -0
  54. tutorials/gcdraco_parking_tutorial.py +61 -0
  55. tutorials/graml_minigrid_tutorial.py +42 -12
  56. tutorials/graml_panda_tutorial.py +35 -14
  57. tutorials/graml_parking_tutorial.py +37 -20
  58. tutorials/graml_point_maze_tutorial.py +33 -13
  59. tutorials/graql_minigrid_tutorial.py +31 -15
  60. gr_libs-0.1.7.post0.dist-info/RECORD +0 -67
  61. {gr_libs-0.1.7.post0.dist-info → gr_libs-0.1.8.dist-info}/top_level.txt +0 -0
@@ -1,39 +1,59 @@
1
-
2
1
  from stable_baselines3 import SAC, TD3
3
2
  from gr_libs.environment.environment import POINT_MAZE, PointMazeProperty
3
+ from gr_libs.environment.utils.utils import domain_to_env_property
4
4
  from gr_libs.metrics.metrics import stochastic_amplified_selection
5
5
  from gr_libs.ml.neural.deep_rl_learner import DeepRLAgent
6
6
  from gr_libs.ml.utils.format import random_subset_with_order
7
7
  from gr_libs.recognizer.graml.graml_recognizer import ExpertBasedGraml
8
8
 
9
+
9
10
  def run_graml_point_maze_tutorial():
10
11
  recognizer = ExpertBasedGraml(
11
- domain_name=POINT_MAZE,
12
- env_name="PointMaze-FourRoomsEnvDense-11x11"
12
+ domain_name=POINT_MAZE, env_name="PointMaze-FourRoomsEnvDense-11x11"
13
13
  )
14
14
 
15
15
  recognizer.domain_learning_phase(
16
- [(9,1), (9,9), (1,9), (3,3), (3,4), (8,2), (3,7), (2,8)],
17
- [(SAC, 200000) for _ in range(8)]
16
+ [(9, 1), (9, 9), (1, 9), (3, 3), (3, 4), (8, 2), (3, 7), (2, 8)],
17
+ [(SAC, 200000) for _ in range(8)],
18
18
  )
19
19
 
20
20
  recognizer.goals_adaptation_phase(
21
- dynamic_goals = [(4,4), (7,3), (3,7)],
22
- dynamic_train_configs=[(SAC, 200000) for _ in range(3)] # for expert sequence generation.
21
+ dynamic_goals=[(4, 4), (7, 3), (3, 7)],
22
+ dynamic_train_configs=[
23
+ (SAC, 200000) for _ in range(3)
24
+ ], # for expert sequence generation.
23
25
  )
24
26
 
27
+ property_type = domain_to_env_property(POINT_MAZE)
28
+ env_property = property_type("PointMaze-FourRoomsEnvDense-11x11")
29
+
25
30
  # TD3 is different from recognizer and expert algorithms, which are SAC #
26
- actor = DeepRLAgent(domain_name="point_maze", problem_name="PointMaze-FourRoomsEnvDense-11x11-Goal-4x4", algorithm=TD3, num_timesteps=200000)
31
+ actor = DeepRLAgent(
32
+ domain_name="point_maze",
33
+ problem_name="PointMaze-FourRoomsEnvDense-11x11-Goal-4x4",
34
+ env_prop=env_property,
35
+ algorithm=TD3,
36
+ num_timesteps=200000,
37
+ )
27
38
  actor.learn()
28
39
  # sample is generated stochastically to simulate suboptimal behavior, noise is added to the actions values #
29
40
  full_sequence = actor.generate_observation(
30
41
  action_selection_method=stochastic_amplified_selection,
31
- random_optimalism=True, # the noise that's added to the actions
42
+ random_optimalism=True, # the noise that's added to the actions
43
+ )
44
+
45
+ partial_sequence = random_subset_with_order(
46
+ full_sequence, (int)(0.5 * len(full_sequence))
47
+ )
48
+ closest_goal = recognizer.inference_phase(
49
+ partial_sequence,
50
+ PointMazeProperty("PointMaze-FourRoomsEnvDense-11x11-Goal-4x4").str_to_goal(),
51
+ 0.5,
52
+ )
53
+ print(
54
+ f"closest_goal returned by GRAML: {closest_goal}\nactual goal actor aimed towards: (4, 4)"
32
55
  )
33
56
 
34
- partial_sequence = random_subset_with_order(full_sequence, (int)(0.5 * len(full_sequence)))
35
- closest_goal = recognizer.inference_phase(partial_sequence, PointMazeProperty("PointMaze-FourRoomsEnvDense-11x11-Goal-4x4").str_to_goal(), 0.5)
36
- print(f"closest_goal returned by GRAML: {closest_goal}\nactual goal actor aimed towards: (4, 4)")
37
57
 
38
58
  if __name__ == "__main__":
39
- run_graml_point_maze_tutorial()
59
+ run_graml_point_maze_tutorial()
@@ -1,34 +1,50 @@
1
- from gr_libs.environment.environment import QLEARNING
1
+ from gr_libs.environment.environment import MINIGRID, QLEARNING
2
+ from gr_libs.environment.utils.utils import domain_to_env_property
2
3
  from gr_libs.metrics.metrics import stochastic_amplified_selection
3
4
  from gr_libs.ml.tabular.tabular_q_learner import TabularQLearner
4
5
  from gr_libs.ml.utils.format import random_subset_with_order
5
6
  from gr_libs import Graql
6
7
 
8
+
7
9
  def run_graql_minigrid_tutorial():
8
- recognizer = Graql(
9
- domain_name="minigrid",
10
- env_name="MiniGrid-SimpleCrossingS13N4"
11
- )
10
+ recognizer = Graql(domain_name="minigrid", env_name="MiniGrid-SimpleCrossingS13N4")
12
11
 
13
- #Graql doesn't have a domain learning phase, so we skip it
12
+ # Graql doesn't have a domain learning phase, so we skip it
14
13
 
15
14
  recognizer.goals_adaptation_phase(
16
- dynamic_goals = [(11,1), (11,11), (1,11)],
17
- dynamic_train_configs=[(QLEARNING, 100000) for _ in range(3)] # for expert sequence generation.
15
+ dynamic_goals=[(11, 1), (11, 11), (1, 11)],
16
+ dynamic_train_configs=[
17
+ (QLEARNING, 100000) for _ in range(3)
18
+ ], # for expert sequence generation.
18
19
  )
20
+
21
+ property_type = domain_to_env_property(MINIGRID)
22
+ env_property = property_type("MiniGrid-SimpleCrossingS13N4")
23
+
19
24
  # TD3 is different from recognizer and expert algorithms, which are SAC #
20
- actor = TabularQLearner(domain_name="minigrid", problem_name="MiniGrid-SimpleCrossingS13N4-DynamicGoal-11x1-v0", algorithm=QLEARNING, num_timesteps=100000)
25
+ actor = TabularQLearner(
26
+ domain_name="minigrid",
27
+ problem_name="MiniGrid-SimpleCrossingS13N4-DynamicGoal-11x1-v0",
28
+ env_prop=env_property,
29
+ algorithm=QLEARNING,
30
+ num_timesteps=100000,
31
+ )
21
32
  actor.learn()
22
33
  # sample is generated stochastically to simulate suboptimal behavior, noise is added to the actions values #
23
34
  full_sequence = actor.generate_observation(
24
35
  action_selection_method=stochastic_amplified_selection,
25
- random_optimalism=True, # the noise that's added to the actions
36
+ random_optimalism=True, # the noise that's added to the actions
37
+ )
38
+
39
+ partial_sequence = random_subset_with_order(
40
+ full_sequence, (int)(0.5 * len(full_sequence)), is_consecutive=False
41
+ )
42
+ closest_goal = recognizer.inference_phase(partial_sequence, (11, 1), 0.5)
43
+ print(
44
+ f"closest_goal returned by Graql: {closest_goal}\nactual goal actor aimed towards: (11, 1)"
26
45
  )
46
+ return closest_goal, (11, 1)
27
47
 
28
- partial_sequence = random_subset_with_order(full_sequence, (int)(0.5 * len(full_sequence)), is_consecutive=False)
29
- closest_goal = recognizer.inference_phase(partial_sequence, (11,1), 0.5)
30
- print(f"closest_goal returned by Graql: {closest_goal}\nactual goal actor aimed towards: (11, 1)")
31
- return closest_goal, (11,1)
32
48
 
33
49
  if __name__ == "__main__":
34
- run_graql_minigrid_tutorial()
50
+ run_graql_minigrid_tutorial()
@@ -1,67 +0,0 @@
1
- evaluation/analyze_results_cross_alg_cross_domain.py,sha256=s_DDh4rNfRnvQ0PDa2d5411jYOa7CaI1YeB8Dpup7QU,9803
2
- evaluation/create_minigrid_map_image.py,sha256=jaSW3n3tY222iFUeAMqedBP9cvD88GCzPrQ6_XHv5oQ,1242
3
- evaluation/file_system.py,sha256=SSYnj8QGFkq-8V_0s7x2MWbD88aFaoFY4Ogc_Pt8m6U,1601
4
- evaluation/generate_experiments_results.py,sha256=oMFt2-TX7g3O6aBflFtQ5q0PT6sngEb8104kpPVMi0s,4051
5
- evaluation/generate_experiments_results_new_ver1.py,sha256=P9gz3xa0DoRRMQ16GQL3_wVSDYUfh8oZ3BCIUjphKaM,8909
6
- evaluation/generate_experiments_results_new_ver2.py,sha256=jeKj_wgdM50o2vi8WZI-s3GbsQdsjultHX-8H4Xvus4,12276
7
- evaluation/generate_task_specific_statistics_plots.py,sha256=rBsqaMe2irP_Cfo-icwIg4_dsleFjEH6eiQCcUBj6WU,15286
8
- evaluation/get_plans_images.py,sha256=BT-bGWuOPUAYpZVDwk7YMRBLdgKaDbNOBjMrtcl1Vjk,2346
9
- evaluation/increasing_and_decreasing_.py,sha256=fu1hkEjhOQC3jEsjiS7emW_UPRpVFCaae0d0E2MGZqI,2991
10
- gr_libs/__init__.py,sha256=WlSRpZIpz5GxLNk96nhympbk3Z5nsMiSOyiAWj17S88,280
11
- gr_libs/_version.py,sha256=Zy3HQFB_Viry2Rl81-7LPU4kL2FTQegnwLvl0VxTs3E,526
12
- gr_libs/environment/__init__.py,sha256=KlRp3qdgxEmej31zDoDsYPwbcAqyDglx6x0mH0KRmHU,1032
13
- gr_libs/environment/environment.py,sha256=d6ZbiAQ4H1aLrUFI8sm0BN9DVW3JtzpkodSi_70Z_PY,6780
14
- gr_libs/environment/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- gr_libs/environment/utils/utils.py,sha256=4yM3s30KjyuEmWR8UuICE5rR03zsLi3tzqNDvBkdPcU,537
16
- gr_libs/metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- gr_libs/metrics/metrics.py,sha256=4bnvs5suv-QrK9i1NuOzkE_E8uIzS1nlEazNDRXvZGs,8700
18
- gr_libs/ml/__init__.py,sha256=jrjxYqvSRgWwFWw7XQP9DzOwvmprMZ2umwT7t-DYtDU,233
19
- gr_libs/ml/agent.py,sha256=DSnK8nRx9SS76fAOZZEEvA68_meLjzm9lfQpMUXmGQU,1957
20
- gr_libs/ml/consts.py,sha256=mrbZk8n6QoGzLGaKmaxq4QlAsBbk4fhkCgXLuO9jXKw,365
21
- gr_libs/ml/base/__init__.py,sha256=MfIYhl_UqH8H7YoTCih8wBFA_gpTOUFq8Ph0_Nq0XQk,68
22
- gr_libs/ml/base/rl_agent.py,sha256=u9rnb-ma9iDM5b_BlwjcTJGSFezIGrxXINw6b-Dbl8s,1598
23
- gr_libs/ml/neural/__init__.py,sha256=g-0D5oFX8W52To4OR8vO8kDoBLSxAupVqwcQw8XjT5E,180
24
- gr_libs/ml/neural/deep_rl_learner.py,sha256=b41_b4GVlYqxhjrr1_YMcGdU9iwcMXsf3zH8D2kEucs,20659
25
- gr_libs/ml/neural/utils/__init__.py,sha256=bJgPfRnmfDQxdnb0OyRGwzgebEc1PnlO7-GpqszPBcc,106
26
- gr_libs/ml/neural/utils/dictlist.py,sha256=WpHfdWpVZ_T3PcSnOQUC--ro_tsS0dvam2WG3LcsHDw,1039
27
- gr_libs/ml/neural/utils/penv.py,sha256=R1uW8sePQqvTlJjpAuMx16eDU6TuGAjQF3hTR1QasMo,1862
28
- gr_libs/ml/planner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- gr_libs/ml/planner/mcts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- gr_libs/ml/planner/mcts/mcts_model.py,sha256=N4B2SRWAySW7sJ1JIIkKHbzpxMYo2GcuaSB-eauJmBg,21068
31
- gr_libs/ml/planner/mcts/utils/__init__.py,sha256=8OE_XolCHiWIZZwS23lqLaLd72tsHwO8cQRRToTC0Lk,45
32
- gr_libs/ml/planner/mcts/utils/node.py,sha256=WXXaEjfU857yIBF8gKVjr0ZGmU2Du9s1d-dBcA4QS10,1220
33
- gr_libs/ml/planner/mcts/utils/tree.py,sha256=mLtLtPoqoU0eauNEExY94px5mdbmH-HCsYAYQDZqioI,3382
34
- gr_libs/ml/sequential/__init__.py,sha256=rusN4ahTvAeAq1Saz6qS_9HEU7WuXDJu2zwhc9WUEYQ,61
35
- gr_libs/ml/sequential/lstm_model.py,sha256=Vzm-C1URR84PGNEecj69GUtn3ZmOVyh1BAY6CUnfL1Q,8978
36
- gr_libs/ml/tabular/__init__.py,sha256=jAfjfTFZLLlVm1KUiJdxdnaNGFp1J2KBU89q_vvradM,177
37
- gr_libs/ml/tabular/state.py,sha256=8xroKF3y3nRX0LK1QX5fRT2PS2WmvcDPp0UvPFdSx2A,733
38
- gr_libs/ml/tabular/tabular_q_learner.py,sha256=5QU9ZWC-Cu5jxv5K1TohoRjQrRDhCgTs1Mt18cqM_Sc,18970
39
- gr_libs/ml/tabular/tabular_rl_agent.py,sha256=7w8PYbKi8QgxHJyECWU_rURtT89spg0tHIMI1cDwYc8,3764
40
- gr_libs/ml/utils/__init__.py,sha256=qH3pcnem5Z6rkQ4RTZi47AXJRe1RkFEST_-DrBmfWcM,258
41
- gr_libs/ml/utils/env.py,sha256=AWVN0OXYmFU-J3FUiwvEAIY93Suf1oL6VNcxtyWJraM,171
42
- gr_libs/ml/utils/format.py,sha256=nu7RzVwn_raG_fqqmnqlJgUjtA0yzKztkB3a5QZnRYo,3071
43
- gr_libs/ml/utils/math.py,sha256=n62zssVOLHnUb4dPofAoFhoLOKl5n_xBzaKQOUQBoNc,440
44
- gr_libs/ml/utils/other.py,sha256=HKUfeLBbd4DgJxSTs3ya9KQ85Acx4TjycRrtGD9WQ3s,505
45
- gr_libs/ml/utils/storage.py,sha256=52wR2pgFmcCOhqbu5Km3tegjAmtI1Fb4HYAVUnUubZk,4626
46
- gr_libs/problems/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
- gr_libs/problems/consts.py,sha256=ON7yfKTAKETg7i3okDYuOzEU7KWvynyubl0m7TlU6Hs,38808
48
- gr_libs/recognizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
- gr_libs/recognizer/recognizer.py,sha256=ZrApJVdBQxKRYhhDiWLCNGmlxgi674nwgb30BgVggC8,1705
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=84GdfohC2dZoNH_QEo7GpSt8nZWdfqSRKCTY99X_iME,5215
52
- gr_libs/recognizer/graml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
- gr_libs/recognizer/graml/gr_dataset.py,sha256=lG6m3ulxFELpH1oURnlcmNDWOrxyuzvlAR28ZTqB7L8,7224
54
- gr_libs/recognizer/graml/graml_recognizer.py,sha256=1xLl1gHj3JxWhHtV9h3SvsW7oJdxsQQV0F-VLtlTmKQ,15911
55
- gr_libs/recognizer/utils/__init__.py,sha256=ewSroxL7aATvvm-Xzc1_-61mP2LU2U28YaOEqvVVDB0,41
56
- gr_libs/recognizer/utils/format.py,sha256=e0AnqtPeYoJsV9Z7cEBpgbzTM0hLNxFIjn07fQ3YbQw,492
57
- tests/test_graml.py,sha256=ZJB2jqtf4Q2-KZredkJq90teqmHBIvigCAQpvR5G110,559
58
- tests/test_graql.py,sha256=-onMi13e2wStOmB5bYv2f3Ita3QFFiw416XMBkby0OI,141
59
- tutorials/graml_minigrid_tutorial.py,sha256=ONvxFi79R7d8dcd6gy083Z_yy9A2flhGTDIDRxurdx8,1782
60
- tutorials/graml_panda_tutorial.py,sha256=wtv_lsw0vsU7j45GKeWecTfE7jzfh4iVGEVnQyaWthM,2063
61
- tutorials/graml_parking_tutorial.py,sha256=M6bt1WQOOgn8_CRyG2kjxF14PMeyXVAWRDq1ZRwGTXo,1808
62
- tutorials/graml_point_maze_tutorial.py,sha256=mYq3IxYbf9jidq-4VdT3MdStV80Q5lytFv6Xzzn22Ys,1835
63
- tutorials/graql_minigrid_tutorial.py,sha256=Jb0TCUhiZQkFeafJWUTPnCISd4FKfPrqP-xfHiqCGKE,1635
64
- gr_libs-0.1.7.post0.dist-info/METADATA,sha256=aS7y9Nl1JErXYdpAHstuQP_W1QMcKMbGet6IfxfJ_Do,9620
65
- gr_libs-0.1.7.post0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
66
- gr_libs-0.1.7.post0.dist-info/top_level.txt,sha256=fJQF8Q8Dfh_D3pA2mhNodazNjzW6b3oWfnx6Jdo-pBU,35
67
- gr_libs-0.1.7.post0.dist-info/RECORD,,