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