Components
OpenMDAO component wrappers for Standard Evaluator.
- class EvaluatorOpenMdaoComponent
Bases:
ExplicitComponentExposes a Standard Evaluator as an OpenMDAO ExplicitComponent.
This component wraps a Standard Evaluator so it can be used within an OpenMDAO model. It maps evaluator variables to component inputs and evaluator responses to component outputs.
Methods:
__init__([evaluator])Initialize the component and store the evaluator.
Declare component options.
setup()Set up component inputs and outputs from the evaluator's OptProblem.
compute(inputs, outputs[, discrete_inputs, ...])Compute responses using the Standard evaluator.
- __init__(evaluator=None, **kwargs)
Initialize the component and store the evaluator.
- Parameters:
evaluator (Evaluator) – The Standard evaluator that will be wrapped. If None, the evaluator is created from the evaluator_options in kwargs.
**kwargs (dict) – Keyword arguments passed to the OpenMDAO ExplicitComponent constructor.
- Raises:
TypeError – If evaluator is provided but is not an instance of Evaluator.
AttributeError – If no evaluator is provided and no evaluator_options key exists in kwargs.
- initialize()
Declare component options.
Stores the evaluator information in the evaluator_options option if the evaluator has a
to_dictmethod.
- setup()
Set up component inputs and outputs from the evaluator’s OptProblem.
Maps opt_problem.variables to OpenMDAO inputs and opt_problem.responses to OpenMDAO outputs with bounds, scaling, and defaults.
- Raises:
ValueError – If a response has a scale value of 0.0.
- compute(inputs, outputs, discrete_inputs=None, discrete_outputs=None)
Compute responses using the Standard evaluator.
Builds a DataFrame from OpenMDAO inputs, calls the evaluator, and extracts responses back to OpenMDAO outputs.
- Parameters:
inputs (dict) – Unscaled, dimensional input variables read via inputs[key].
outputs (dict) – Unscaled, dimensional output variables read via outputs[key].
discrete_inputs (dict) – If not None, dict containing discrete input values.
discrete_outputs (dict) – If not None, dict containing discrete output values.
- Raises:
ValueError – If discrete_inputs or discrete_outputs are provided.