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.
Files changed (86) hide show
  1. gr_libs/__init__.py +4 -1
  2. gr_libs/_evaluation/__init__.py +1 -0
  3. gr_libs/_evaluation/_analyze_results_cross_alg_cross_domain.py +260 -0
  4. gr_libs/_evaluation/_generate_experiments_results.py +141 -0
  5. gr_libs/_evaluation/_generate_task_specific_statistics_plots.py +497 -0
  6. gr_libs/_evaluation/_get_plans_images.py +61 -0
  7. gr_libs/_evaluation/_increasing_and_decreasing_.py +106 -0
  8. gr_libs/_version.py +2 -2
  9. gr_libs/all_experiments.py +294 -0
  10. gr_libs/environment/__init__.py +30 -9
  11. gr_libs/environment/_utils/utils.py +27 -0
  12. gr_libs/environment/environment.py +417 -54
  13. gr_libs/metrics/__init__.py +7 -0
  14. gr_libs/metrics/metrics.py +231 -54
  15. gr_libs/ml/__init__.py +2 -5
  16. gr_libs/ml/agent.py +21 -6
  17. gr_libs/ml/base/__init__.py +3 -1
  18. gr_libs/ml/base/rl_agent.py +81 -13
  19. gr_libs/ml/consts.py +1 -1
  20. gr_libs/ml/neural/__init__.py +1 -3
  21. gr_libs/ml/neural/deep_rl_learner.py +619 -378
  22. gr_libs/ml/neural/utils/__init__.py +1 -2
  23. gr_libs/ml/neural/utils/dictlist.py +3 -3
  24. gr_libs/ml/planner/mcts/{utils → _utils}/__init__.py +1 -1
  25. gr_libs/ml/planner/mcts/{utils → _utils}/node.py +11 -7
  26. gr_libs/ml/planner/mcts/{utils → _utils}/tree.py +15 -11
  27. gr_libs/ml/planner/mcts/mcts_model.py +571 -312
  28. gr_libs/ml/sequential/__init__.py +0 -1
  29. gr_libs/ml/sequential/_lstm_model.py +270 -0
  30. gr_libs/ml/tabular/__init__.py +1 -3
  31. gr_libs/ml/tabular/state.py +7 -7
  32. gr_libs/ml/tabular/tabular_q_learner.py +150 -82
  33. gr_libs/ml/tabular/tabular_rl_agent.py +42 -28
  34. gr_libs/ml/utils/__init__.py +2 -3
  35. gr_libs/ml/utils/format.py +28 -97
  36. gr_libs/ml/utils/math.py +5 -3
  37. gr_libs/ml/utils/other.py +3 -3
  38. gr_libs/ml/utils/storage.py +88 -81
  39. gr_libs/odgr_executor.py +268 -0
  40. gr_libs/problems/consts.py +1549 -1227
  41. gr_libs/recognizer/_utils/__init__.py +0 -0
  42. gr_libs/recognizer/_utils/format.py +18 -0
  43. gr_libs/recognizer/gr_as_rl/gr_as_rl_recognizer.py +233 -88
  44. gr_libs/recognizer/graml/_gr_dataset.py +233 -0
  45. gr_libs/recognizer/graml/graml_recognizer.py +586 -252
  46. gr_libs/recognizer/recognizer.py +90 -30
  47. gr_libs/tutorials/draco_panda_tutorial.py +58 -0
  48. gr_libs/tutorials/draco_parking_tutorial.py +56 -0
  49. gr_libs/tutorials/gcdraco_panda_tutorial.py +62 -0
  50. gr_libs/tutorials/gcdraco_parking_tutorial.py +57 -0
  51. gr_libs/tutorials/graml_minigrid_tutorial.py +64 -0
  52. gr_libs/tutorials/graml_panda_tutorial.py +57 -0
  53. gr_libs/tutorials/graml_parking_tutorial.py +52 -0
  54. gr_libs/tutorials/graml_point_maze_tutorial.py +60 -0
  55. gr_libs/tutorials/graql_minigrid_tutorial.py +50 -0
  56. {gr_libs-0.1.7.post0.dist-info → gr_libs-0.2.2.dist-info}/METADATA +84 -29
  57. gr_libs-0.2.2.dist-info/RECORD +71 -0
  58. {gr_libs-0.1.7.post0.dist-info → gr_libs-0.2.2.dist-info}/WHEEL +1 -1
  59. gr_libs-0.2.2.dist-info/top_level.txt +2 -0
  60. tests/test_draco.py +14 -0
  61. tests/test_gcdraco.py +10 -0
  62. tests/test_graml.py +12 -8
  63. tests/test_graql.py +3 -2
  64. evaluation/analyze_results_cross_alg_cross_domain.py +0 -277
  65. evaluation/create_minigrid_map_image.py +0 -34
  66. evaluation/file_system.py +0 -42
  67. evaluation/generate_experiments_results.py +0 -92
  68. evaluation/generate_experiments_results_new_ver1.py +0 -254
  69. evaluation/generate_experiments_results_new_ver2.py +0 -331
  70. evaluation/generate_task_specific_statistics_plots.py +0 -272
  71. evaluation/get_plans_images.py +0 -47
  72. evaluation/increasing_and_decreasing_.py +0 -63
  73. gr_libs/environment/utils/utils.py +0 -17
  74. gr_libs/ml/neural/utils/penv.py +0 -57
  75. gr_libs/ml/sequential/lstm_model.py +0 -192
  76. gr_libs/recognizer/graml/gr_dataset.py +0 -134
  77. gr_libs/recognizer/utils/__init__.py +0 -1
  78. gr_libs/recognizer/utils/format.py +0 -13
  79. gr_libs-0.1.7.post0.dist-info/RECORD +0 -67
  80. gr_libs-0.1.7.post0.dist-info/top_level.txt +0 -4
  81. tutorials/graml_minigrid_tutorial.py +0 -34
  82. tutorials/graml_panda_tutorial.py +0 -41
  83. tutorials/graml_parking_tutorial.py +0 -39
  84. tutorials/graml_point_maze_tutorial.py +0 -39
  85. tutorials/graql_minigrid_tutorial.py +0 -34
  86. /gr_libs/environment/{utils → _utils}/__init__.py +0 -0
@@ -1,2 +1 @@
1
- from gr_libs.ml.neural.utils.dictlist import DictList
2
- from gr_libs.ml.neural.utils.penv import ParallelEnv
1
+ """ utility functions for GR algorithms that use neural networks """
@@ -22,12 +22,12 @@ class DictList(dict):
22
22
  def __setitem__(self, index, d):
23
23
  for key, value in d.items():
24
24
  dict.__getitem__(self, key)[index] = value
25
-
25
+
26
26
  def __reduce__(self):
27
27
  # Custom serialization method for dill
28
28
  return (DictList, (dict(self),)) # Serialize as (DictList, (dict(self),))
29
29
 
30
30
  def __setstate__(self, state):
31
31
  # Custom deserialization method for dill
32
- data, = state
33
- self.update(data)
32
+ (data,) = state
33
+ self.update(data)
@@ -1,2 +1,2 @@
1
1
  from .node import Node
2
- from .tree import Tree
2
+ from .tree import Tree
@@ -1,8 +1,11 @@
1
1
  import random
2
2
 
3
+
3
4
  class Node:
4
5
 
5
- def __init__(self, identifier, state, action, action_space, reward, terminal, pos, depth):
6
+ def __init__(
7
+ self, identifier, state, action, action_space, reward, terminal, pos, depth
8
+ ):
6
9
  self.identifier = identifier
7
10
  self.parent_identifier = None
8
11
  self.children_identifiers = []
@@ -21,13 +24,14 @@ class Node:
21
24
 
22
25
  def __str__(self):
23
26
  return "{}: (action={}, visits={}, reward={:d}, ratio={:0.4f})".format(
24
- self.state,
25
- self.action,
26
- self.num_visits,
27
- int(self.total_simulation_reward),
28
- self.performance)
27
+ self.state,
28
+ self.action,
29
+ self.num_visits,
30
+ int(self.total_simulation_reward),
31
+ self.performance,
32
+ )
29
33
 
30
34
  def untried_action(self):
31
35
  action = random.choice(self.untried_actions)
32
36
  self.untried_actions.remove(action)
33
- return action
37
+ return action
@@ -1,22 +1,24 @@
1
1
  def vertical_lines(last_node_flags):
2
2
  vertical_lines = []
3
- vertical_line = '\u2502'
3
+ vertical_line = "\u2502"
4
4
  for last_node_flag in last_node_flags[0:-1]:
5
5
  if last_node_flag == False:
6
- vertical_lines.append(vertical_line + ' ' * 3)
6
+ vertical_lines.append(vertical_line + " " * 3)
7
7
  else:
8
8
  # space between vertical lines
9
- vertical_lines.append(' ' * 4)
10
- return ''.join(vertical_lines)
9
+ vertical_lines.append(" " * 4)
10
+ return "".join(vertical_lines)
11
+
11
12
 
12
13
  def horizontal_line(last_node_flags):
13
- horizontal_line = '\u251c\u2500\u2500 '
14
- horizontal_line_end = '\u2514\u2500\u2500 '
14
+ horizontal_line = "\u251c\u2500\u2500 "
15
+ horizontal_line_end = "\u2514\u2500\u2500 "
15
16
  if last_node_flags[-1]:
16
17
  return horizontal_line_end
17
18
  else:
18
19
  return horizontal_line
19
20
 
21
+
20
22
  class Tree:
21
23
 
22
24
  def __init__(self):
@@ -39,7 +41,9 @@ class Tree:
39
41
  if depth == 0:
40
42
  yield "", node
41
43
  else:
42
- yield vertical_lines(last_node_flags) + horizontal_line(last_node_flags), node
44
+ yield vertical_lines(last_node_flags) + horizontal_line(
45
+ last_node_flags
46
+ ), node
43
47
 
44
48
  children = [self.nodes[identifier] for identifier in node.children_identifiers]
45
49
  last_index = len(children) - 1
@@ -60,7 +64,7 @@ class Tree:
60
64
  self.nodes[node.identifier].parent = None
61
65
  else:
62
66
  self.nodes[parent.identifier].children_identifiers.append(node.identifier)
63
- self.nodes[node.identifier].parent_identifier=parent.identifier
67
+ self.nodes[node.identifier].parent_identifier = parent.identifier
64
68
 
65
69
  def update_id(self, old_id, new_id):
66
70
  assert new_id not in self.nodes.keys()
@@ -78,7 +82,7 @@ class Tree:
78
82
  # update the node's children (if there are any?...)
79
83
  for child_id in node.children_identifiers:
80
84
  self.nodes[child_id].parent_identifier = new_id
81
-
85
+
82
86
  self.nodes.pop(old_id)
83
87
  self.nodes.update({node.identifier: node})
84
88
 
@@ -98,5 +102,5 @@ class Tree:
98
102
  def show(self):
99
103
  lines = ""
100
104
  for edge, node in self.iter(identifier=None, depth=0, last_node_flags=[]):
101
- lines += "{}{}\n".format(edge, node)
102
- print(lines)
105
+ lines += f"{edge}{node}\n"
106
+ print(lines)