sierra-research 1.3.11__py3-none-any.whl → 1.5.0__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 (254) hide show
  1. sierra/__init__.py +3 -3
  2. sierra/core/__init__.py +3 -3
  3. sierra/core/batchroot.py +223 -0
  4. sierra/core/cmdline.py +681 -1057
  5. sierra/core/compare.py +11 -0
  6. sierra/core/config.py +96 -88
  7. sierra/core/engine.py +306 -0
  8. sierra/core/execenv.py +380 -0
  9. sierra/core/expdef.py +11 -0
  10. sierra/core/experiment/__init__.py +1 -0
  11. sierra/core/experiment/bindings.py +150 -101
  12. sierra/core/experiment/definition.py +414 -245
  13. sierra/core/experiment/spec.py +83 -85
  14. sierra/core/exproot.py +44 -0
  15. sierra/core/generators/__init__.py +10 -0
  16. sierra/core/generators/experiment.py +528 -0
  17. sierra/core/generators/generator_factory.py +138 -137
  18. sierra/core/graphs/__init__.py +23 -0
  19. sierra/core/graphs/bcbridge.py +94 -0
  20. sierra/core/graphs/heatmap.py +245 -324
  21. sierra/core/graphs/pathset.py +27 -0
  22. sierra/core/graphs/schema.py +77 -0
  23. sierra/core/graphs/stacked_line.py +341 -0
  24. sierra/core/graphs/summary_line.py +506 -0
  25. sierra/core/logging.py +3 -2
  26. sierra/core/models/__init__.py +3 -1
  27. sierra/core/models/info.py +19 -0
  28. sierra/core/models/interface.py +52 -122
  29. sierra/core/pipeline/__init__.py +2 -5
  30. sierra/core/pipeline/pipeline.py +228 -126
  31. sierra/core/pipeline/stage1/__init__.py +10 -0
  32. sierra/core/pipeline/stage1/pipeline_stage1.py +45 -31
  33. sierra/core/pipeline/stage2/__init__.py +10 -0
  34. sierra/core/pipeline/stage2/pipeline_stage2.py +8 -11
  35. sierra/core/pipeline/stage2/runner.py +401 -0
  36. sierra/core/pipeline/stage3/__init__.py +12 -0
  37. sierra/core/pipeline/stage3/gather.py +321 -0
  38. sierra/core/pipeline/stage3/pipeline_stage3.py +37 -84
  39. sierra/core/pipeline/stage4/__init__.py +12 -2
  40. sierra/core/pipeline/stage4/pipeline_stage4.py +36 -354
  41. sierra/core/pipeline/stage5/__init__.py +12 -0
  42. sierra/core/pipeline/stage5/pipeline_stage5.py +33 -208
  43. sierra/core/pipeline/yaml.py +48 -0
  44. sierra/core/plugin.py +529 -62
  45. sierra/core/proc.py +11 -0
  46. sierra/core/prod.py +11 -0
  47. sierra/core/ros1/__init__.py +5 -1
  48. sierra/core/ros1/callbacks.py +22 -21
  49. sierra/core/ros1/cmdline.py +59 -88
  50. sierra/core/ros1/generators.py +159 -175
  51. sierra/core/ros1/variables/__init__.py +3 -0
  52. sierra/core/ros1/variables/exp_setup.py +122 -116
  53. sierra/core/startup.py +106 -76
  54. sierra/core/stat_kernels.py +4 -5
  55. sierra/core/storage.py +13 -32
  56. sierra/core/trampoline.py +30 -0
  57. sierra/core/types.py +116 -71
  58. sierra/core/utils.py +103 -106
  59. sierra/core/variables/__init__.py +1 -1
  60. sierra/core/variables/base_variable.py +12 -17
  61. sierra/core/variables/batch_criteria.py +387 -481
  62. sierra/core/variables/builtin.py +135 -0
  63. sierra/core/variables/exp_setup.py +19 -39
  64. sierra/core/variables/population_size.py +72 -76
  65. sierra/core/variables/variable_density.py +44 -68
  66. sierra/core/vector.py +1 -1
  67. sierra/main.py +256 -88
  68. sierra/plugins/__init__.py +119 -0
  69. sierra/plugins/compare/__init__.py +14 -0
  70. sierra/plugins/compare/graphs/__init__.py +19 -0
  71. sierra/plugins/compare/graphs/cmdline.py +120 -0
  72. sierra/plugins/compare/graphs/comparator.py +291 -0
  73. sierra/plugins/compare/graphs/inter_controller.py +531 -0
  74. sierra/plugins/compare/graphs/inter_scenario.py +297 -0
  75. sierra/plugins/compare/graphs/namecalc.py +53 -0
  76. sierra/plugins/compare/graphs/outputroot.py +73 -0
  77. sierra/plugins/compare/graphs/plugin.py +147 -0
  78. sierra/plugins/compare/graphs/preprocess.py +172 -0
  79. sierra/plugins/compare/graphs/schema.py +37 -0
  80. sierra/plugins/engine/__init__.py +14 -0
  81. sierra/plugins/engine/argos/__init__.py +18 -0
  82. sierra/plugins/{platform → engine}/argos/cmdline.py +144 -151
  83. sierra/plugins/{platform/argos/variables → engine/argos/generators}/__init__.py +5 -0
  84. sierra/plugins/engine/argos/generators/engine.py +394 -0
  85. sierra/plugins/engine/argos/plugin.py +393 -0
  86. sierra/plugins/{platform/argos/generators → engine/argos/variables}/__init__.py +5 -0
  87. sierra/plugins/engine/argos/variables/arena_shape.py +183 -0
  88. sierra/plugins/engine/argos/variables/cameras.py +240 -0
  89. sierra/plugins/engine/argos/variables/constant_density.py +112 -0
  90. sierra/plugins/engine/argos/variables/exp_setup.py +82 -0
  91. sierra/plugins/{platform → engine}/argos/variables/physics_engines.py +83 -87
  92. sierra/plugins/engine/argos/variables/population_constant_density.py +178 -0
  93. sierra/plugins/engine/argos/variables/population_size.py +115 -0
  94. sierra/plugins/engine/argos/variables/population_variable_density.py +123 -0
  95. sierra/plugins/engine/argos/variables/rendering.py +108 -0
  96. sierra/plugins/engine/ros1gazebo/__init__.py +18 -0
  97. sierra/plugins/engine/ros1gazebo/cmdline.py +175 -0
  98. sierra/plugins/{platform/ros1robot → engine/ros1gazebo}/generators/__init__.py +5 -0
  99. sierra/plugins/engine/ros1gazebo/generators/engine.py +125 -0
  100. sierra/plugins/engine/ros1gazebo/plugin.py +404 -0
  101. sierra/plugins/engine/ros1gazebo/variables/__init__.py +15 -0
  102. sierra/plugins/engine/ros1gazebo/variables/population_size.py +214 -0
  103. sierra/plugins/engine/ros1robot/__init__.py +18 -0
  104. sierra/plugins/engine/ros1robot/cmdline.py +159 -0
  105. sierra/plugins/{platform/ros1gazebo → engine/ros1robot}/generators/__init__.py +4 -0
  106. sierra/plugins/engine/ros1robot/generators/engine.py +95 -0
  107. sierra/plugins/engine/ros1robot/plugin.py +410 -0
  108. sierra/plugins/{hpc/local → engine/ros1robot/variables}/__init__.py +5 -0
  109. sierra/plugins/engine/ros1robot/variables/population_size.py +146 -0
  110. sierra/plugins/execenv/__init__.py +11 -0
  111. sierra/plugins/execenv/hpc/__init__.py +18 -0
  112. sierra/plugins/execenv/hpc/adhoc/__init__.py +18 -0
  113. sierra/plugins/execenv/hpc/adhoc/cmdline.py +30 -0
  114. sierra/plugins/execenv/hpc/adhoc/plugin.py +131 -0
  115. sierra/plugins/execenv/hpc/cmdline.py +137 -0
  116. sierra/plugins/execenv/hpc/local/__init__.py +18 -0
  117. sierra/plugins/execenv/hpc/local/cmdline.py +31 -0
  118. sierra/plugins/execenv/hpc/local/plugin.py +145 -0
  119. sierra/plugins/execenv/hpc/pbs/__init__.py +18 -0
  120. sierra/plugins/execenv/hpc/pbs/cmdline.py +30 -0
  121. sierra/plugins/execenv/hpc/pbs/plugin.py +121 -0
  122. sierra/plugins/execenv/hpc/slurm/__init__.py +18 -0
  123. sierra/plugins/execenv/hpc/slurm/cmdline.py +30 -0
  124. sierra/plugins/execenv/hpc/slurm/plugin.py +133 -0
  125. sierra/plugins/execenv/prefectserver/__init__.py +18 -0
  126. sierra/plugins/execenv/prefectserver/cmdline.py +66 -0
  127. sierra/plugins/execenv/prefectserver/dockerremote/__init__.py +18 -0
  128. sierra/plugins/execenv/prefectserver/dockerremote/cmdline.py +66 -0
  129. sierra/plugins/execenv/prefectserver/dockerremote/plugin.py +132 -0
  130. sierra/plugins/execenv/prefectserver/flow.py +66 -0
  131. sierra/plugins/execenv/prefectserver/local/__init__.py +18 -0
  132. sierra/plugins/execenv/prefectserver/local/cmdline.py +29 -0
  133. sierra/plugins/execenv/prefectserver/local/plugin.py +133 -0
  134. sierra/plugins/{hpc/adhoc → execenv/robot}/__init__.py +1 -0
  135. sierra/plugins/execenv/robot/turtlebot3/__init__.py +18 -0
  136. sierra/plugins/execenv/robot/turtlebot3/plugin.py +204 -0
  137. sierra/plugins/expdef/__init__.py +14 -0
  138. sierra/plugins/expdef/json/__init__.py +14 -0
  139. sierra/plugins/expdef/json/plugin.py +504 -0
  140. sierra/plugins/expdef/xml/__init__.py +14 -0
  141. sierra/plugins/expdef/xml/plugin.py +386 -0
  142. sierra/{core/hpc → plugins/proc}/__init__.py +1 -1
  143. sierra/plugins/proc/collate/__init__.py +15 -0
  144. sierra/plugins/proc/collate/cmdline.py +47 -0
  145. sierra/plugins/proc/collate/plugin.py +271 -0
  146. sierra/plugins/proc/compress/__init__.py +18 -0
  147. sierra/plugins/proc/compress/cmdline.py +47 -0
  148. sierra/plugins/proc/compress/plugin.py +123 -0
  149. sierra/plugins/proc/decompress/__init__.py +18 -0
  150. sierra/plugins/proc/decompress/plugin.py +96 -0
  151. sierra/plugins/proc/imagize/__init__.py +15 -0
  152. sierra/plugins/proc/imagize/cmdline.py +49 -0
  153. sierra/plugins/proc/imagize/plugin.py +270 -0
  154. sierra/plugins/proc/modelrunner/__init__.py +16 -0
  155. sierra/plugins/proc/modelrunner/plugin.py +250 -0
  156. sierra/plugins/proc/statistics/__init__.py +15 -0
  157. sierra/plugins/proc/statistics/cmdline.py +64 -0
  158. sierra/plugins/proc/statistics/plugin.py +390 -0
  159. sierra/plugins/{hpc → prod}/__init__.py +1 -0
  160. sierra/plugins/prod/graphs/__init__.py +18 -0
  161. sierra/plugins/prod/graphs/cmdline.py +269 -0
  162. sierra/plugins/prod/graphs/collate.py +279 -0
  163. sierra/plugins/prod/graphs/inter/__init__.py +13 -0
  164. sierra/plugins/prod/graphs/inter/generate.py +83 -0
  165. sierra/plugins/prod/graphs/inter/heatmap.py +86 -0
  166. sierra/plugins/prod/graphs/inter/line.py +134 -0
  167. sierra/plugins/prod/graphs/intra/__init__.py +15 -0
  168. sierra/plugins/prod/graphs/intra/generate.py +202 -0
  169. sierra/plugins/prod/graphs/intra/heatmap.py +74 -0
  170. sierra/plugins/prod/graphs/intra/line.py +114 -0
  171. sierra/plugins/prod/graphs/plugin.py +103 -0
  172. sierra/plugins/prod/graphs/targets.py +63 -0
  173. sierra/plugins/prod/render/__init__.py +18 -0
  174. sierra/plugins/prod/render/cmdline.py +72 -0
  175. sierra/plugins/prod/render/plugin.py +282 -0
  176. sierra/plugins/storage/__init__.py +5 -0
  177. sierra/plugins/storage/arrow/__init__.py +18 -0
  178. sierra/plugins/storage/arrow/plugin.py +38 -0
  179. sierra/plugins/storage/csv/__init__.py +9 -0
  180. sierra/plugins/storage/csv/plugin.py +12 -5
  181. sierra/version.py +3 -2
  182. sierra_research-1.5.0.dist-info/METADATA +238 -0
  183. sierra_research-1.5.0.dist-info/RECORD +186 -0
  184. {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/WHEEL +1 -2
  185. sierra/core/experiment/xml.py +0 -454
  186. sierra/core/generators/controller_generator_parser.py +0 -34
  187. sierra/core/generators/exp_creator.py +0 -351
  188. sierra/core/generators/exp_generators.py +0 -142
  189. sierra/core/graphs/scatterplot2D.py +0 -109
  190. sierra/core/graphs/stacked_line_graph.py +0 -251
  191. sierra/core/graphs/stacked_surface_graph.py +0 -220
  192. sierra/core/graphs/summary_line_graph.py +0 -371
  193. sierra/core/hpc/cmdline.py +0 -142
  194. sierra/core/models/graphs.py +0 -87
  195. sierra/core/pipeline/stage2/exp_runner.py +0 -286
  196. sierra/core/pipeline/stage3/imagizer.py +0 -149
  197. sierra/core/pipeline/stage3/run_collator.py +0 -317
  198. sierra/core/pipeline/stage3/statistics_calculator.py +0 -478
  199. sierra/core/pipeline/stage4/graph_collator.py +0 -320
  200. sierra/core/pipeline/stage4/inter_exp_graph_generator.py +0 -240
  201. sierra/core/pipeline/stage4/intra_exp_graph_generator.py +0 -317
  202. sierra/core/pipeline/stage4/model_runner.py +0 -168
  203. sierra/core/pipeline/stage4/rendering.py +0 -283
  204. sierra/core/pipeline/stage4/yaml_config_loader.py +0 -103
  205. sierra/core/pipeline/stage5/inter_scenario_comparator.py +0 -328
  206. sierra/core/pipeline/stage5/intra_scenario_comparator.py +0 -989
  207. sierra/core/platform.py +0 -493
  208. sierra/core/plugin_manager.py +0 -369
  209. sierra/core/root_dirpath_generator.py +0 -241
  210. sierra/plugins/hpc/adhoc/plugin.py +0 -125
  211. sierra/plugins/hpc/local/plugin.py +0 -81
  212. sierra/plugins/hpc/pbs/__init__.py +0 -9
  213. sierra/plugins/hpc/pbs/plugin.py +0 -126
  214. sierra/plugins/hpc/slurm/__init__.py +0 -9
  215. sierra/plugins/hpc/slurm/plugin.py +0 -130
  216. sierra/plugins/platform/__init__.py +0 -9
  217. sierra/plugins/platform/argos/__init__.py +0 -9
  218. sierra/plugins/platform/argos/generators/platform_generators.py +0 -383
  219. sierra/plugins/platform/argos/plugin.py +0 -337
  220. sierra/plugins/platform/argos/variables/arena_shape.py +0 -145
  221. sierra/plugins/platform/argos/variables/cameras.py +0 -243
  222. sierra/plugins/platform/argos/variables/constant_density.py +0 -136
  223. sierra/plugins/platform/argos/variables/exp_setup.py +0 -113
  224. sierra/plugins/platform/argos/variables/population_constant_density.py +0 -175
  225. sierra/plugins/platform/argos/variables/population_size.py +0 -102
  226. sierra/plugins/platform/argos/variables/population_variable_density.py +0 -132
  227. sierra/plugins/platform/argos/variables/rendering.py +0 -104
  228. sierra/plugins/platform/ros1gazebo/__init__.py +0 -9
  229. sierra/plugins/platform/ros1gazebo/cmdline.py +0 -213
  230. sierra/plugins/platform/ros1gazebo/generators/platform_generators.py +0 -137
  231. sierra/plugins/platform/ros1gazebo/plugin.py +0 -335
  232. sierra/plugins/platform/ros1gazebo/variables/__init__.py +0 -10
  233. sierra/plugins/platform/ros1gazebo/variables/population_size.py +0 -204
  234. sierra/plugins/platform/ros1robot/__init__.py +0 -9
  235. sierra/plugins/platform/ros1robot/cmdline.py +0 -175
  236. sierra/plugins/platform/ros1robot/generators/platform_generators.py +0 -112
  237. sierra/plugins/platform/ros1robot/plugin.py +0 -373
  238. sierra/plugins/platform/ros1robot/variables/__init__.py +0 -10
  239. sierra/plugins/platform/ros1robot/variables/population_size.py +0 -146
  240. sierra/plugins/robot/__init__.py +0 -9
  241. sierra/plugins/robot/turtlebot3/__init__.py +0 -9
  242. sierra/plugins/robot/turtlebot3/plugin.py +0 -194
  243. sierra_research-1.3.11.data/data/share/man/man1/sierra-cli.1 +0 -2349
  244. sierra_research-1.3.11.data/data/share/man/man7/sierra-examples.7 +0 -508
  245. sierra_research-1.3.11.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
  246. sierra_research-1.3.11.data/data/share/man/man7/sierra-glossary.7 +0 -285
  247. sierra_research-1.3.11.data/data/share/man/man7/sierra-platforms.7 +0 -358
  248. sierra_research-1.3.11.data/data/share/man/man7/sierra-usage.7 +0 -729
  249. sierra_research-1.3.11.data/data/share/man/man7/sierra.7 +0 -78
  250. sierra_research-1.3.11.dist-info/METADATA +0 -492
  251. sierra_research-1.3.11.dist-info/RECORD +0 -133
  252. sierra_research-1.3.11.dist-info/top_level.txt +0 -1
  253. {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
  254. {sierra_research-1.3.11.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,383 +0,0 @@
1
- # Copyright 2021 John Harwell, All rights reserved.
2
- #
3
- # SPDX-License-Identifier: MIT
4
- """Classes for generating common XML modifications for :term:`ARGoS`.
5
-
6
- I.e., changes which are platform-specific, but applicable to all projects using
7
- the platform.
8
-
9
- """
10
- # Core packages
11
- import typing as tp
12
- import logging
13
- import sys
14
- import pathlib
15
-
16
- # 3rd party packages
17
- import psutil
18
-
19
- # Project packages
20
- from sierra.core.utils import ArenaExtent
21
- from sierra.core.experiment import spec, definition, xml
22
- from sierra.core import types, config, utils
23
- import sierra.core.plugin_manager as pm
24
-
25
- from sierra.plugins.platform.argos.variables import arena_shape
26
- from sierra.plugins.platform.argos.variables import population_size
27
- from sierra.plugins.platform.argos.variables import physics_engines
28
- from sierra.plugins.platform.argos.variables import cameras
29
- from sierra.plugins.platform.argos.variables import rendering
30
- import sierra.plugins.platform.argos.variables.exp_setup as exp
31
-
32
-
33
- class PlatformExpDefGenerator():
34
- """
35
- Init the object.
36
-
37
- Attributes:
38
-
39
- controller: The controller used for the experiment.
40
-
41
- cmdopts: Dictionary of parsed cmdline parameters.
42
- """
43
-
44
- def __init__(self,
45
- exp_spec: spec.ExperimentSpec,
46
- controller: str,
47
- cmdopts: types.Cmdopts,
48
- **kwargs) -> None:
49
- self.controller = controller
50
- self.spec = exp_spec
51
- self.cmdopts = cmdopts
52
- self.template_input_file = kwargs['template_input_file']
53
- self.kwargs = kwargs
54
- self.logger = logging.getLogger(__name__)
55
-
56
- def generate(self) -> definition.XMLExpDef:
57
- """Generate XML modifications common to all ARGoS experiments.
58
-
59
- """
60
- # ARGoS uses a single input file
61
- wr_config = xml.WriterConfig([{'src_parent': None,
62
- 'src_tag': '.',
63
- 'opath_leaf': config.kARGoS['launch_file_ext'],
64
- 'create_tags': None,
65
- 'dest_parent': None,
66
- 'rename_to': None
67
- }])
68
- exp_def = definition.XMLExpDef(input_fpath=self.template_input_file,
69
- write_config=wr_config)
70
-
71
- # Generate # robots
72
- self._generate_n_robots(exp_def)
73
-
74
- # Setup library
75
- self._generate_library(exp_def)
76
-
77
- # Setup simulation visualizations
78
- self._generate_visualization(exp_def)
79
-
80
- # Setup threading
81
- self._generate_threading(exp_def)
82
-
83
- # Setup robot sensors/actuators
84
- self._generate_saa(exp_def)
85
-
86
- # Setup simulation time parameters
87
- self._generate_time(exp_def)
88
-
89
- return exp_def
90
-
91
- def generate_physics(self,
92
- exp_def: definition.XMLExpDef,
93
- cmdopts: types.Cmdopts,
94
- engine_type: str,
95
- n_engines: int,
96
- extents: tp.List[ArenaExtent],
97
- remove_defs: bool = True) -> None:
98
- """
99
- Generate XML changes for the specified physics engines configuration.
100
-
101
- Physics engine definition removal is optional, because when mixing 2D/3D
102
- engine definitions, you only want to remove the existing definitions
103
- BEFORE you have adding first of the mixed definitions. Doing so every
104
- time results in only the LAST of the mixed definitions being present in
105
- the input file.
106
-
107
- Does not write generated changes to the simulation definition pickle
108
- file.
109
- """
110
- # Valid to have 0 engines here if 2D/3D were mixed but only 1 engine was
111
- # specified for the whole simulation.
112
- if n_engines == 0:
113
- self.logger.warning("0 engines of type %s specified", engine_type)
114
- return
115
-
116
- self.logger.trace(("Generating changes for %d '%s' " # type: ignore
117
- "physics engines (all runs)"),
118
- n_engines,
119
- engine_type)
120
- if cmdopts['physics_spatial_hash2D']:
121
- assert hasattr(self.spec.criteria, 'n_robots'),\
122
- ("When using the 2D spatial hash, the batch "
123
- "criteria must implement bc.IQueryableBatchCriteria")
124
- n_robots = self.spec.criteria.n_robots(self.spec.exp_num)
125
- else:
126
- n_robots = None
127
-
128
- module = pm.pipeline.get_plugin_module(cmdopts['platform'])
129
- robot_type = module.robot_type_from_def(exp_def)
130
- pe = physics_engines.factory(engine_type,
131
- n_engines,
132
- n_robots,
133
- robot_type,
134
- cmdopts,
135
- extents)
136
-
137
- utils.apply_to_expdef(pe, exp_def)
138
-
139
- def generate_arena_shape(self,
140
- exp_def: definition.XMLExpDef,
141
- shape: arena_shape.ArenaShape) -> None:
142
- """
143
- Generate XML changes for the specified arena shape.
144
-
145
- Writes generated changes to the simulation definition pickle file.
146
- """
147
- self.logger.trace(("Generating changes for arena " # type: ignore
148
- "share (all runs)"))
149
- _, adds, chgs = utils.apply_to_expdef(shape, exp_def)
150
- utils.pickle_modifications(adds, chgs, self.spec.exp_def_fpath)
151
-
152
- def _generate_n_robots(self, exp_def: definition.XMLExpDef) -> None:
153
- """
154
- Generate XML changes to setup # robots (if specified on cmdline).
155
-
156
- Writes generated changes to the simulation definition pickle file.
157
- """
158
- if self.cmdopts['n_robots'] is None:
159
- return
160
-
161
- self.logger.trace(("Generating changes for # robots " # type: ignore
162
- "(all runs)"))
163
- chgs = population_size.PopulationSize.gen_attr_changelist_from_list(
164
- [self.cmdopts['n_robots']])
165
- for a in chgs[0]:
166
- exp_def.attr_change(a.path, a.attr, a.value, True)
167
-
168
- # Write # robots info to file for later retrieval
169
- chgs[0].pickle(self.spec.exp_def_fpath)
170
-
171
- def _generate_saa(self, exp_def: definition.XMLExpDef) -> None:
172
- """Generate XML changes to disable selected sensors/actuators.
173
-
174
- Some sensors and actuators are computationally expensive in large
175
- populations, but not that costly if the # robots is small.
176
-
177
- Does not write generated changes to the simulation definition pickle
178
- file.
179
-
180
- """
181
- self.logger.trace(("Generating changes for SAA " # type: ignore
182
- "(all runs)"))
183
-
184
- if not self.cmdopts["with_robot_rab"]:
185
- exp_def.tag_remove(".//media", "range_and_bearing", noprint=True)
186
- exp_def.tag_remove(".//actuators",
187
- "range_and_bearing",
188
- noprint=True)
189
- exp_def.tag_remove(".//sensors", "range_and_bearing", noprint=True)
190
-
191
- if not self.cmdopts["with_robot_leds"]:
192
- exp_def.tag_remove(".//actuators", "leds", noprint=True)
193
- exp_def.tag_remove(".//sensors",
194
- "colored_blob_omnidirectional_camera",
195
- noprint=True)
196
- exp_def.tag_remove(".//media", "led", noprint=True)
197
-
198
- if not self.cmdopts["with_robot_battery"]:
199
- exp_def.tag_remove(".//sensors", "battery", noprint=True)
200
- exp_def.tag_remove(".//entity/*", "battery", noprint=True)
201
-
202
- def _generate_time(self, exp_def: definition.XMLExpDef) -> None:
203
- """
204
- Generate XML changes to setup simulation time parameters.
205
-
206
- Writes generated changes to the simulation definition pickle file.
207
- """
208
- self.logger.debug("Using exp_setup=%s", self.cmdopts['exp_setup'])
209
-
210
- setup = exp.factory(self.cmdopts["exp_setup"])()
211
- rms, adds, chgs = utils.apply_to_expdef(setup, exp_def)
212
-
213
- # Write time setup info to file for later retrieval
214
- utils.pickle_modifications(adds, chgs, self.spec.exp_def_fpath)
215
-
216
- def _generate_threading(self, exp_def: definition.XMLExpDef) -> None:
217
- """Generate XML changes to set the # of cores for a simulation to use.
218
-
219
- This may be less than the total # available on the system, depending on
220
- the experiment definition and user preferences.
221
-
222
- Does not write generated changes to the simulation definition pickle
223
- file.
224
-
225
- """
226
- self.logger.trace( # type: ignore
227
- "Generating changes for threading (all runs)")
228
- exp_def.attr_change(".//system",
229
- "threads",
230
- str(self.cmdopts["physics_n_engines"]))
231
-
232
- # Only valid on linux, per ARGoS, so we ely on the user to add this
233
- # attribute to the input file if it is applicable.
234
- if not exp_def.attr_get(".//system", "pin_threads_to_cores"):
235
- return
236
-
237
- if sys.platform != "linux":
238
- self.logger.critical((".//system/pin_threads_to_cores only "
239
- "valid on linux--configuration error?"))
240
- return
241
-
242
- # If you don't do this, you will get runtime errors in ARGoS when you
243
- # attempt to set thread affinity to a core that does not exist. This is
244
- # better than modifying ARGoS source to only pin threads to cores that
245
- # exist, because it implies a configuration error by the user, and
246
- # SIERRA should fail as a result (correctness by construction).
247
- if self.cmdopts['physics_n_engines'] > psutil.cpu_count():
248
- self.logger.warning(("Disabling pinning threads to cores: "
249
- "mores threads than cores! %s > %s"),
250
- self.cmdopts['physics_n_engines'],
251
- psutil.cpu_count())
252
- exp_def.attr_change(".//system",
253
- "pin_threads_to_cores",
254
- "false")
255
-
256
- else:
257
- exp_def.attr_change(".//system",
258
- "pin_threads_to_cores",
259
- "true")
260
-
261
- def _generate_library(self, exp_def: definition.XMLExpDef) -> None:
262
- """Generate XML changes for ARGoS search paths for controller,loop functions.
263
-
264
- Set to the name of the plugin passed on the cmdline, unless overriden in
265
- configuration. The ``__CONTROLLER__`` tag is changed during stage 1, but
266
- since this function is called as part of common def generation, it
267
- happens BEFORE that, and so this is OK. If, for some reason that
268
- assumption becomes invalid, a warning will be issued about a
269
- non-existent XML path, so it won't be a silent error.
270
-
271
- Does not write generated changes to the simulation definition pickle
272
- file.
273
-
274
- """
275
- self.logger.trace( # type: ignore
276
- "Generating changes for library (all runs)")
277
- run_config = self.spec.criteria.main_config['sierra']['run']
278
- lib_name = run_config.get('library_name',
279
- 'lib' + self.cmdopts['project'])
280
- exp_def.attr_change(".//loop_functions",
281
- "library",
282
- lib_name)
283
- exp_def.attr_change(".//__CONTROLLER__",
284
- "library",
285
- lib_name)
286
-
287
- def _generate_visualization(self, exp_def: definition.XMLExpDef) -> None:
288
- """Generate XML changes to remove visualization elements from input file.
289
-
290
- This depends on cmdline parameters, as visualization definitions should
291
- be left in if ARGoS should output simulation frames for video creation.
292
-
293
- Does not write generated changes to the simulation definition pickle
294
- file.
295
-
296
- """
297
- self.logger.trace(("Generating changes for " # type: ignore
298
- "visualization (all runs)"))
299
-
300
- if not self.cmdopts["platform_vc"]:
301
- # ARGoS visualizations
302
- exp_def.tag_remove(".", "./visualization", noprint=True)
303
- else:
304
- self.logger.debug('Frame grabbing enabled')
305
- # Rendering must be processing before cameras, because it deletes
306
- # the <qt_opengl> tag if it exists, and then re-adds it.
307
- render = rendering.factory(self.cmdopts)
308
- utils.apply_to_expdef(render, exp_def)
309
-
310
- cams = cameras.factory(self.cmdopts, [self.spec.arena_dim])
311
- utils.apply_to_expdef(cams, exp_def)
312
-
313
-
314
- class PlatformExpRunDefUniqueGenerator:
315
- """Generate XML changes unique to each experimental run.
316
-
317
- These include:
318
-
319
- - Random seeds for each simulation.
320
-
321
- Attributes:
322
-
323
- run_num: The runulation # in the experiment.
324
-
325
- run_output_path: Path to simulation output directory within experiment
326
- root.
327
-
328
- cmdopts: Dictionary containing parsed cmdline options.
329
-
330
- """
331
-
332
- def __init__(self,
333
- run_num: int,
334
- run_output_path: pathlib.Path,
335
- launch_stem_path: pathlib.Path,
336
- random_seed: int,
337
- cmdopts: types.Cmdopts) -> None:
338
-
339
- self.run_output_path = run_output_path
340
- self.launch_stem_path = launch_stem_path
341
- self.cmdopts = cmdopts
342
- self.run_num = run_num
343
- self.random_seed = random_seed
344
- self.logger = logging.getLogger(__name__)
345
-
346
- def __generate_random(self, exp_def) -> None:
347
- """
348
- Generate XML changes for random seeding for a specific simulation.
349
- """
350
- self.logger.trace("Generating random seed changes for run%s", # type: ignore
351
- self.run_num)
352
-
353
- # Set the random seed in the input file
354
- exp_def.attr_change(".//experiment",
355
- "random_seed",
356
- str(self.random_seed))
357
-
358
- def generate(self, exp_def: definition.XMLExpDef):
359
- # Setup simulation random seed
360
- self.__generate_random(exp_def)
361
-
362
- # Setup simulation visualization output
363
- self.__generate_visualization(exp_def)
364
-
365
- def __generate_visualization(self, exp_def: definition.XMLExpDef):
366
- """
367
- Generate XML changes for setting up rendering for a specific simulation.
368
- """
369
- self.logger.trace("Generating visualization changes for run%s", # type: ignore
370
- self.run_num)
371
-
372
- if self.cmdopts['platform_vc']:
373
- argos = config.kRendering['argos']
374
- frames_fpath = self.run_output_path / argos['frames_leaf']
375
- exp_def.attr_change(".//qt-opengl/frame_grabbing",
376
- "directory",
377
- str(frames_fpath)) # probably will not be present
378
-
379
-
380
- __api__ = [
381
- 'PlatformExpDefGenerator',
382
- 'PlatformExpRunDefUniqueGenerator'
383
- ]