gemseo / problems / mdo / scalable / data_driven

Hide inherited members

diagonal module

Scalable diagonal model.

This module implements the concept of scalable diagonal model, which is a particular scalable model built from an input-output dataset relying on a diagonal design of experiments (DOE) where inputs vary proportionally from their lower bounds to their upper bounds, following the diagonal of the input space.

So for every output, the dataset catches its evolution with respect to this proportion, which makes it a mono dimensional behavior. Then, for a new user-defined problem dimension, the scalable model extrapolates this mono dimensional behavior to the different input directions.

The concept of scalable diagonal model is implemented through the ScalableDiagonalModel class which is composed of a ScalableDiagonalApproximation. With regard to the diagonal DOE, GEMSEO proposes the DiagonalDOE class.

class gemseo.problems.mdo.scalable.data_driven.diagonal.ScalableDiagonalApproximation(sizes, output_dependency, io_dependency)[source]

Bases: object

Methodology that captures the trends of a physical problem.

It also extends it into a problem that has scalable input and outputs dimensions. The original and the resulting scalable problem have the same interface:

all inputs and outputs have the same names; only their dimensions vary.

Parameters:
  • sizes (Mapping[str, int]) – The sizes of the inputs and outputs.

  • output_dependency – The dependency between the original and new outputs.

  • io_dependency – The dependency between the new inputs and outputs.

build_scalable_function(function_name, dataset, input_names, degree=3)[source]

Create the interpolation functions for a specific output.

Parameters:
  • function_name (str) – The name of the output.

  • dataset (IODataset) – The input-output dataset.

  • input_names (Iterable[str]) – The names of the inputs.

  • degree (int) –

    The degree of interpolation.

    By default it is set to 3.

Returns:

The input and output samples scaled in [0, 1].

Return type:

tuple[list[NDArray[float]], NDArray[float]]

get_scalable_derivative(output_function)[source]

Return the function computing the derivatives of an output.

Parameters:

output_function (str) – The name of the output.

Returns:

The function computing the derivatives of this output.

Return type:

Callable[[Iterable[float]], NDArray[float]]

get_scalable_function(output_function)[source]

Return the function computing an output.

Parameters:

output_function (str) – The name of the output.

Returns:

The function computing the output.

Return type:

Callable[[Iterable[float]], NDArray[float]]

static scale_samples(samples)[source]

Scale array samples into [0, 1].

Parameters:

samples (Iterable[NDArray[float]]) – The samples.

Returns:

The samples with components scaled in [0, 1].

Return type:

NDArray[float]

class gemseo.problems.mdo.scalable.data_driven.diagonal.ScalableDiagonalModel(data, sizes=None, fill_factor=-1, comp_dep=None, inpt_dep=None, force_input_dependency=False, allow_unused_inputs=True, seed=0, group_dep=None)[source]

Bases: ScalableModel

Scalable diagonal model.

Parameters:
  • data (IODataset) – The input-output dataset.

  • sizes (Sequence[int] | None) – The sizes of the inputs and outputs. If None, use the original sizes.

  • fill_factor (float) –

    The degree of sparsity of the dependency matrix.

    By default it is set to -1.

  • comp_dep (NDArray[float]) – The matrix defining the selection of a single original component for each scalable component.

  • inpt_dep (NDArray[float]) – The input-output dependency matrix.

  • force_input_dependency (bool) –

    Whether to force the dependency of each output with at least one input.

    By default it is set to False.

  • allow_unused_inputs (bool) –

    The possibility to have an input with no dependence with any output.

    By default it is set to True.

  • seed (int) –

    The seed for reproducible results.

    By default it is set to 0.

  • group_dep (Mapping[str, Iterable[str]] | None) – The dependency between the inputs and outputs.

build_model()[source]

Build the model with the original sizes for input and output variables.

Returns:

The scalable approximation.

Return type:

ScalableDiagonalApproximation

compute_bounds()

Compute lower and upper bounds of both input and output variables.

Returns:

The lower and upper bounds.

Return type:

tuple[dict[str, int], dict[str, int]]

generate_random_dependency()[source]

Generate a random dependency structure for use in scalable discipline.

Returns:

The dependency structure.

Return type:

tuple[dict[str, NDArray[int]], dict[str, dict[str, NDArray[float]]]]

normalize_data()

Normalize the dataset from lower and upper bounds.

Return type:

None

plot_1d_interpolations(save=False, show=False, step=0.01, varnames=None, directory='.', png=False)[source]

Plot the scaled 1D interpolations, a.k.a. the basis functions.

A basis function is a mono dimensional function interpolating the samples of a given output component over the input sampling line \(t\in[0,1]\mapsto \\underline{x}+t(\overline{x}-\\underline{x})\).

There are as many basis functions as there are output components from the discipline. Thus, for a discipline with a single output in dimension 1, there is 1 basis function. For a discipline with a single output in dimension 2, there are 2 basis functions. For a discipline with an output in dimension 2 and an output in dimension 13, there are 15 basis functions. And so on. This method allows to plot the basis functions associated with all outputs or only part of them, either on screen (show=True), in a file (save=True) or both. We can also specify the discretization step whose default value is 0.01.

Parameters:
  • save (bool) –

    Whether to save the figure.

    By default it is set to False.

  • show (bool) –

    Whether to display the figure.

    By default it is set to False.

  • step (float) –

    The step to evaluate the 1d interpolation function.

    By default it is set to 0.01.

  • varnames (Sequence[str] | None) – The names of the variable to plot. If None, all the variables are plotted.

  • directory (str) –

    The directory path.

    By default it is set to “.”.

  • png (bool) –

    Whether to use PNG file format instead of PDF.

    By default it is set to False.

Returns:

The names of the files.

Return type:

list[str]

plot_dependency(add_levels=True, save=True, show=False, directory='.', png=False)[source]

Plot the dependency matrix of a discipline in the form of a chessboard.

The rows represent inputs, columns represent output and gray scale represents the dependency level between inputs and outputs.

Parameters:
  • add_levels (bool) –

    Whether to add the dependency levels in percentage.

    By default it is set to True.

  • save (bool) –

    Whether to save the figure.

    By default it is set to True.

  • show (bool) –

    Whether to display the figure.

    By default it is set to False.

  • directory (str) –

    The directory path.

    By default it is set to “.”.

  • png (bool) –

    Whether to use PNG file format instead of PDF.

    By default it is set to False.

Return type:

str

scalable_derivatives(input_value=None)[source]

Compute the derivatives.

Parameters:

input_value (Mapping[str, NDArray[float]] | None) – The input values.

Returns:

The values of the derivatives.

Return type:

dict[str, NDArray[float]]

scalable_function(input_value=None)[source]

Compute the outputs.

Parameters:

input_value (Mapping[str, NDArray[float]] | None) – The input values.

Returns:

The values of the outputs.

Return type:

dict[str, NDArray[float]]

ABBR = 'sdm'
data: IODataset

The learning dataset.

property input_names: list[str]

The input names.

property original_sizes: Mapping[str, int]

The original sizes of variables.

property output_names: list[str]

The output names.