gemseo / disciplines

Show inherited members

surrogate module

Surrogate discipline.

class gemseo.disciplines.surrogate.SurrogateDiscipline(surrogate, data=None, transformer=mappingproxy({'inputs': <gemseo.mlearning.transformers.scaler.min_max_scaler.MinMaxScaler object>, 'outputs': <gemseo.mlearning.transformers.scaler.min_max_scaler.MinMaxScaler object>}), disc_name=None, default_inputs=None, input_names=None, output_names=None, **parameters)[source]

Bases: MDODiscipline

A MDODiscipline approximating another one with a surrogate model.

This surrogate model is a regression model implemented as a MLRegressionAlgo. This MLRegressionAlgo is built from an input- output Dataset composed of evaluations of the original discipline.

Initialize self. See help(type(self)) for accurate signature.

  • surrogate (str | MLRegressionAlgo) – Either the class name or the instance of the MLRegressionAlgo.

  • data (Dataset | None) – The learning dataset to train the regression model. If None, the regression model is supposed to be trained.

  • transformer (TransformerType) –

    The strategies to transform the variables. The values are instances of Transformer while the keys are the names of either the variables or the groups of variables, e.g. "inputs" or "outputs" in the case of the regression algorithms. If a group is specified, the Transformer will be applied to all the variables of this group. If The :attr:.MLRegressionAlgo.DEFAULT_TRANSFORMER` uses the MinMaxScaler strategy for both input and output variables.

    By default it is set to {‘inputs’: <gemseo.mlearning.transformers.scaler.min_max_scaler.MinMaxScaler object at 0x7fea815af520>, ‘outputs’: <gemseo.mlearning.transformers.scaler.min_max_scaler.MinMaxScaler object at 0x7fea815af580>}.

  • disc_name (str | None) – The name to be given to the surrogate discipline. If None, concatenate SHORT_ALGO_NAME and

  • default_inputs (dict[str, ndarray] | None) – The default values of the inputs. If None, use the center of the learning input space.

  • input_names (Iterable[str] | None) – The names of the input variables. If None, consider all input variables mentioned in the learning dataset.

  • output_names (Iterable[str] | None) – The names of the output variables. If None, consider all input variables mentioned in the learning dataset.

  • **parameters (MLAlgoParameterType) – The parameters of the machine learning algorithm.


ValueError – If the learning dataset is missing whilst the regression model is not trained.

cache: AbstractCache | None

The cache containing one or several executions of the discipline according to the cache policy.

data_processor: DataProcessor

A tool to pre- and post-process discipline data.

exec_for_lin: bool

Whether the last execution was due to a linearization.

input_grammar: BaseGrammar

The input grammar.

jac: dict[str, dict[str, ndarray]]

The Jacobians of the outputs wrt inputs.

The structure is {output: {input: matrix}}.

name: str

The name of the discipline.

output_grammar: BaseGrammar

The output grammar.

re_exec_policy: ReExecutionPolicy

The policy to re-execute the same discipline.

residual_variables: Mapping[str, str]

The output variables mapping to their inputs, to be considered as residuals; they shall be equal to zero.

run_solves_residuals: bool

Whether the run method shall solve the residuals.

Examples using SurrogateDiscipline

Create a surrogate discipline

Create a surrogate discipline

Plug a surrogate discipline in a Scenario

Plug a surrogate discipline in a Scenario