예제 #1
0
 def test_save(self):
     fname = 'ezyrb.tmp'
     pod = POD()
     rbf = RBF()
     db = Database(param, snapshots.T)
     rom = ROM(db, pod, rbf)
     rom.fit()
     rom.save(fname)
예제 #2
0
    def test_with_db_predict(self):
        reg = Linear()
        pod = POD()
        db = Database(np.array([1, 2, 3])[:,None], np.array([1, 5, 3])[:,None])
        rom = ReducedOrderModel(db, pod, reg)

        rom.fit()
        assert rom.predict([1]) == 1
        assert rom.predict([2]) == 5
        assert rom.predict([3]) == 3
예제 #3
0
    def test_with_db_predict(self):
        reg = RadiusNeighborsRegressor(radius=0.5)
        pod = POD()
        db = Database(
            np.array([1, 2, 3])[:, None],
            np.array([1, 5, 3])[:, None])
        rom = ReducedOrderModel(db, pod, reg)

        rom.fit()
        assert rom.predict([1]) == 1
        assert rom.predict([2]) == 5
        assert rom.predict([3]) == 3
예제 #4
0
 def test_load2(self):
     fname = 'ezyrb2.tmp'
     pod = POD()
     rbf = RBF()
     db = Database(param, snapshots.T)
     rom = ROM(db, pod, rbf)
     rom.fit()
     rom.save(fname, save_db=False)
     new_rom = ROM.load(fname)
     new_param = [-0.293344, -0.23120537]
     np.testing.assert_array_almost_equal(
         rom.predict(new_param),
         new_rom.predict(new_param)
     )
예제 #5
0
#POD offline
snapshots = np.load('Snapshots/Snapshot75b.npy')
print(f'Total number of columns in snapshot matrix = {len(snapshots[0])}')
limit = int(0.8 * len(snapshots[0]))
snapshots = snapshots[:, 0:limit]
snapshots = np.transpose(snapshots)

param = np.load('Param/Param75b.npy')
param_snap = param[:, 0:limit]
param_snap = np.transpose(param_snap)

db = Database(param_snap, snapshots)
pod = POD('svd')
rbf = RBF()
rom = ROM(db, pod, rbf)
rom.fit()

#POD Online
param_train = np.transpose(param[:, limit:len(param[0])])
Error_array = np.zeros((len(param[0]) - limit, 1))
train_limit = len(param[0]) - limit

for i in range(0, train_limit):
    param_i = param_train[i, :]
    [A, b, TleftBC] = buildadvdefop(param_i[0], param_i[1], param_i[2])
    wcomp = np.linalg.solve(A, b).T.squeeze()
    pred_sol = rom.predict(param_i)
    MSE = np.square(np.subtract(wcomp, pred_sol)).mean()
    RMSE = math.sqrt(MSE)
    Error_array[i, :] = RMSE