analysis_driver.py

analysis_driver.py#

AnalysisDriver definition.

class openmdao.drivers.analysis_driver.AnalysisDriver(samples=None, **kwargs)[source]

Bases: Driver

A driver for repeatedly running the model with a list of sampled data.

Samples may be provided as a Sequence of dictionaries, where each entry in the sequence is a dictionary keyed by the variable names to be set for that specific execution.

For instance, the following sequence of samples provides 3 executions, testing (x=0, y=4), (x=1, y=5), and (x=2, y=6). Units may be optionally provided.

Alternatively, samples can be provided as an instance of AnalysisGenerator, which will provide each sample in a lazily-evaluated way.

Parameters:
sampleslist, tuple, or AnalysisGenerator

If given, provides a list or tuple of samples (variable names and values to be tested), or an AnalysisGenerator which provides samples.

**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Driver options.

Attributes:
_namestr

The name used to identify this driver in recorded samples.

_problem_commMPI.Comm or None

The MPI communicator for the Problem.

_colorint or None

In MPI, the cached color is used to determine which samples to run on this proc.

_num_colorsint

The number of total MPI colors for the run.

_prev_sample_varsset

The set of variables seen in the previous iteration of the driver on this rank.

_generatorAnalysisGenerator

The internal AnalysisGenerator providing samples.

Methods

add_recorder(recorder)

Add a recorder to the driver.

add_response(name[, indices, units, linear, ...])

Add a response variable to the model associated with this AnalysisDriver.

add_responses(responses)

Add multiple responses to be recorded by the AnalysisDriver.

check_relevance()

Check if there are constraints that don't depend on any design vars.

cleanup()

Clean up resources prior to exit.

compute_lagrange_multipliers([...])

Get the approximated Lagrange multipliers of one or more constraints.

declare_coloring([num_full_jacs, tol, ...])

Set options for total deriv coloring.

get_coloring_fname([mode])

Get the filename for the coloring file.

get_constraint_values([ctype, lintype, ...])

Return constraint values.

get_design_var_values([get_remote, ...])

Return the design variable values.

get_driver_derivative_calls()

Return number of derivative evaluations made during a driver run.

get_driver_objective_calls()

Return number of objective evaluations made during a driver run.

get_exit_status()

Return exit status of driver run.

get_objective_values([driver_scaling])

Return objective values.

get_reports_dir()

Get the path to the directory where the report files should go.

record_derivatives()

Record the current total jacobian.

record_iteration()

Record an iteration of the current Driver.

run()

Generate samples and run the model for each set of generated input values.

scaling_report([outfile, title, ...])

Generate a self-contained html file containing a detailed connection viewer.

set_design_var(name, value[, set_remote])

Set the value of a design variable.

use_fixed_coloring([coloring])

Tell the driver to use a precomputed coloring.

__init__(samples=None, **kwargs)[source]

Construct an AnalysisDriver.

add_response(name, indices=None, units=None, linear=False, parallel_deriv_color=None, cache_linear_solution=False, flat_indices=None, alias=None)[source]

Add a response variable to the model associated with this AnalysisDriver.

For AnalysisDriver, a response is an “output of interest” that we want to monitor as a result of changes made in the various samples.

The AnalysisDriver.add_response interface does not support any optimization-centric arguments associated with constraints or objectives, such as scaling.

Internally, the driver does add this as an ‘objective’ to the model for the purposes of tracking derivatives.

Parameters:
namestr

Promoted name of the response variable in the system.

indicessequence of int, optional

If variable is an array, these indicate which entries are of interest for this particular response.

unitsstr, optional

Units to convert to before applying scaling.

linearbool

Set to True if constraint is linear. Default is False.

parallel_deriv_colorstr

If specified, this design var will be grouped for parallel derivative calculations with other variables sharing the same parallel_deriv_color.

cache_linear_solutionbool

If True, store the linear solution vectors for this variable so they can be used to start the next linear solution with an initial guess equal to the solution from the previous linear solve.

flat_indicesbool

If True, interpret specified indices as being indices into a flat source array.

aliasstr or None

Alias for this response. Necessary when adding multiple responses on different indices of the same variable.

add_responses(responses)[source]

Add multiple responses to be recorded by the AnalysisDriver.

Parameters:
responsesSequence or dict or str

A sequence of response names to be recorded. If more metadata needs to be specified, reponses can be provided as a dictionary whose keys are the variables to be recorded, and whose associated values are dictionaries of metadata to be passed on as keyword arguments to add_response.

run()[source]

Generate samples and run the model for each set of generated input values.

Rank 0 will both manage the distribution of samples to the other procs and serve as a worker running the samples.

All other procs just run samples.

Returns:
bool

Failure flag; True if failed to converge, False is successful.