def get_F110_interp(): this_dir = os.path.split(__file__)[0] xt, yt, xlimits = get_data() interp = RMTB( xlimits=xlimits, num_ctrl_pts=15, order=4, approx_order=2, nonlinear_maxiter=40, solver_tolerance=1.e-20, # solver='lu', derivative_solver='lu', energy_weight=1.e-4, regularization_weight=0.e-18, extrapolate=False, print_global=False, data_dir=os.path.join(this_dir, '_smt_cache'), ) # interp = KRG(theta0=[0.1]*3, data_dir='_smt_cache/') interp.set_training_values(xt, yt) interp.train() return interp
def test_rmtb(self): import numpy as np import matplotlib.pyplot as plt from smt.surrogate_models import RMTB xt = np.array([0.0, 1.0, 2.0, 3.0, 4.0]) yt = np.array([0.0, 1.0, 1.5, 0.5, 1.0]) xlimits = np.array([[0.0, 4.0]]) sm = RMTB( xlimits=xlimits, order=4, num_ctrl_pts=20, energy_weight=1e-15, regularization_weight=0.0, ) sm.set_training_values(xt, yt) sm.train() num = 100 x = np.linspace(0.0, 4.0, num) y = sm.predict_values(x) plt.plot(xt, yt, "o") plt.plot(x, y) plt.xlabel("x") plt.ylabel("y") plt.legend(["Training data", "Prediction"]) plt.show()
def rMTBSimba(xt, yt, xtest, ytest, funXLimits): t = RMTB(xlimits=funXLimits, min_energy=True, nonlinear_maxiter=20, print_prediction=False) t.set_training_values(xt, yt) # Add the gradient information # for i in range(ndim): # t.set_training_derivatives(xt,yt[:, 1+i].reshape((yt.shape[0],1)),i) t.train() # Prediction of the validation points print('RMTB, err: ' + str(compute_rms_error(t, xtest, ytest))) # plot prediction/true values title = 'RMTB' return t, title, xtest, ytest
from smt.surrogate_models import RMTB from smt.examples.one_D_step.one_D_step import get_one_d_step, plot_one_d_step xt, yt, xlimits = get_one_d_step() interp = RMTB(num_ctrl_pts=100, xlimits=xlimits, nonlinear_maxiter=20, solver_tolerance=1e-16, energy_weight=1e-14, regularization_weight=0.) interp.set_training_values(xt, yt) interp.train() plot_one_d_step(xt, yt, xlimits, interp)
])) counter += 1 else: skipcount += 1 a = np.array(krigedata) xt = a[:, 0:3] yt = a[:, 3:] print('Data points: ' + str(counter) + ' Skipped: ' + str(skipcount)) # define a RMTS spline interpolant # TODO replace with a different SMT surrogate limits = np.array([[0.2, 0.8], [0.05, 1.0], [0.0, 3.5]]) sm = RMTB(order=3, xlimits=limits, nonlinear_maxiter=100) sm.set_training_values(xt, yt) sm.train() # plot a grid of values at a slice of throttle = 0.5 machs = np.linspace(0.2, 0.8, 25) alts = np.linspace(0.0, 35000., 25) machs, alts = np.meshgrid(machs, alts) pred = np.zeros((25, 25, 3)) pred2 = np.zeros((25, 25, 3)) # altitude is scaled by 1 / 10000 everywhere to make the indepdent variables of O(1) # this is necessary for certain methods like IDW # TODO examine other slices (for example holding Mach = 0.5 and varying other two parameters) for i in range(25): for j in range(25):