nearest_neighbor.py

Surrogate model based on the N-Dimensional Interpolation library by Stephen Marone.

https://github.com/SMarone/NDInterp

class openmdao.surrogate_models.nearest_neighbor.NearestNeighbor(interpolant_type='rbf', **kwargs)[source]

Bases: openmdao.surrogate_models.surrogate_model.SurrogateModel

Surrogate model that approximates values using a nearest neighbor approximation.

Attributes

interpolant (object) Interpolator object
interpolant_init_args (dict) Input keyword arguments for the interpolator.
interpolant_type (str) Type of interpolator from [‘linear’, ‘weighted’, ‘rbf’]
__init__(interpolant_type='rbf', **kwargs)[source]

Initialize all attributes.

Parameters:

interpolant_type : str

must be one of ‘linear’, ‘weighted’, or ‘rbf’.

**kwargs : dict

keyword arguments

linearize(x, **kwargs)[source]

Calculate the jacobian of the interpolant at the requested point.

Parameters:

x : array-like

Point at which the surrogate Jacobian is evaluated.

**kwargs : dict

Additional keyword arguments passed to the interpolant.

Returns:

ndarray

Jacobian of surrogate output wrt inputs.

predict(x, **kwargs)[source]

Calculate a predicted value of the response based on the current trained model.

Parameters:

x : array-like

Point(s) at which the surrogate is evaluated.

**kwargs : dict

Additional keyword arguments passed to the interpolant.

Returns:

float

Predicted value.

train(x, y)[source]

Train the surrogate model with the given set of inputs and outputs.

Parameters:

x : array-like

Training input locations

y : array-like

Model responses at given inputs.

vectorized_predict(x)

Calculate predicted values of the response based on the current trained model.

Parameters:

x : array-like

Vectorized point(s) at which the surrogate is evaluated.