aerosandbox.modeling.surrogate_model#

Module Contents#

Classes#

SurrogateModel

A SurrogateModel is effectively a callable; it only has the __call__ method, and all subclasses must explicitly

class aerosandbox.modeling.surrogate_model.SurrogateModel[source]#

Bases: aerosandbox.common.AeroSandboxObject

A SurrogateModel is effectively a callable; it only has the __call__ method, and all subclasses must explicitly overwrite this. The only reason it is not a callable is that you want to be able to save it to disk (via pickling) while also having the capability to save associated data (for example, constants associated with a particular model, or underlying data).

If data is used to generate the SurrogateModel, it should be stored as follows:

  • The independent variable(s) should be stored as SurrogateModel.x_data

    • in the general N-dimensional case, x_data should be a dictionary where: keys are variable names and

    values are float/array

    • in the case of a 1-dimensional input (R^1 -> R^1), x-data should be a float/array.

  • The dependent variable should be stored as SurrogateModel.y_data

    • The type of this variable should be a float or an np.ndarray.

Even if you don’t have any real x_data or y_data to add as SurrogateModel.x_data or SurrogateModel.y_data,

it’s recommended (but not required) that you add values here as examples that users can inspect in order to see the data types and array shapes required.

abstract __call__(x)[source]#

Evaluates the surrogate model at some given input x.

The input x is of the type:
  • in the general N-dimensional case, a dictionary where keys are variable names and values are float/array.

  • in the case of a 1-dimensional input (R^1 -> R^2), a float/array.

Parameters:

x (Union[int, float, aerosandbox.numpy.ndarray, Dict[str, aerosandbox.numpy.ndarray]]) –

Return type:

Union[float, aerosandbox.numpy.ndarray]

__repr__()[source]#

Return repr(self).

Return type:

str

input_dimensionality()[source]#

Returns the number of inputs that should be supplied in x, where x is the input to the SurrogateModel.

Return type:

int

input_names()[source]#

If x (the input to this model) is supposed to be a dict, this method returns the keys that should be part of x.

If x is 1D and simply takes in floats or arrays, or if no x_data exists, returns None.

Return type:

Union[List, None]

plot(resolution=250)[source]#