本文主要是介绍在python中使用代理模型加快fmu模拟速度,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
from pyfmi import load_fmu
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn.tree import DecisionTreeRegressor # 决策树算法
from sklearn.metrics import r2_score
# 全局 FMU 对象
model = load_fmu(r'C:\Users\win10\Desktop\GPS\test10.fmu')
simulation_data = []
for _ in range(100):x1 = np.random.uniform(0.3, 2.7)x2 = np.random.uniform(0.3, 2.7)if (x1 - 0.5 > x2 and x1 > 0.3 and x1 < 2.7 and x2 > 0.3 and x2 < 2.7): model.set('hysteresis1.uHigh', x1)model.set('hysteresis1.uLow', x2)res = model.simulate(start_time=0, final_time=82800)p_data = model.get('standardDeviation1.y')simulation_data.append(([x1, x2], np.max(p_data)))else:continue
print(simulation_data)
input_values, output_values = zip(*simulation_data)
input_values = np.array(input_values)
output_values = np.array(output_values)# 训练决
这篇关于在python中使用代理模型加快fmu模拟速度的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!