本文整理汇总了Python中openmdao.recorders.recording_manager.RecordingManager.close方法的典型用法代码示例。如果您正苦于以下问题:Python RecordingManager.close方法的具体用法?Python RecordingManager.close怎么用?Python RecordingManager.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openmdao.recorders.recording_manager.RecordingManager
的用法示例。
在下文中一共展示了RecordingManager.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Driver
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import close [as 别名]
#.........这里部分代码省略.........
if all(scaler == 1.0):
continue
elif scaler == 1.0:
continue
self.fn_conversions[name] = scaler
def _setup_communicators(self, comm, parent_dir):
"""
Assign a communicator to the root `System`.
Args
----
comm : an MPI communicator (real or fake)
The communicator being offered by the Problem.
parent_dir : str
Absolute directory of the Problem.
"""
self.root._setup_communicators(comm, parent_dir)
def get_req_procs(self):
"""
Returns
-------
tuple
A tuple of the form (min_procs, max_procs), indicating the
min and max processors usable by this `Driver`.
"""
return self.root.get_req_procs()
def cleanup(self):
""" Clean up resources prior to exit. """
self.recorders.close()
def _map_voi_indices(self):
poi_indices = OrderedDict()
qoi_indices = OrderedDict()
for name, meta in chain(iteritems(self._cons), iteritems(self._objs)):
# set indices of interest
if 'indices' in meta:
qoi_indices[name] = meta['indices']
for name, meta in iteritems(self._desvars):
# set indices of interest
if 'indices' in meta:
poi_indices[name] = meta['indices']
return poi_indices, qoi_indices
def _of_interest(self, voi_list):
"""Return a list of tuples, with the given voi_list organized
into tuples based on the previously defined grouping of VOIs.
"""
vois = []
remaining = set(voi_list)
for voi_set in self._voi_sets:
vois.append([])
for i, voi_set in enumerate(self._voi_sets):
for v in voi_list:
if v in voi_set:
vois[i].append(v)
remaining.remove(v)
vois = [tuple(x) for x in vois if x]
示例2: SolverBase
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import close [as 别名]
class SolverBase(object):
""" Common base class for Linear and Nonlinear solver. Should not be used
by users. Always inherit from `LinearSolver` or `NonlinearSolver`."""
def __init__(self):
self.iter_count = 0
self.options = OptionsDictionary()
desc = (
"Set to 0 to disable printing, set to 1 to print the "
"residual to stdout each iteration, set to 2 to print "
"subiteration residuals as well."
)
self.options.add_option("iprint", 0, values=[0, 1, 2], desc=desc)
self.recorders = RecordingManager()
self.local_meta = None
def setup(self, sub):
""" Solvers override to define post-setup initiailzation.
Args
----
sub: `System`
System that owns this solver.
"""
pass
def cleanup(self):
""" Clean up resources prior to exit. """
self.recorders.close()
def print_norm(self, solver_string, pathname, iteration, res, res0, msg=None, indent=0, solver="NL"):
""" Prints out the norm of the residual in a neat readable format.
Args
----
solver_string: string
Unique string to identify your solver type (e.g., 'LN_GS' or
'NEWTON').
pathname: dict
Parent system pathname.
iteration: int
Current iteration number
res: float
Absolute residual value.
res0: float
Baseline initial residual for relative comparison.
msg: string, optional
Message that indicates convergence.
ident: int, optional
Additional indentation levels for subiterations.
solver: string, optional
Solver type if not LN or NL (mostly for line search operations.)
"""
if pathname == "":
name = "root"
else:
name = "root." + pathname
# Find indentation level
level = pathname.count(".")
# No indentation for driver; top solver is no indentation.
level = level + indent
indent = " " * level
if msg is not None:
form = indent + "[%s] %s: %s %d | %s"
print(form % (name, solver, solver_string, iteration, msg))
return
form = indent + "[%s] %s: %s %d | %.9g %.9g"
print(form % (name, solver, solver_string, iteration, res, res / res0))
def print_all_convergence(self):
""" Turns on iprint for this solver and all subsolvers. Override if
your solver has subsolvers."""
self.options["iprint"] = 1
def generate_docstring(self):
"""
Generates a numpy-style docstring for a user-created System class.
Returns
-------
docstring : str
string that contains a basic numpy docstring.
"""
# start the docstring off
docstring = ' """\n'
# Put options into docstring
firstTime = 1
# for py3.4, items from vars must come out in same order.
#.........这里部分代码省略.........
示例3: SolverBase
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import close [as 别名]
class SolverBase(object):
""" Common base class for Linear and Nonlinear solver. Should not be used
by users. Always inherit from `LinearSolver` or `NonlinearSolver`."""
def __init__(self):
self.iter_count = 0
self.options = OptionsDictionary()
desc = 'Set to 0 to disable printing, set to 1 to print the ' \
'residual to stdout each iteration, set to 2 to print ' \
'subiteration residuals as well.'
self.options.add_option('iprint', 0, values=[0, 1, 2], desc=desc)
self.options.add_option('err_on_maxiter', False,
desc='If True, raise an AnalysisError if not converged at maxiter.')
self.recorders = RecordingManager()
self.local_meta = None
def setup(self, sub):
""" Solvers override to define post-setup initiailzation.
Args
----
sub: `System`
System that owns this solver.
"""
pass
def cleanup(self):
""" Clean up resources prior to exit. """
self.recorders.close()
def print_norm(self, solver_string, pathname, iteration, res, res0,
msg=None, indent=0, solver='NL', u_norm=None):
""" Prints out the norm of the residual in a neat readable format.
Args
----
solver_string: string
Unique string to identify your solver type (e.g., 'LN_GS' or
'NEWTON').
pathname: dict
Parent system pathname.
iteration: int
Current iteration number
res: float
Norm of the absolute residual value.
res0: float
Norm of the baseline initial residual for relative comparison.
msg: string, optional
Message that indicates convergence.
ident: int, optional
Additional indentation levels for subiterations.
solver: string, optional
Solver type if not LN or NL (mostly for line search operations.)
u_norm: float, optional
Norm of the u vector, if applicable.
"""
if pathname=='':
name = 'root'
else:
name = 'root.' + pathname
# Find indentation level
level = pathname.count('.')
# No indentation for driver; top solver is no indentation.
level = level + indent
indent = ' ' * level
if msg is not None:
form = indent + '[%s] %s: %s %d | %s'
if u_norm:
form += ' (%s)' % u_norm
print(form % (name, solver, solver_string, iteration, msg))
return
form = indent + '[%s] %s: %s %d | %.9g %.9g'
if u_norm:
form += ' (%s)' % u_norm
print(form % (name, solver, solver_string, iteration, res, res/res0))
def print_all_convergence(self):
""" Turns on iprint for this solver and all subsolvers. Override if
your solver has subsolvers."""
self.options['iprint'] = 1
def generate_docstring(self):
"""
Generates a numpy-style docstring for a user-created System class.
#.........这里部分代码省略.........
示例4: Driver
# 需要导入模块: from openmdao.recorders.recording_manager import RecordingManager [as 别名]
# 或者: from openmdao.recorders.recording_manager.RecordingManager import close [as 别名]
#.........这里部分代码省略.........
self.debug_print.declare('debug_print_ln_con', types=bool, default=False,
desc='Print linear constraints')
self.debug_print.declare('debug_print_objective', types=bool, default=False,
desc='Print objectives')
self.iter_count = 0
self.metadata = None
self._model_viewer_data = None
self.cite = ""
# TODO, support these in OpenMDAO
self.supports.declare('integer_design_vars', types=bool, default=False)
self._simul_coloring_info = None
self._res_jacs = {}
self.fail = False
def add_recorder(self, recorder):
"""
Add a recorder to the driver.
Parameters
----------
recorder : BaseRecorder
A recorder instance.
"""
self._rec_mgr.append(recorder)
def cleanup(self):
"""
Clean up resources prior to exit.
"""
self._rec_mgr.close()
def _setup_driver(self, problem):
"""
Prepare the driver for execution.
This is the final thing to run during setup.
Parameters
----------
problem : <Problem>
Pointer to the containing problem.
"""
self._problem = problem
model = problem.model
self._objs = objs = OrderedDict()
self._cons = cons = OrderedDict()
self._responses = model.get_responses(recurse=True)
response_size = 0
for name, data in iteritems(self._responses):
if data['type'] == 'con':
cons[name] = data
else:
objs[name] = data
response_size += data['size']
# Gather up the information for design vars.
self._designvars = model.get_design_vars(recurse=True)
desvar_size = np.sum(data['size'] for data in itervalues(self._designvars))
if ((problem._mode == 'fwd' and desvar_size > response_size) or
(problem._mode == 'rev' and response_size > desvar_size)):