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(**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.

__init__(self, **kwargs)[source]

Initialize all attributes.

Parameters
**kwargsdict

options dictionary.

linearize(self, x, **kwargs)[source]

Calculate the jacobian of the interpolant at the requested point.

Parameters
xarray-like

Point at which the surrogate Jacobian is evaluated.

**kwargsdict

Additional keyword arguments passed to the interpolant.

Returns
ndarray

Jacobian of surrogate output wrt inputs.

predict(self, x, **kwargs)[source]

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

Parameters
xarray-like

Point(s) at which the surrogate is evaluated.

**kwargsdict

Additional keyword arguments passed to the interpolant.

Returns
float

Predicted value.

train(self, x, y)[source]

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

Parameters
xarray-like

Training input locations

yarray-like

Model responses at given inputs.

vectorized_predict(self, x)

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

Parameters
xarray-like

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