meta_model_unstructured_comp.py#
MetaModel provides basic meta modeling capability.
- class openmdao.components.meta_model_unstructured_comp.MetaModelUnStructuredComp(**kwargs)[source]
Bases:
ExplicitComponentClass that creates a reduced order model for outputs from inputs.
Each output may have its own surrogate model. Training inputs and outputs are automatically created with ‘train_’ prepended to the corresponding input/output name.
For a Float variable, the training data is an array of length m, where m is the number of training points.
- Parameters:
- **kwargsdict of keyword arguments
Keyword arguments that will be mapped into the Component options.
- Attributes:
- trainbool
If True, training will occur on the next execution.
- _input_sizeint
Keeps track of the cumulative size of all inputs.
- _surrogate_input_names[str, ..]
List of inputs that are not the training vars.
- _surrogate_output_names[str, ..]
List of outputs that are not the training vars.
- _static_input_sizeint
Keeps track of the cumulative size of all inputs added outside of setup.
- _static_surrogate_input_names[str, ..]
List of inputs that are not the training vars and are added outside of setup.
- _static_surrogate_output_names[str, ..]
List of outputs that are not the training vars and are added outside of setup.
- _training_inputdict
Training data for inputs.
- _training_outputdict
Training data for outputs.
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, training_data])Add an input to this component and a corresponding training input.
add_objective(name[, ref, ref0, index, ...])Add a response variable to this system.
add_output(name[, val, training_data, surrogate])Add an output to this component and a corresponding training output.
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, training_data=None, **kwargs)[source]
Add an input to this component and a corresponding training input.
- Parameters:
- namestr
Name of the input.
- valfloat or ndarray
Initial value for the input.
- training_datafloat or ndarray
Training data for this variable. Optional, can be set by the problem later.
- **kwargsdict
Additional agruments for add_input.
- Returns:
- dict
Metadata for added variable.
- add_output(name, val=1.0, training_data=None, surrogate=None, **kwargs)[source]
Add an output to this component and a corresponding training output.
- Parameters:
- namestr
Name of the variable output.
- valfloat or ndarray
Initial value for the output. While the value is overwritten during execution, it is useful for inferring size.
- training_datafloat or ndarray
Training data for this variable. Optional, can be set by the problem later.
- surrogate<SurrogateModel>, optional
Surrogate model to use for this output; if None, use default surrogate.
- **kwargsdict
Additional arguments for add_output.
- Returns:
- dict
Metadata for added variable.
- check_config(logger)[source]
Perform optional error checks.
- Parameters:
- loggerobject
The object that manages logging output.
- compute(inputs, outputs)[source]
Predict outputs.
If the training flag is set, train the metamodel first.
- Parameters:
- inputsVector
Unscaled, dimensional input variables read via inputs[key].
- outputsVector
Unscaled, dimensional output variables read via outputs[key].
- compute_partials(inputs, partials)[source]
Compute sub-jacobian parts. The model is assumed to be in an unscaled state.
- Parameters:
- inputsVector
Unscaled, dimensional input variables read via inputs[key].
- partialsJacobian
Sub-jac components written to partials[output_name, input_name].
- declare_partials(of, wrt, dependent=True, rows=None, cols=None, val=None, method='exact', step=None, form=None, step_calc=None)[source]
Declare information about this component’s subjacobians.
- Parameters:
- ofstr or list of str
The name of the residual(s) that derivatives are being computed for. May also contain a glob pattern.
- wrtstr or list of str
The name of the variables that derivatives are taken with respect to. This can contain the name of any input or output variable. May also contain a glob pattern.
- dependentbool(True)
If False, specifies no dependence between the output(s) and the input(s). This is only necessary in the case of a sparse global jacobian, because if ‘dependent=False’ is not specified and declare_partials is not called for a given pair, then a dense matrix of zeros will be allocated in the sparse global jacobian for that pair. In the case of a dense global jacobian it doesn’t matter because the space for a dense subjac will always be allocated for every pair.
- rowsndarray of int or None
Row indices for each nonzero entry. For sparse subjacobians only.
- colsndarray of int or None
Column indices for each nonzero entry. For sparse subjacobians only.
- valfloat or ndarray of float or scipy.sparse
Value of subjacobian. If rows and cols are not None, this will contain the values found at each (row, col) location in the subjac.
- methodstr
The type of approximation that should be used. Valid options include: ‘fd’: Finite Difference, ‘cs’: Complex Step, ‘exact’: use the component defined analytic derivatives. Default is ‘exact’.
- stepfloat
Step size for approximation. Defaults to None, in which case the approximation method provides its default value.
- formstr
Form for finite difference, can be ‘forward’, ‘backward’, or ‘central’. Defaults to None, in which case the approximation method provides its default value.
- step_calcstr
Step type for computing the size of the finite difference step. It can be ‘abs’ for absolute, ‘rel_avg’ for a size relative to the absolute value of the vector input, or ‘rel_element’ for a size relative to each value in the vector input. In addition, it can be ‘rel_legacy’ for a size relative to the norm of the vector. For backwards compatibilty, it can be ‘rel’, which is now equivalent to ‘rel_avg’. Defaults to None, in which case the approximation method provides its default value.
- initialize()[source]
Declare options.