gemseo / problems / scalable

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 monodimensional behavior. Then, for a new user-defined problem dimension, the scalable model extrapolates this monodimensional 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.scalable.diagonal.ScalableDiagonalApproximation(sizes, var_lb, var_ub, output_dependency, io_dependency, seed=0)[source]

Bases: object

Methodology that captures the trends of a physical problem, and 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.

Constructor:

Parameters
  • sizes (dict) – sizes of both input and output variables.

  • var_lb (dict) – lower bounds of the input variables.

  • var_ub (dict) – upper bounds of the input variables.

  • output_dependency (dict) – dependency between old and new outputs.

  • io_dependency (dict) – dependency between new inputs and new outputs.

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

Build interpolation interpolation from a 1D input and output function. Add the model to the local dictionary

Parameters
  • function_name (str) – name of the output function

  • dataset (AbstractFullCache) – the input-output dataset

  • input_names (list(str)) – names of the input variables

  • degree (int) – degree of interpolation (Default value = 3)

get_scalable_derivative(output_function)[source]

Retrieve the (scalable) gradient of the scalable function generated from the original discipline

Parameters

output_function (str) – name of the output function

get_scalable_function(output_function)[source]

Retrieve the scalable function generated from the original discipline

Parameters

output_function (str) – name of the output function

static scale_samples(samples)[source]

Scale samples of array into [0, 1]

Parameters

samples (list(array)) – samples of multivariate array

Returns

samples of multivariate array

Return type

array

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

Bases: gemseo.problems.scalable.model.ScalableModel

Scalable diagonal model.

Constructor.

Parameters
  • data (AbstractFullCache) – learning dataset.

  • sizes (dict) – sizes of input and output variables. If None, use the original sizes. Default: None.

  • fill_factor – degree of sparsity of the dependency matrix. Default: -1.

  • comp_dep – matrix that establishes the selection of a single original component for each scalable component

  • inpt_dep – dependency matrix that establishes the dependency of outputs wrt inputs

  • force_input_dependency (bool) – for any output, force dependency with at least on input.

  • allow_unused_input (bool) – possibility to have an input with no dependence with any output

  • seed (int) – seed

  • group_dep (dict(list(str))) – dependency between inputs and outputs

ABBR = 'sdm'
build_model()[source]

Build model with original sizes for input and output variables.

Returns

scalable approximation.

Return type

ScalableDiagonalApproximation

generate_random_dependency()[source]

Generates a random dependency structure for use in scalable discipline

Parameters
  • force_input_dependency (bool) – force input dependency for a given output. Default: True.

  • allow_unused_inputs (bool) – allow unused inputs, that is to say input dimensions without any interaction with output functions. Default: False.

  • io_dependency (dict(list(str))) – input-output dependency structure. If None, all output components can depend on all input components. Default: None.

Returns

output component dependency and input-output dependency

Return type

dict(int), dict(dict(array))

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

This methods plots the scaled 1D interpolations, a.k.a. basis functions.

A basis function is a monodimensional 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) – if True, export the plot as a PDF file (Default value = False)

  • show (bool) – if True, display the plot (Default value = False)

  • step (bool) – Step to evaluate the 1d interpolation function (Default value = 0.01)

  • varnames (list(str)) – names of the variable to plot; if None, all variables are plotted (Default value = None)

  • directory (str) – directory path. Default: ‘.’.

  • png (bool) – if True, the file format is PNG. Otherwise, use PDF. Default: False.

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

This method plots the dependency matrix of a discipline in the form of a chessboard, where rows represent inputs, columns represent output and gray scale represent the dependency level between inputs and outputs.

Parameters
  • add_levels (bool) – add values of dependency levels in percentage. Default: True.

  • save (bool) – if True, export the plot into a file. Default: True.

  • show (bool) – if True, display the plot. Default: False.

  • directory (str) – directory path. Default: ‘.’.

  • png (bool) – if True, the file format is PNG. Otherwise, use PDF. Default: False.

scalable_derivatives(input_value=None)[source]

Evaluate the scalable derivatives.

Parameters

input_value (dict) – input values. If None, use default inputs.

Returns

evaluation of the scalable derivatives.

Return type

dict

scalable_function(input_value=None)[source]

Evaluate the scalable functions.

Parameters

input_value (dict) – input values. If None, use default inputs.

Returns

evaluation of the scalable functions.

Return type

dict