multifi_meta_model_unstructured_comp.py

multifi_meta_model_unstructured_comp.py#

Define the MultiFiMetaModel class.

class openmdao.components.multifi_meta_model_unstructured_comp.MultiFiMetaModelUnStructuredComp(**kwargs)[source]

Bases: MetaModelUnStructuredComp

Generalize MetaModel to be able to train surrogates with multi-fidelity training inputs.

For a given number of levels of fidelity nfi (given at initialization) the corresponding training input variables train_[invar]_fi[2..nfi] and train_[outvar]_fi[2..nfi] are automatically created besides the given train_[invar] and train_[outvar] variables. Note the index starts at 2, the index 1 is omitted considering the simple name var is equivalent to var_fi1 which is intended to be the data of highest fidelity.

The surrogate models are trained with a list of (m samples, n dim) ndarrays built from the various training input data. By convention, the fidelities are intended to be ordered from highest to lowest fidelity. Obviously for a given level of fidelity corresponding lists train_[var]_fi[n] have to be of the same size.

Thus given the initialization:

>>> mm = MultiFiMetaModelUnStructuredComp(nfi=2)`
>>> mm.add_input('x1', 0.)
>>> mm.add_input('x2', 0.)
>>> mm.add_output('y1', 0.)
>>> mm.add_output('y2', 0.)

the following supplementary training input variables train_x1_fi2 and train_x2_fi2 are created together with the classic ones train_x1 and train_x2 and the output variables train_y1_fi2 and train_y2_fi2 are created as well. The embedded surrogate for y1 will be trained with a couple (X, Y).

Where X is the list [X_fi1, X_fi2] where X_fi1 is an (m1, 2) ndarray filled with the m1 samples [x1 value, x2 value], X_fi2 is an (m2, 2) ndarray filled with the m2 samples [x1_fi2 value, x2_fi2 value]

Where Y is a list [Y1_fi1, Y1_fi2] where Y1_fi1 is a (m1, 1) ndarray of y1 values and Y1_fi2 a (m2, 1) ndarray y1_fi2 values.

Note

when nfi ==1 a MultiFiMetaModelUnStructuredComp object behaves as a MetaModelUnStructured object.

Parameters:
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Component options.

Attributes:
_input_sizeslist

Stores the size of the inputs at each level.

_static_input_sizeslist

Stores the size of the inputs at each level for inputs added outside of setup.

_nfifloat

number of levels of fidelity

_training_inputdict

Training data for inputs.

Methods

abs_meta_iter(iotype[, local, cont, discrete])

Iterate over absolute variable names and their metadata for this System.

add_constraint(name[, lower, upper, equals, ...])

Add a constraint variable to this system.

add_design_var(name[, lower, upper, ref, ...])

Add a design variable to this system.

add_discrete_input(name, val[, desc, tags, ...])

Add a discrete input variable to the component.

add_discrete_output(name, val[, desc, tags, ...])

Add an output variable to the component.

add_input(name[, val])

Add an input variable to the component.

add_objective(name[, ref, ref0, index, ...])

Add a response variable to this system.

add_output(name[, val])

Add an output variable to the component.

add_recorder(recorder[, recurse])

Add a recorder to the system.

add_response(name, type_[, lower, upper, ...])

Add a response variable to this system.

best_partial_deriv_direction()

Return the best direction for partial deriv calculations based on input and output sizes.

check_config(logger)

Perform optional error checks.

check_partials([out_stream, compact_print, ...])

Check partial derivatives comprehensively for this component.

check_sparsity([method, max_nz, out_stream])

Check the sparsity of the computed jacobian against the declared sparsity.

cleanup()

Clean up resources prior to exit.

comm_info_iter()

Yield comm size for this system and all subsystems.

compute(inputs, outputs)

Predict outputs.

compute_fd_jac(jac[, method])

Force the use of finite difference to compute a jacobian.

compute_fd_sparsity([method, num_full_jacs, ...])

Use finite difference to compute a sparsity matrix.

compute_jacvec_product(inputs, d_inputs, ...)

Compute jac-vector product.

compute_partials(inputs, partials)

Compute sub-jacobian parts.

compute_sparsity([direction, num_iters, ...])

Compute the sparsity of the partial jacobian.

convert2units(name, val, units)

Convert the given value to the specified units.

convert_from_units(name, val, units)

Convert the given value from the specified units to those of the named variable.

convert_units(name, val, units_from, units_to)

Wrap the utility convert_units and give a good error message.

declare_coloring([wrt, method, form, step, ...])

Set options for deriv coloring of a set of wrt vars matching the given pattern(s).

declare_partials(of, wrt[, dependent, rows, ...])

Declare information about this component's subjacobians.

dist_size_iter(io, top_comm)

Yield names and distributed ranges of all local and remote variables in this system.

get_coloring_fname(mode)

Return the full pathname to a coloring file.

get_conn_graph()

Return the model connection graph.

get_constraints([recurse, get_sizes, ...])

Get the Constraint settings from this system.

get_declare_partials_calls([sparsity])

Return a string containing declare_partials() calls based on the subjac sparsity.

get_design_vars([recurse, get_sizes, ...])

Get the DesignVariable settings from this system.

get_io_metadata([iotypes, metadata_keys, ...])

Retrieve metadata for a filtered list of variables.

get_linear_vectors()

Return the linear inputs, outputs, and residuals vectors.

get_nonlinear_vectors()

Return the inputs, outputs, and residuals vectors.

get_objectives([recurse, get_sizes, ...])

Get the Objective settings from this system.

get_outputs_dir(*subdirs[, mkdir])

Get the path under which all output files of this system are to be placed.

get_promotions([inprom, outprom])

Return all promotions for the given promoted variable(s).

get_reports_dir()

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

get_responses([recurse, get_sizes, use_prom_ivc])

Get the response variable settings from this system.

get_self_statics()

Override this in derived classes if compute_primal references static values.

get_source(name)

Return the source variable connected to the given named variable.

get_val(name[, units, indices, get_remote, ...])

Get an output/input/residual variable.

get_var_dup_info(name, io)

Return information about how the given variable is duplicated across MPI processes.

get_var_sizes(name, io)

Return the sizes of the given variable on all procs.

has_vectors()

Check if the system vectors have been initialized.

initialize()

Declare options.

is_explicit([is_comp])

Return True if this is an explicit component.

list_inputs([val, prom_name, units, shape, ...])

Write a list of input names and other optional information to a specified stream.

list_options([include_default, ...])

Write a list of output names and other optional information to a specified stream.

list_outputs([explicit, implicit, val, ...])

Write a list of output names and other optional information to a specified stream.

list_vars([val, prom_name, residuals, ...])

Write a list of inputs and outputs sorted by component in execution order.

load_case(case)

Pull all input and output variables from a Case into this System.

load_model_options()

Load the relevant model options from Problem._metadata['model_options'].

override_method(name, method)

Dynamically add a method to this component instance.

record_iteration()

Record an iteration of the current System.

run_apply_linear(mode[, scope_out, scope_in])

Compute jac-vec product.

run_apply_nonlinear()

Compute residuals.

run_linearize([sub_do_ln])

Compute jacobian / factorization.

run_solve_linear(mode)

Apply inverse jac product.

run_solve_nonlinear()

Compute outputs.

run_validation()

Run validate method on all systems below this system.

set_check_partial_options(wrt[, method, ...])

Set options that will be used for checking partial derivatives.

set_constraint_options(name[, ref, ref0, ...])

Set options for constraints in the model.

set_design_var_options(name[, lower, upper, ...])

Set options for design vars in the model.

set_objective_options(name[, ref, ref0, ...])

Set options for objectives in the model.

set_output_solver_options(name[, lower, ...])

Set solver output options.

set_solver_print([level, depth, type_, ...])

Control printing for solvers and subsolvers in the model.

set_val(name, val[, units, indices])

Set an input or output variable.

setup()

Declare inputs and outputs.

setup_partials()

Declare partials.

sparsity_matches_fd([direction, outstream])

Compare the sparsity computed by this system vs.

subjac_sparsity_iter(sparsity[, wrt_matches])

Iterate over sparsity for each subjac in the jacobian.

system_iter([include_self, recurse, typ, ...])

Yield a generator of local subsystems of this system.

total_local_size(io)

Return the total local size of the given variable.

use_fixed_coloring([coloring, recurse])

Use a precomputed coloring for this System.

uses_approx()

Return True if the system uses approximations to compute derivatives.

validate(inputs, outputs[, discrete_inputs, ...])

Check any final input / output values after a run.

__init__(**kwargs)[source]

Initialize all attributes.

add_input(name, val=1.0, **kwargs)[source]

Add an input variable to the component.

Parameters:
namestr

Name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

**kwargsdict

Additional arguments to be passed to the add_input method of the base class.

add_output(name, val=1.0, **kwargs)[source]

Add an output variable to the component.

Parameters:
namestr

Name of the variable in this component’s namespace.

valfloat or list or tuple or ndarray

The initial value of the variable being added in user-defined units. Default is 1.0.

**kwargsdict

Additional arguments to be passed to the add_output method of the base class.

initialize()[source]

Declare options.