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,531 @@
|
|
1
|
+
# Copyright 2019 John Harwell, All rights reserved.
|
2
|
+
#
|
3
|
+
# SPDX-License-Identifier: MIT
|
4
|
+
|
5
|
+
"""Classes for comparing deliverables across controllers.
|
6
|
+
|
7
|
+
Batch criteria and scenario are the same across all compared controllers.
|
8
|
+
"""
|
9
|
+
|
10
|
+
# Core packages
|
11
|
+
import glob
|
12
|
+
import re
|
13
|
+
import typing as tp
|
14
|
+
import argparse
|
15
|
+
import logging
|
16
|
+
import pathlib
|
17
|
+
|
18
|
+
# 3rd party packages
|
19
|
+
|
20
|
+
# Project packages
|
21
|
+
from sierra.core.variables import batch_criteria as bc
|
22
|
+
from sierra.core import types, utils, config, batchroot, graphs
|
23
|
+
from sierra.plugins.compare.graphs import namecalc, preprocess, outputroot, comparator
|
24
|
+
|
25
|
+
|
26
|
+
class BaseInterControllerComparator(comparator.BaseComparator):
|
27
|
+
def __init__(
|
28
|
+
self,
|
29
|
+
controllers: tp.List[str],
|
30
|
+
stage5_roots: outputroot.PathSet,
|
31
|
+
cmdopts: types.Cmdopts,
|
32
|
+
cli_args: argparse.Namespace,
|
33
|
+
main_config: types.YAMLDict,
|
34
|
+
) -> None:
|
35
|
+
super().__init__(controllers, stage5_roots, cmdopts, cli_args, main_config)
|
36
|
+
self.logger = logging.getLogger(__name__)
|
37
|
+
|
38
|
+
def exp_select(self) -> tp.List[batchroot.ExpRoot]:
|
39
|
+
"""Determine if a controller can be included in the comparison for a scenario."""
|
40
|
+
# Obtain the raw list of batch experiments to use. We can just take the
|
41
|
+
# scenario list of the first THING, because we have already checked that
|
42
|
+
# all things were executed in the same context, and if there were any
|
43
|
+
# warnings which will cause crashes at this stage, the user will have
|
44
|
+
# been warned.
|
45
|
+
selected = []
|
46
|
+
for controller in self.things:
|
47
|
+
for scenario in (self.project_root / self.things[0]).iterdir():
|
48
|
+
for candidate in scenario.iterdir():
|
49
|
+
root = batchroot.ExpRoot(
|
50
|
+
sierra_root=self.cmdopts["sierra_root"],
|
51
|
+
project=self.cmdopts["project"],
|
52
|
+
controller=controller,
|
53
|
+
leaf=batchroot.ExpRootLeaf.from_name(candidate.name),
|
54
|
+
scenario=str(scenario),
|
55
|
+
)
|
56
|
+
if root.to_path().exists():
|
57
|
+
selected.append(root)
|
58
|
+
return selected
|
59
|
+
|
60
|
+
|
61
|
+
class UnivarInterControllerComparator(BaseInterControllerComparator):
|
62
|
+
"""Compares a set of controllers within each of a set of scenarios.
|
63
|
+
|
64
|
+
Graph generation
|
65
|
+
is controlled via a config file parsed in
|
66
|
+
:class:`~sierra.core.pipeline.stage5.pipeline_stage5.PipelineStage5`.
|
67
|
+
|
68
|
+
Univariate batch criteria only.
|
69
|
+
|
70
|
+
Attributes:
|
71
|
+
controllers: List of controller names to compare.
|
72
|
+
|
73
|
+
stage5_roots: Set of directory paths for stage 5 file generation.
|
74
|
+
|
75
|
+
cmdopts: Dictionary of parsed cmdline parameters.
|
76
|
+
|
77
|
+
cli_args: :class:`argparse` object containing the cmdline
|
78
|
+
parameters. Needed for
|
79
|
+
:class:`~sierra.core.variables.batch_criteria.XVarBatchCriteria`
|
80
|
+
generation for each scenario controllers are compared within,
|
81
|
+
as batch criteria is dependent on controller+scenario
|
82
|
+
definition, and needs to be re-generated for each scenario in
|
83
|
+
order to get graph labels/axis ticks to come out right in all
|
84
|
+
cases.
|
85
|
+
|
86
|
+
"""
|
87
|
+
|
88
|
+
def __init__(
|
89
|
+
self,
|
90
|
+
controllers: tp.List[str],
|
91
|
+
stage5_roots: outputroot.PathSet,
|
92
|
+
cmdopts: types.Cmdopts,
|
93
|
+
cli_args: argparse.Namespace,
|
94
|
+
main_config: types.YAMLDict,
|
95
|
+
) -> None:
|
96
|
+
super().__init__(controllers, stage5_roots, cmdopts, cli_args, main_config)
|
97
|
+
|
98
|
+
def compare(
|
99
|
+
self,
|
100
|
+
cmdopts: types.Cmdopts,
|
101
|
+
graph: types.YAMLDict,
|
102
|
+
roots: tp.List[batchroot.ExpRoot],
|
103
|
+
legend: tp.List[str],
|
104
|
+
) -> None:
|
105
|
+
|
106
|
+
for controller in self.things:
|
107
|
+
valid_configurations = sum(r.controller == controller for r in roots)
|
108
|
+
if valid_configurations > 1:
|
109
|
+
self.logger.warning(
|
110
|
+
"Skipping ambiguous comparison for controller %s: was run on multiple selected batch roots %s",
|
111
|
+
controller,
|
112
|
+
[r.to_str() for r in roots],
|
113
|
+
)
|
114
|
+
continue
|
115
|
+
|
116
|
+
if valid_configurations == 0:
|
117
|
+
self.logger.warning(
|
118
|
+
"Skipping comparison for controller %s: not run on any selected batch roots %s",
|
119
|
+
controller,
|
120
|
+
[r.to_str() for r in roots],
|
121
|
+
)
|
122
|
+
continue
|
123
|
+
|
124
|
+
# Each controller should have been run on exactly ONE batch
|
125
|
+
# experiment that we selected for controller comparison, by
|
126
|
+
# definition.
|
127
|
+
root = next(r for r in roots if r.controller == controller)
|
128
|
+
|
129
|
+
# We need to generate the root directory paths for each batch
|
130
|
+
# experiment (which # lives inside of the scenario dir), because
|
131
|
+
# they are all different. We need generate these paths for EACH
|
132
|
+
# controller, because the controller is part of the batch root path.
|
133
|
+
pathset = batchroot.from_exp(
|
134
|
+
sierra_root=self.cli_args.sierra_root,
|
135
|
+
project=self.cli_args.project,
|
136
|
+
batch_leaf=root.leaf,
|
137
|
+
controller=controller,
|
138
|
+
scenario=root.scenario,
|
139
|
+
)
|
140
|
+
|
141
|
+
# For each scenario, we have to create the batch criteria for it,
|
142
|
+
# because they are all different.
|
143
|
+
criteria = bc.factory(
|
144
|
+
self.main_config,
|
145
|
+
cmdopts,
|
146
|
+
pathset.input_root,
|
147
|
+
self.cli_args,
|
148
|
+
root.scenario,
|
149
|
+
)
|
150
|
+
|
151
|
+
# We incrementally generate the CSV, adding a new column for each
|
152
|
+
# controller as we iterate.
|
153
|
+
self._accum_csv(
|
154
|
+
batch_leaf=root.leaf,
|
155
|
+
criteria=criteria,
|
156
|
+
pathset=pathset,
|
157
|
+
controller=controller,
|
158
|
+
src_stem=graph["src_stem"],
|
159
|
+
dest_stem=graph["dest_stem"],
|
160
|
+
index=graph.get("index", -1),
|
161
|
+
inc_exps=graph.get("include_exp", None),
|
162
|
+
)
|
163
|
+
|
164
|
+
# After the CSV has been generated, we can generate the graph. We can
|
165
|
+
# use any controller when computing the batch leaf, since they are all
|
166
|
+
# the same in this comparison, by definition.
|
167
|
+
root = next(r for r in roots if r.controller == self.things[0])
|
168
|
+
self._gen_graph(
|
169
|
+
batch_leaf=root.leaf,
|
170
|
+
criteria=criteria,
|
171
|
+
cmdopts=cmdopts,
|
172
|
+
batch_output_root=pathset.output_root,
|
173
|
+
dest_stem=graph["dest_stem"],
|
174
|
+
title=graph.get("title", ""),
|
175
|
+
label=graph.get("label", ""),
|
176
|
+
inc_exps=graph.get("include_exp", None),
|
177
|
+
legend=legend,
|
178
|
+
backend=graph.get("backend", cmdopts["graphs_backend"]),
|
179
|
+
)
|
180
|
+
|
181
|
+
def _accum_csv(
|
182
|
+
self,
|
183
|
+
batch_leaf: batchroot.ExpRootLeaf,
|
184
|
+
criteria: bc.XVarBatchCriteria,
|
185
|
+
pathset: batchroot.PathSet,
|
186
|
+
controller: str,
|
187
|
+
src_stem: str,
|
188
|
+
dest_stem: str,
|
189
|
+
index: int,
|
190
|
+
inc_exps: tp.Optional[str],
|
191
|
+
) -> None:
|
192
|
+
"""Accumulate info in a CSV file for inter-controller comparison."""
|
193
|
+
self.logger.debug(
|
194
|
+
"Gathering data for %s from %s -> %s", controller, src_stem, dest_stem
|
195
|
+
)
|
196
|
+
ipath = pathset.stat_interexp_root / (
|
197
|
+
src_stem + config.kStats["mean"].exts["mean"]
|
198
|
+
)
|
199
|
+
|
200
|
+
# Some experiments might not generate the necessary performance measure
|
201
|
+
# .csvs for graph generation, which is OK.
|
202
|
+
if not utils.path_exists(ipath):
|
203
|
+
self.logger.warning("%s missing for controller %s", ipath, controller)
|
204
|
+
return
|
205
|
+
|
206
|
+
preparer = preprocess.IntraExpPreparer(
|
207
|
+
ipath_stem=pathset.stat_interexp_root,
|
208
|
+
ipath_leaf=src_stem,
|
209
|
+
opath_stem=self.stage5_roots.csv_root,
|
210
|
+
criteria=criteria,
|
211
|
+
)
|
212
|
+
opath_leaf = namecalc.for_cc(batch_leaf, dest_stem, None)
|
213
|
+
preparer.for_cc(
|
214
|
+
controller=controller, opath_leaf=opath_leaf, index=index, inc_exps=inc_exps
|
215
|
+
)
|
216
|
+
|
217
|
+
def _gen_graph(
|
218
|
+
self,
|
219
|
+
batch_leaf: batchroot.ExpRootLeaf,
|
220
|
+
criteria: bc.XVarBatchCriteria,
|
221
|
+
cmdopts: types.Cmdopts,
|
222
|
+
batch_output_root: pathlib.Path,
|
223
|
+
dest_stem: str,
|
224
|
+
title: str,
|
225
|
+
label: str,
|
226
|
+
inc_exps: tp.Optional[str],
|
227
|
+
legend: tp.List[str],
|
228
|
+
backend: str,
|
229
|
+
) -> None:
|
230
|
+
"""Generate a graph comparing the specified controllers within a scenario."""
|
231
|
+
opath_leaf = namecalc.for_cc(batch_leaf, dest_stem, None)
|
232
|
+
|
233
|
+
info = criteria.graph_info(cmdopts, batch_output_root=batch_output_root)
|
234
|
+
|
235
|
+
if inc_exps is not None:
|
236
|
+
xtick_labels = utils.exp_include_filter(
|
237
|
+
inc_exps, info.xticklabels, criteria.n_exp()
|
238
|
+
)
|
239
|
+
xticks = utils.exp_include_filter(inc_exps, info.xticks, criteria.n_exp())
|
240
|
+
|
241
|
+
paths = graphs.PathSet(
|
242
|
+
input_root=self.stage5_roots.csv_root,
|
243
|
+
output_root=self.stage5_roots.graph_root,
|
244
|
+
batchroot=pathlib.Path(
|
245
|
+
self.cmdopts["sierra_root"], self.cmdopts["project"]
|
246
|
+
),
|
247
|
+
model_root=None,
|
248
|
+
)
|
249
|
+
|
250
|
+
graphs.summary_line(
|
251
|
+
paths=paths,
|
252
|
+
input_stem=opath_leaf,
|
253
|
+
output_stem=opath_leaf,
|
254
|
+
stats=cmdopts["dist_stats"],
|
255
|
+
medium="storage.csv",
|
256
|
+
title=title,
|
257
|
+
xlabel=info.xlabel,
|
258
|
+
ylabel=label,
|
259
|
+
backend=backend,
|
260
|
+
xticklabels=xtick_labels,
|
261
|
+
xticks=xticks,
|
262
|
+
logyscale=cmdopts["plot_log_yscale"],
|
263
|
+
large_text=self.cmdopts["plot_large_text"],
|
264
|
+
legend=legend,
|
265
|
+
)
|
266
|
+
|
267
|
+
|
268
|
+
class BivarInterControllerComparator(BaseInterControllerComparator):
|
269
|
+
"""Compares a set of controllers within each of a set of scenarios.
|
270
|
+
|
271
|
+
Graph generation is controlled via a config file
|
272
|
+
parsed in
|
273
|
+
:class:`~sierra.core.pipeline.stage5.pipeline_stage5.PipelineStage5`.
|
274
|
+
|
275
|
+
Bivariate batch criteria only.
|
276
|
+
|
277
|
+
Attributes:
|
278
|
+
controllers: List of controller names to compare.
|
279
|
+
|
280
|
+
cmdopts: Dictionary of parsed cmdline parameters.
|
281
|
+
|
282
|
+
cli_args: :class:`argparse` object containing the cmdline
|
283
|
+
parameters. Needed for
|
284
|
+
:class:`~sierra.core.variables.batch_criteria.XVarBatchCriteria`
|
285
|
+
generation for each scenario controllers are compared within,
|
286
|
+
as batch criteria is dependent on controller+scenario
|
287
|
+
definition, and needs to be re-generated for each scenario in
|
288
|
+
order to get graph labels/axis ticks to come out right in all
|
289
|
+
cases.
|
290
|
+
"""
|
291
|
+
|
292
|
+
def __init__(
|
293
|
+
self,
|
294
|
+
controllers: tp.List[str],
|
295
|
+
stage5_roots: outputroot.PathSet,
|
296
|
+
cmdopts: types.Cmdopts,
|
297
|
+
cli_args: argparse.Namespace,
|
298
|
+
main_config: types.YAMLDict,
|
299
|
+
) -> None:
|
300
|
+
super().__init__(controllers, stage5_roots, cmdopts, cli_args, main_config)
|
301
|
+
|
302
|
+
def compare(
|
303
|
+
self,
|
304
|
+
cmdopts: types.Cmdopts,
|
305
|
+
graph: types.YAMLDict,
|
306
|
+
roots: tp.List[batchroot.ExpRoot],
|
307
|
+
legend: tp.List[str],
|
308
|
+
) -> None:
|
309
|
+
|
310
|
+
for controller in self.things:
|
311
|
+
valid_configurations = sum(r.controller == controller for r in roots)
|
312
|
+
if valid_configurations > 1:
|
313
|
+
self.logger.warning(
|
314
|
+
"Skipping ambiguous comparison for controller %s: was run on multiple selected batch roots %s",
|
315
|
+
controller,
|
316
|
+
[r.to_str() for r in roots],
|
317
|
+
)
|
318
|
+
continue
|
319
|
+
|
320
|
+
if valid_configurations == 0:
|
321
|
+
self.logger.warning(
|
322
|
+
"Skipping comparison for controller %s: not run on any selected batch roots %s",
|
323
|
+
controller,
|
324
|
+
[r.to_str() for r in roots],
|
325
|
+
)
|
326
|
+
continue
|
327
|
+
|
328
|
+
# Each controller should have been run on exactly ONE batch
|
329
|
+
# experiment that we selected for controller comparison, by
|
330
|
+
# definition.
|
331
|
+
root = next(r for r in roots if r.controller == controller)
|
332
|
+
|
333
|
+
# We need to generate the root directory paths for each batch
|
334
|
+
# experiment (which # lives inside of the scenario dir), because
|
335
|
+
# they are all different. We need generate these paths for EACH
|
336
|
+
# controller, because the controller is part of the batch root path.
|
337
|
+
pathset = batchroot.from_exp(
|
338
|
+
sierra_root=self.cli_args.sierra_root,
|
339
|
+
project=self.cli_args.project,
|
340
|
+
batch_leaf=root.leaf,
|
341
|
+
controller=controller,
|
342
|
+
scenario=root.scenario,
|
343
|
+
)
|
344
|
+
|
345
|
+
# For each scenario, we have to create the batch criteria for it,
|
346
|
+
# because they are all different.
|
347
|
+
criteria = bc.factory(
|
348
|
+
self.main_config,
|
349
|
+
cmdopts,
|
350
|
+
pathset.input_root,
|
351
|
+
self.cli_args,
|
352
|
+
root.scenario,
|
353
|
+
)
|
354
|
+
|
355
|
+
if self.cli_args.comparison_type == "LNraw":
|
356
|
+
self._gen_csvs_for_1D(
|
357
|
+
cmdopts=cmdopts,
|
358
|
+
criteria=criteria,
|
359
|
+
pathset=pathset,
|
360
|
+
controller=controller,
|
361
|
+
batch_leaf=root.leaf,
|
362
|
+
src_stem=graph["src_stem"],
|
363
|
+
dest_stem=graph["dest_stem"],
|
364
|
+
primary_axis=graph.get("primary_axis", 0),
|
365
|
+
inc_exps=graph.get("include_exp", None),
|
366
|
+
index=graph.get("index", -1),
|
367
|
+
)
|
368
|
+
|
369
|
+
if self.cli_args.comparison_type == "LNraw":
|
370
|
+
self._gen_graphs1D(
|
371
|
+
batch_leaf=root.leaf,
|
372
|
+
criteria=criteria,
|
373
|
+
cmdopts=cmdopts,
|
374
|
+
pathset=pathset,
|
375
|
+
dest_stem=graph["dest_stem"],
|
376
|
+
title=graph.get("title", ""),
|
377
|
+
label=graph.get("label", ""),
|
378
|
+
primary_axis=graph.get("primary_axis", 0),
|
379
|
+
inc_exps=graph.get("include_exp", None),
|
380
|
+
index=graph.get("index", -1),
|
381
|
+
legend=legend,
|
382
|
+
)
|
383
|
+
|
384
|
+
def _gen_csvs_for_1D(
|
385
|
+
self,
|
386
|
+
cmdopts: types.Cmdopts,
|
387
|
+
pathset: batchroot.PathSet,
|
388
|
+
criteria: bc.XVarBatchCriteria,
|
389
|
+
batch_leaf: batchroot.ExpRootLeaf,
|
390
|
+
controller: str,
|
391
|
+
src_stem: str,
|
392
|
+
dest_stem: str,
|
393
|
+
primary_axis: int,
|
394
|
+
index: int,
|
395
|
+
inc_exps: tp.Optional[str],
|
396
|
+
) -> None:
|
397
|
+
"""Generate a set of CSV files for use in intra-scenario graph generation.
|
398
|
+
|
399
|
+
Because we are targeting linegraphs, we draw the the i-th row/col (as
|
400
|
+
configured) from the performance results of each controller .csv, and
|
401
|
+
concatenate them into a new .csv file which can be given to
|
402
|
+
:func:`~sierra.core.graphs.summary_line`.
|
403
|
+
|
404
|
+
"""
|
405
|
+
self.logger.debug(
|
406
|
+
"Gathering data for '%s' from %s -> %s", controller, src_stem, dest_stem
|
407
|
+
)
|
408
|
+
|
409
|
+
csv_ipath = pathset.stat_interexp_root / (
|
410
|
+
src_stem + config.kStats["mean"].exts["mean"]
|
411
|
+
)
|
412
|
+
|
413
|
+
# Some experiments might not generate the necessary performance measure
|
414
|
+
# .csvs for graph generation, which is OK.
|
415
|
+
if not utils.path_exists(csv_ipath):
|
416
|
+
self.logger.warning("%s missing for controller '%s'", csv_ipath, controller)
|
417
|
+
return
|
418
|
+
|
419
|
+
if cmdopts["dist_stats"] != "none":
|
420
|
+
self.logger.warning(
|
421
|
+
(
|
422
|
+
"--dist-stats is not supported with "
|
423
|
+
"1D CSVs sliced from 2D CSV for linegraph "
|
424
|
+
"generation: no stats will be included"
|
425
|
+
)
|
426
|
+
)
|
427
|
+
|
428
|
+
if primary_axis == 0:
|
429
|
+
preparer = preprocess.IntraExpPreparer(
|
430
|
+
ipath_stem=pathset.stat_interexp_root,
|
431
|
+
ipath_leaf=src_stem,
|
432
|
+
opath_stem=self.stage5_roots.csv_root,
|
433
|
+
criteria=criteria,
|
434
|
+
)
|
435
|
+
|
436
|
+
opath_leaf = namecalc.for_cc(batch_leaf, dest_stem, [index])
|
437
|
+
preparer.for_cc(
|
438
|
+
controller, opath_leaf=opath_leaf, index=index, inc_exps=inc_exps
|
439
|
+
)
|
440
|
+
else:
|
441
|
+
preparer = preprocess.IntraExpPreparer(
|
442
|
+
ipath_stem=pathset.stat_interexp_root,
|
443
|
+
ipath_leaf=src_stem,
|
444
|
+
opath_stem=self.stage5_roots.csv_root,
|
445
|
+
criteria=criteria,
|
446
|
+
)
|
447
|
+
|
448
|
+
exp_dirs = criteria.gen_exp_names()
|
449
|
+
xlabels, ylabels = utils.bivar_exp_labels_calc(exp_dirs)
|
450
|
+
xlabels = utils.exp_include_filter(
|
451
|
+
inc_exps, xlabels, criteria.criteria1.n_exp()
|
452
|
+
)
|
453
|
+
|
454
|
+
for col in ylabels:
|
455
|
+
col_index = ylabels.index(col)
|
456
|
+
opath_leaf = namecalc.for_cc(batch_leaf, dest_stem, [col_index])
|
457
|
+
preparer.across_cols(
|
458
|
+
opath_leaf=opath_leaf,
|
459
|
+
col_index=col_index,
|
460
|
+
all_cols=xlabels,
|
461
|
+
inc_exps=inc_exps,
|
462
|
+
)
|
463
|
+
|
464
|
+
def _gen_graphs1D(
|
465
|
+
self,
|
466
|
+
batch_leaf: batchroot.ExpRootLeaf,
|
467
|
+
criteria: bc.XVarBatchCriteria,
|
468
|
+
pathset: batchroot.PathSet,
|
469
|
+
cmdopts: types.Cmdopts,
|
470
|
+
dest_stem: str,
|
471
|
+
title: str,
|
472
|
+
label: str,
|
473
|
+
primary_axis: int,
|
474
|
+
index: int,
|
475
|
+
inc_exps: tp.Optional[str],
|
476
|
+
legend: tp.List[str],
|
477
|
+
) -> None:
|
478
|
+
oleaf = namecalc.for_cc(batch_leaf, dest_stem, None)
|
479
|
+
csv_stem_root = self.stage5_roots.csv_root / oleaf
|
480
|
+
pattern = str(csv_stem_root) + "*" + config.kStats["mean"].exts["mean"]
|
481
|
+
paths = [f for f in glob.glob(pattern) if re.search("_[0-9]+", f)]
|
482
|
+
|
483
|
+
opath_leaf = namecalc.for_cc(batch_leaf, dest_stem, [index])
|
484
|
+
|
485
|
+
info = criteria.graph_info(cmdopts, batch_output_root=pathset.output_root)
|
486
|
+
if primary_axis == 0:
|
487
|
+
n_exp = criteria.criterias[0].n_exp()
|
488
|
+
yticks = info.yticks
|
489
|
+
xticks = utils.exp_include_filter(inc_exps, yticks, n_exp)
|
490
|
+
|
491
|
+
ytick_labels = info.yticklabels
|
492
|
+
xtick_labels = utils.exp_include_filter(inc_exps, ytick_labels, n_exp)
|
493
|
+
xlabel = info.ylabel
|
494
|
+
else:
|
495
|
+
n_exp = criteria.criterias[1].n_exp()
|
496
|
+
yticks = info.xticks
|
497
|
+
xticks = utils.exp_include_filter(inc_exps, yticks, n_exp)
|
498
|
+
|
499
|
+
ytick_labels = info.xticklabels
|
500
|
+
xtick_labels = utils.exp_include_filter(inc_exps, ytick_labels, n_exp)
|
501
|
+
xlabel = info.xlabel
|
502
|
+
|
503
|
+
# TODO: Fix no statistics support for these graphs
|
504
|
+
paths = graphs.PathSet(
|
505
|
+
input_root=self.stage5_roots.csv_root,
|
506
|
+
output_root=self.stage5_roots.graph_root,
|
507
|
+
batchroot=pathlib.Path(
|
508
|
+
self.cmdopts["sierra_root"], self.cmdopts["project"]
|
509
|
+
),
|
510
|
+
model_root=None,
|
511
|
+
)
|
512
|
+
|
513
|
+
graphs.summary_line(
|
514
|
+
paths=paths,
|
515
|
+
input_stem=opath_leaf,
|
516
|
+
output_stem=opath_leaf,
|
517
|
+
medium="storage.csv",
|
518
|
+
stats="none",
|
519
|
+
title=title,
|
520
|
+
xlabel=xlabel,
|
521
|
+
ylabel=label,
|
522
|
+
backend=cmdopts["graphs_backend"],
|
523
|
+
xticks=xticks,
|
524
|
+
xticklabels=xtick_labels,
|
525
|
+
legend=legend,
|
526
|
+
logyscale=cmdopts["plot_log_yscale"],
|
527
|
+
large_text=cmdopts["plot_large_text"],
|
528
|
+
)
|
529
|
+
|
530
|
+
|
531
|
+
__all__ = ["UnivarInterControllerComparator", "BivarInterControllerComparator"]
|