本文整理汇总了Python中openmdao.recorders.recording_manager.RecordingManager.record_metadata方法的典型用法代码示例。如果您正苦于以下问题:Python RecordingManager.record_metadata方法的具体用法?Python RecordingManager.record_metadata怎么用?Python RecordingManager.record_metadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openmdao.recorders.recording_manager.RecordingManager
的用法示例。
在下文中一共展示了RecordingManager.record_metadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Driver
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import record_metadata [as 别名]
class Driver(object):
"""
Top-level container for the systems and drivers.
Options
-------
options['debug_print'] : list of strings([])
Indicates what variables to print at each iteration. The valid options are:
'desvars','ln_cons','nl_cons',and 'objs'.
recording_options['record_metadata'] : bool(True)
Tells recorder whether to record variable attribute metadata.
recording_options['record_desvars'] : bool(True)
Tells recorder whether to record the desvars of the Driver.
recording_options['record_responses'] : bool(False)
Tells recorder whether to record the responses of the Driver.
recording_options['record_objectives'] : bool(False)
Tells recorder whether to record the objectives of the Driver.
recording_options['record_constraints'] : bool(False)
Tells recorder whether to record the constraints of the Driver.
recording_options['includes'] : list of strings("*")
Patterns for variables to include in recording.
recording_options['excludes'] : list of strings('')
Patterns for variables to exclude in recording (processed after includes).
Attributes
----------
fail : bool
Reports whether the driver ran successfully.
iter_count : int
Keep track of iterations for case recording.
metadata : list
List of metadata
options : <OptionsDictionary>
Dictionary with general pyoptsparse options.
recording_options : <OptionsDictionary>
Dictionary with driver recording options.
debug_print : <OptionsDictionary>
Dictionary with debugging printing options.
cite : str
Listing of relevant citataions that should be referenced when
publishing work that uses this class.
_problem : <Problem>
Pointer to the containing problem.
supports : <OptionsDictionary>
Provides a consistant way for drivers to declare what features they support.
_designvars : dict
Contains all design variable info.
_cons : dict
Contains all constraint info.
_objs : dict
Contains all objective info.
_responses : dict
Contains all response info.
_rec_mgr : <RecordingManager>
Object that manages all recorders added to this driver.
_vars_to_record: dict
Dict of lists of var names indicating what to record
_model_viewer_data : dict
Structure of model, used to make n2 diagram.
_remote_dvs : dict
Dict of design variables that are remote on at least one proc. Values are
(owning rank, size).
_remote_cons : dict
Dict of constraints that are remote on at least one proc. Values are
(owning rank, size).
_remote_objs : dict
Dict of objectives that are remote on at least one proc. Values are
(owning rank, size).
_remote_responses : dict
A combined dict containing entries from _remote_cons and _remote_objs.
_simul_coloring_info : tuple of dicts
A data structure describing coloring for simultaneous derivs.
_res_jacs : dict
Dict of sparse subjacobians for use with certain optimizers, e.g. pyOptSparseDriver.
"""
def __init__(self):
"""
Initialize the driver.
"""
self._rec_mgr = RecordingManager()
self._vars_to_record = {
'desvarnames': set(),
'responsenames': set(),
'objectivenames': set(),
'constraintnames': set(),
'sysinclnames': set(),
}
self._problem = None
self._designvars = None
self._cons = None
self._objs = None
self._responses = None
self.options = OptionsDictionary()
self.recording_options = OptionsDictionary()
###########################
self.options.declare('debug_print', types=list, is_valid=_is_debug_print_opts_valid,
#.........这里部分代码省略.........
示例2: Solver
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import record_metadata [as 别名]
class Solver(object):
"""
Base solver class.
This class is subclassed by NonlinearSolver and LinearSolver,
which are in turn subclassed by actual solver implementations.
Attributes
----------
_system : <System>
Pointer to the owning system.
_depth : int
How many subsolvers deep this solver is (0 means not a subsolver).
_vec_names : [str, ...]
List of right-hand-side (RHS) vector names.
_mode : str
'fwd' or 'rev', applicable to linear solvers only.
_iter_count : int
Number of iterations for the current invocation of the solver.
_rec_mgr : <RecordingManager>
object that manages all recorders added to this solver
cite : str
Listing of relevant citations that should be referenced when
publishing work that uses this class.
options : <OptionsDictionary>
Options dictionary.
recording_options : <OptionsDictionary>
Recording options dictionary.
supports : <OptionsDictionary>
Options dictionary describing what features are supported by this
solver.
_filtered_vars_to_record: Dict
Dict of list of var names to record
_norm0: float
Normalization factor
_solver_info : SolverInfo
A stack-like object shared by all Solvers in the model.
"""
# Object to store some formatting for iprint that is shared across all solvers.
SOLVER = 'base_solver'
def __init__(self, **kwargs):
"""
Initialize all attributes.
Parameters
----------
**kwargs : dict of keyword arguments
Keyword arguments that will be mapped into the Solver options.
"""
self._system = None
self._depth = 0
self._vec_names = None
self._mode = 'fwd'
self._iter_count = 0
self._solver_info = None
# Solver options
self.options = OptionsDictionary()
self.options.declare('maxiter', types=int, default=10,
desc='maximum number of iterations')
self.options.declare('atol', default=1e-10,
desc='absolute error tolerance')
self.options.declare('rtol', default=1e-10,
desc='relative error tolerance')
self.options.declare('iprint', types=int, default=1,
desc='whether to print output')
self.options.declare('err_on_maxiter', types=bool, default=False,
desc="When True, AnalysisError will be raised if we don't converge.")
# Case recording options
self.recording_options = OptionsDictionary()
self.recording_options.declare('record_abs_error', types=bool, default=True,
desc='Set to True to record absolute error at the \
solver level')
self.recording_options.declare('record_rel_error', types=bool, default=True,
desc='Set to True to record relative error at the \
solver level')
self.recording_options.declare('record_inputs', types=bool, default=True,
desc='Set to True to record inputs at the solver level')
self.recording_options.declare('record_outputs', types=bool, default=True,
desc='Set to True to record outputs at the solver level')
self.recording_options.declare('record_solver_residuals', types=bool, default=False,
desc='Set to True to record residuals at the solver level')
self.recording_options.declare('record_metadata', types=bool, desc='Record metadata',
default=True)
self.recording_options.declare('includes', types=list, default=['*'],
desc='Patterns for variables to include in recording')
self.recording_options.declare('excludes', types=list, default=[],
desc='Patterns for vars to exclude in recording '
'(processed post-includes)')
# Case recording related
self._filtered_vars_to_record = {}
self._norm0 = 0.0
# What the solver supports.
self.supports = OptionsDictionary()
self.supports.declare('gradients', types=bool, default=False)
self.supports.declare('implicit_components', types=bool, default=False)
#.........这里部分代码省略.........
示例3: Driver
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import record_metadata [as 别名]
#.........这里部分代码省略.........
if incl:
myoutputs = {n for n in model._outputs
if n in abs2prom and check_path(abs2prom[n], incl, excl)}
if MPI:
# gather the variables from all ranks to rank 0
all_vars = model.comm.gather(myoutputs, root=0)
if MPI.COMM_WORLD.rank == 0:
myoutputs = all_vars[-1]
for d in all_vars[:-1]:
myoutputs.update(d)
# de-duplicate
myoutputs = myoutputs.difference(all_desvars, all_objectives, all_constraints)
if MPI:
myoutputs = [n for n in myoutputs if rrank == rowned[n]]
filtered_vars_to_record['sys'] = list(myoutputs)
return filtered_vars_to_record
def _setup_recording(self):
"""
Set up case recording.
"""
self._filtered_vars_to_record = self._get_vars_to_record(self.recording_options)
self._rec_mgr.startup(self)
# record the system metadata to the recorders attached to this Driver
if self.recording_options['record_model_metadata']:
for sub in self._problem.model.system_iter(recurse=True, include_self=True):
self._rec_mgr.record_metadata(sub)
def _get_voi_val(self, name, meta, remote_vois, unscaled=False, ignore_indices=False):
"""
Get the value of a variable of interest (objective, constraint, or design var).
This will retrieve the value if the VOI is remote.
Parameters
----------
name : str
Name of the variable of interest.
meta : dict
Metadata for the variable of interest.
remote_vois : dict
Dict containing (owning_rank, size) for all remote vois of a particular
type (design var, constraint, or objective).
unscaled : bool
Set to True if unscaled (physical) design variables are desired.
ignore_indices : bool
Set to True if the full array is desired, not just those indicated by indices.
Returns
-------
float or ndarray
The value of the named variable of interest.
"""
model = self._problem.model
comm = model.comm
vec = model._outputs._views_flat
indices = meta['indices']
if name in remote_vois: