sierra-research 1.3.6__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.6.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 -249
- sierra/core/graphs/stacked_surface_graph.py +0 -220
- sierra/core/graphs/summary_line_graph.py +0 -369
- 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 -319
- 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.6.data/data/share/man/man1/sierra-cli.1 +0 -2349
- sierra_research-1.3.6.data/data/share/man/man7/sierra-examples.7 +0 -488
- sierra_research-1.3.6.data/data/share/man/man7/sierra-exec-envs.7 +0 -331
- sierra_research-1.3.6.data/data/share/man/man7/sierra-glossary.7 +0 -285
- sierra_research-1.3.6.data/data/share/man/man7/sierra-platforms.7 +0 -358
- sierra_research-1.3.6.data/data/share/man/man7/sierra-usage.7 +0 -725
- sierra_research-1.3.6.data/data/share/man/man7/sierra.7 +0 -78
- sierra_research-1.3.6.dist-info/METADATA +0 -500
- sierra_research-1.3.6.dist-info/RECORD +0 -133
- sierra_research-1.3.6.dist-info/top_level.txt +0 -1
- {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info}/entry_points.txt +0 -0
- {sierra_research-1.3.6.dist-info → sierra_research-1.5.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,328 +0,0 @@
|
|
1
|
-
# Copyright 2019 John Harwell, All rights reserved.
|
2
|
-
#
|
3
|
-
# SPDX-License-Identifier: MIT
|
4
|
-
|
5
|
-
"""Classes for comparing deliverables across a set of scenarios.
|
6
|
-
|
7
|
-
Univariate batch criteria only. The same controller must be used for all
|
8
|
-
scenarios.
|
9
|
-
|
10
|
-
"""
|
11
|
-
|
12
|
-
# Core packages
|
13
|
-
import os
|
14
|
-
import copy
|
15
|
-
import typing as tp
|
16
|
-
import argparse
|
17
|
-
import logging
|
18
|
-
import pathlib
|
19
|
-
|
20
|
-
# 3rd party packages
|
21
|
-
import pandas as pd
|
22
|
-
|
23
|
-
# Project packages
|
24
|
-
from sierra.core.graphs.summary_line_graph import SummaryLineGraph
|
25
|
-
from sierra.core.variables import batch_criteria as bc
|
26
|
-
import sierra.core.root_dirpath_generator as rdg
|
27
|
-
import sierra.core.plugin_manager as pm
|
28
|
-
from sierra.core import types, utils, config, storage
|
29
|
-
|
30
|
-
|
31
|
-
class UnivarInterScenarioComparator:
|
32
|
-
"""Compares a single controller across a set of scenarios.
|
33
|
-
|
34
|
-
Graph generation is controlled via a config file parsed in
|
35
|
-
:class:`~sierra.core.pipeline.stage5.pipeline_stage5.PipelineStage5`.
|
36
|
-
|
37
|
-
Univariate batch criteria only.
|
38
|
-
|
39
|
-
Attributes:
|
40
|
-
|
41
|
-
controller: Controller to use.
|
42
|
-
|
43
|
-
scenarios: List of scenario names to compare ``controller`` across.
|
44
|
-
|
45
|
-
sc_csv_root: Absolute directory path to the location scenario CSV
|
46
|
-
files should be output to.
|
47
|
-
|
48
|
-
sc_graph_root: Absolute directory path to the location the generated
|
49
|
-
graphs should be output to.
|
50
|
-
|
51
|
-
cmdopts: Dictionary of parsed cmdline parameters.
|
52
|
-
|
53
|
-
cli_args: :class:`argparse` object containing the cmdline
|
54
|
-
parameters. Needed for
|
55
|
-
:class:`~sierra.core.variables.batch_criteria.BatchCriteria`
|
56
|
-
generation for each scenario controllers are compared within,
|
57
|
-
as batch criteria is dependent on controller+scenario
|
58
|
-
definition, and needs to be re-generated for each scenario in
|
59
|
-
order to get graph labels/axis ticks to come out right in all
|
60
|
-
cases.
|
61
|
-
|
62
|
-
"""
|
63
|
-
|
64
|
-
def __init__(self,
|
65
|
-
controller: str,
|
66
|
-
scenarios: tp.List[str],
|
67
|
-
roots: tp.Dict[str, pathlib.Path],
|
68
|
-
cmdopts: types.Cmdopts,
|
69
|
-
cli_args: argparse.Namespace,
|
70
|
-
main_config: types.YAMLDict) -> None:
|
71
|
-
self.controller = controller
|
72
|
-
self.scenarios = scenarios
|
73
|
-
self.sc_graph_root = roots['graphs']
|
74
|
-
self.sc_csv_root = roots['csvs']
|
75
|
-
self.sc_model_root = roots['models']
|
76
|
-
|
77
|
-
self.cmdopts = cmdopts
|
78
|
-
self.cli_args = cli_args
|
79
|
-
self.main_config = main_config
|
80
|
-
self.logger = logging.getLogger(__name__)
|
81
|
-
|
82
|
-
def __call__(self,
|
83
|
-
graphs: tp.List[types.YAMLDict],
|
84
|
-
legend: tp.List[str]) -> None:
|
85
|
-
# Obtain the list of experimental run results directories to draw from.
|
86
|
-
batch_leaves = os.listdir(pathlib.Path(self.cmdopts['sierra_root'],
|
87
|
-
self.cmdopts['project'],
|
88
|
-
self.controller))
|
89
|
-
|
90
|
-
# The FS gives us batch leaves which might not be in the same order as
|
91
|
-
# the list of specified scenarios, so we:
|
92
|
-
#
|
93
|
-
# 1. Remove all batch leaves which do not have a counterpart in the
|
94
|
-
# scenario list we are comparing across.
|
95
|
-
#
|
96
|
-
# 2. Do matching to get the indices of the batch leaves relative to the
|
97
|
-
# list, and then sort it.
|
98
|
-
batch_leaves = [
|
99
|
-
leaf for leaf in batch_leaves for s in self.scenarios if s in leaf]
|
100
|
-
indices = [self.scenarios.index(s)
|
101
|
-
for leaf in batch_leaves for s in self.scenarios if s in leaf]
|
102
|
-
batch_leaves = [leaf for s, leaf in sorted(zip(indices, batch_leaves),
|
103
|
-
key=lambda pair: pair[0])]
|
104
|
-
|
105
|
-
# For each controller comparison graph we are interested in, generate it
|
106
|
-
# using data from all scenarios
|
107
|
-
cmdopts = copy.deepcopy(self.cmdopts)
|
108
|
-
for graph in graphs:
|
109
|
-
for leaf in batch_leaves:
|
110
|
-
if self._leaf_select(leaf):
|
111
|
-
self._compare_across_scenarios(cmdopts=cmdopts,
|
112
|
-
graph=graph,
|
113
|
-
batch_leaf=leaf,
|
114
|
-
legend=legend)
|
115
|
-
else:
|
116
|
-
self.logger.debug("Skipping '%s': not in scenario list %s/does not match %s",
|
117
|
-
leaf,
|
118
|
-
self.scenarios,
|
119
|
-
self.cli_args.batch_criteria)
|
120
|
-
|
121
|
-
def _leaf_select(self, candidate: str) -> bool:
|
122
|
-
"""Figure out if a batch experiment root should be included in the comparison.
|
123
|
-
|
124
|
-
Inclusion determined by if a scenario that the selected controller has
|
125
|
-
been run on in the past is part of the set passed that the controller
|
126
|
-
should be compared across (i.e., the controller is not compared across
|
127
|
-
all scenarios it has ever been run on).
|
128
|
-
|
129
|
-
"""
|
130
|
-
template_stem, scenario, _ = rdg.parse_batch_leaf(candidate)
|
131
|
-
leaf = rdg.gen_batch_leaf(criteria=self.cli_args.batch_criteria,
|
132
|
-
scenario=scenario,
|
133
|
-
template_stem=template_stem)
|
134
|
-
return leaf in candidate and scenario in self.scenarios
|
135
|
-
|
136
|
-
def _compare_across_scenarios(self,
|
137
|
-
cmdopts: types.Cmdopts,
|
138
|
-
graph: types.YAMLDict,
|
139
|
-
batch_leaf: str,
|
140
|
-
legend: tp.List[str]) -> None:
|
141
|
-
|
142
|
-
# We need to generate the root directory paths for each batch
|
143
|
-
# experiment (which # lives inside of the scenario dir), because they
|
144
|
-
# are all different. We need generate these paths for EACH controller,
|
145
|
-
# because the controller is part of the batch root path.
|
146
|
-
paths = rdg.regen_from_exp(sierra_rpath=self.cli_args.sierra_root,
|
147
|
-
project=self.cli_args.project,
|
148
|
-
batch_leaf=batch_leaf,
|
149
|
-
controller=self.controller)
|
150
|
-
cmdopts.update(paths)
|
151
|
-
|
152
|
-
# For each scenario, we have to create the batch criteria for it,
|
153
|
-
# because they are all different.
|
154
|
-
criteria = bc.factory(self.main_config,
|
155
|
-
cmdopts,
|
156
|
-
self.cli_args,
|
157
|
-
self.scenarios[0])
|
158
|
-
|
159
|
-
self._gen_csvs(cmdopts=cmdopts,
|
160
|
-
batch_leaf=batch_leaf,
|
161
|
-
src_stem=graph['src_stem'],
|
162
|
-
dest_stem=graph['dest_stem'])
|
163
|
-
|
164
|
-
self._gen_graph(criteria=criteria,
|
165
|
-
cmdopts=cmdopts,
|
166
|
-
dest_stem=graph['dest_stem'],
|
167
|
-
inc_exps=graph.get('include_exp', None),
|
168
|
-
title=graph.get('title', None),
|
169
|
-
label=graph['label'],
|
170
|
-
legend=legend)
|
171
|
-
|
172
|
-
def _gen_graph(self,
|
173
|
-
criteria: bc.IConcreteBatchCriteria,
|
174
|
-
cmdopts: types.Cmdopts,
|
175
|
-
dest_stem: str,
|
176
|
-
inc_exps: tp.Optional[str],
|
177
|
-
title: str,
|
178
|
-
label: str,
|
179
|
-
legend: tp.List[str]) -> None:
|
180
|
-
"""Generate graph comparing the specified controller across scenarios.
|
181
|
-
|
182
|
-
"""
|
183
|
-
istem = dest_stem + "-" + self.controller
|
184
|
-
img_opath = pathlib.Path(self.sc_graph_root,
|
185
|
-
dest_stem + '-' + self.controller + config.kImageExt)
|
186
|
-
|
187
|
-
xticks = criteria.graph_xticks(cmdopts)
|
188
|
-
xtick_labels = criteria.graph_xticklabels(cmdopts)
|
189
|
-
|
190
|
-
if inc_exps is not None:
|
191
|
-
xtick_labels = utils.exp_include_filter(inc_exps,
|
192
|
-
xtick_labels,
|
193
|
-
criteria.n_exp())
|
194
|
-
xticks = utils.exp_include_filter(
|
195
|
-
inc_exps, xticks, criteria.n_exp())
|
196
|
-
|
197
|
-
SummaryLineGraph(stats_root=self.sc_csv_root,
|
198
|
-
input_stem=istem,
|
199
|
-
stats=cmdopts['dist_stats'],
|
200
|
-
output_fpath=img_opath,
|
201
|
-
model_root=self.sc_model_root,
|
202
|
-
title=title,
|
203
|
-
xlabel=criteria.graph_xlabel(cmdopts),
|
204
|
-
ylabel=label,
|
205
|
-
xticks=xticks,
|
206
|
-
xtick_labels=xtick_labels,
|
207
|
-
logyscale=cmdopts['plot_log_yscale'],
|
208
|
-
large_text=cmdopts['plot_large_text'],
|
209
|
-
legend=legend).generate()
|
210
|
-
|
211
|
-
def _gen_csvs(self,
|
212
|
-
cmdopts: types.Cmdopts,
|
213
|
-
batch_leaf: str,
|
214
|
-
src_stem: str,
|
215
|
-
dest_stem: str) -> None:
|
216
|
-
"""Generate a set of CSV files for use in inter-scenario graph generation.
|
217
|
-
|
218
|
-
Generates:
|
219
|
-
|
220
|
-
- ``.mean`` CSV file containing results for each scenario the controller
|
221
|
-
is being compared across, 1 per line.
|
222
|
-
|
223
|
-
- Stastics CSV files containing various statistics for the ``.mean`` CSV
|
224
|
-
file, 1 per line.
|
225
|
-
|
226
|
-
- ``.model`` file containing model predictions for controller behavior
|
227
|
-
during each scenario, 1 per line (not generated if models were not run
|
228
|
-
the performance measures we are generating graphs for).
|
229
|
-
|
230
|
-
- ``.legend`` file containing legend values for models to plot (not
|
231
|
-
generated if models were not run for the performance measures we are
|
232
|
-
generating graphs for).
|
233
|
-
|
234
|
-
"""
|
235
|
-
|
236
|
-
csv_ipath_stem = pathlib.Path(cmdopts['batch_output_root'],
|
237
|
-
cmdopts['batch_stat_collate_root'],
|
238
|
-
src_stem)
|
239
|
-
|
240
|
-
# Some experiments might not generate the necessary performance measure
|
241
|
-
# CSVs for graph generation, which is OK.
|
242
|
-
csv_ipath_mean = csv_ipath_stem.with_suffix(
|
243
|
-
config.kStats['mean'].exts['mean'])
|
244
|
-
if not utils.path_exists(csv_ipath_mean):
|
245
|
-
self.logger.warning("%s missing for controller %s",
|
246
|
-
csv_ipath_mean,
|
247
|
-
self.controller)
|
248
|
-
return
|
249
|
-
|
250
|
-
opath_stem = pathlib.Path(self.sc_csv_root,
|
251
|
-
dest_stem + "-" + self.controller)
|
252
|
-
writer = storage.DataFrameWriter('storage.csv')
|
253
|
-
|
254
|
-
# Collect performance measure results. Append to existing dataframe if
|
255
|
-
# it exists, otherwise start a new one.
|
256
|
-
exts = config.kStats['mean'].exts
|
257
|
-
exts.update(config.kStats['conf95'].exts)
|
258
|
-
exts.update(config.kStats['bw'].exts)
|
259
|
-
|
260
|
-
for k in exts:
|
261
|
-
# Can't use with_suffix() for opath, because that path contains the
|
262
|
-
# controller, which already has a '.' in it.
|
263
|
-
csv_opath = opath_stem.with_name(opath_stem.name + exts[k])
|
264
|
-
csv_ipath = csv_ipath_stem.with_suffix(exts[k])
|
265
|
-
df = self._accum_df(csv_ipath, csv_opath, src_stem)
|
266
|
-
if df is not None:
|
267
|
-
writer(df, csv_opath, index=False)
|
268
|
-
|
269
|
-
# Collect performance results models and legends. Append to existing
|
270
|
-
# dataframes if they exist, otherwise start new ones.
|
271
|
-
# Can't use with_suffix() for opath, because that path contains the
|
272
|
-
# controller, which already has a '.' in it.
|
273
|
-
model_istem = pathlib.Path(cmdopts['batch_model_root'], src_stem)
|
274
|
-
model_ostem = pathlib.Path(self.sc_model_root,
|
275
|
-
dest_stem + "-" + self.controller)
|
276
|
-
|
277
|
-
model_ipath = model_istem.with_suffix(config.kModelsExt['model'])
|
278
|
-
model_opath = model_ostem.with_name(
|
279
|
-
model_ostem.name + config.kModelsExt['model'])
|
280
|
-
model_df = self._accum_df(model_ipath, model_opath, src_stem)
|
281
|
-
legend_opath = model_ostem.with_name(
|
282
|
-
model_ostem.name + config.kModelsExt['legend'])
|
283
|
-
|
284
|
-
if model_df is not None:
|
285
|
-
writer(model_df, model_opath, index=False)
|
286
|
-
|
287
|
-
with utils.utf8open(legend_opath, 'a') as f:
|
288
|
-
_, scenario, _ = rdg.parse_batch_leaf(batch_leaf)
|
289
|
-
sgp = pm.module_load_tiered(project=cmdopts['project'],
|
290
|
-
path='generators.scenario_generator_parser')
|
291
|
-
kw = sgp.ScenarioGeneratorParser().to_dict(scenario)
|
292
|
-
f.write("{0} Prediction\n".format(kw['scenario_tag']))
|
293
|
-
|
294
|
-
def _accum_df(self,
|
295
|
-
ipath: pathlib.Path,
|
296
|
-
opath: pathlib.Path,
|
297
|
-
src_stem: str) -> pd.DataFrame:
|
298
|
-
reader = storage.DataFrameReader('storage.csv')
|
299
|
-
|
300
|
-
if utils.path_exists(opath):
|
301
|
-
cum_df = reader(opath)
|
302
|
-
else:
|
303
|
-
cum_df = None
|
304
|
-
|
305
|
-
if utils.path_exists(ipath):
|
306
|
-
t = reader(ipath)
|
307
|
-
if cum_df is None:
|
308
|
-
cum_df = pd.DataFrame(columns=t.columns)
|
309
|
-
|
310
|
-
if len(t.index) != 1:
|
311
|
-
self.logger.warning(("'%s.csv' is a collated inter-experiment "
|
312
|
-
"not a summary inter-experiment csv: "
|
313
|
-
"# rows %s != 1"),
|
314
|
-
src_stem,
|
315
|
-
len(t.index))
|
316
|
-
self.logger.warning("Truncating '%s.csv' to last row", src_stem)
|
317
|
-
|
318
|
-
# Series are columns, so we have to transpose before concatenating
|
319
|
-
cum_df = pd.concat([cum_df,
|
320
|
-
t.loc[t.index[-1], :].to_frame().T])
|
321
|
-
|
322
|
-
# cum_df = cum_df.append(t.loc[t.index[-1], t.columns.to_list()])
|
323
|
-
return cum_df
|
324
|
-
|
325
|
-
return None
|
326
|
-
|
327
|
-
|
328
|
-
__api__ = ['UnivarInterScenarioComparator']
|