Source code for openmdao.surrogate_models.surrogate_model

"""
Class definition for SurrogateModel, the base class for all surrogate models.
"""

[docs]class SurrogateModel(object): """ Base class for surrogate models. """ def __init__(self): self.trained = False
[docs] def train(self, x, y): self.trained = True
[docs] def predict(self, x): if not self.trained: msg = "{0} has not been trained, so no prediction can be made."\ .format(type(self).__name__) raise RuntimeError(msg)
[docs] def linearize(self, x): msg = "{0} has not defined a jacobian method." \ .format(type(self).__name__) raise RuntimeError(msg)
[docs]class MultiFiSurrogateModel(SurrogateModel): """ Base class for surrogate models using multi-fiddelity training data """
[docs] def train(self, x, y): super(MultiFiSurrogateModel, self).train(x, y) self.train_multifi([x], [y])
[docs] def train_multifi(self, x, y): """Trains the surrogate model, based on the given multi-fidelity training data. x: list of (m samples, n inputs) ndarrays Values representing the multi-fidelity training case inputs. y: list of ndarray output training values which corresponds to the multi-fidelity training case input given by x. """