def obj_func3(x): Q_et = heat_flux.heat_flux_solve(x[0], 1, x[1], 0.9,x[2],0.9) shiyingdu0 = np.sum(np.square(Q_et[0]-Q_real[0])) shiyingdu1 = np.sum(np.square(Q_et[1]-Q_real[1])) shiyingdu2 = np.sum(np.square(Q_et[2]-Q_real[2])) shiyingdu = shiyingdu0 + shiyingdu1 + shiyingdu2 return shiyingdu
def temprature_main(): t1_generation = [] t3_generation = [] for i in range(9): F = 0.1*(i+1) de = DE(func=obj_func, n_dim=2, size_pop=100, max_iter=100, lb=[0, 0 ], ub=[1, 1], F = F) best_x, best_y, t_best = de.run() print('best_x:', best_x, '\n', 'best_y:', best_y) Q_best = heat_flux.heat_flux_solve(best_x[0], 1, best_x[1])[1] t1_generation.append(t_best[:,0]) t3_generation.append(t_best[:,1]) df = pd.DataFrame(best_x) df.to_csv('/biyesheji/交叉因子为'+str(F)+'.csv') save_t1 = pd.DataFrame(t1_generation) save_t3 = pd.DataFrame(t3_generation) save_t1.to_csv('/biyesheji/t1_data.csv') save_t3.to_csv('/biyesheji/t3_data.csv')
import heat_flux from sko.DE import DE # from sko.DE_ori import DE_ori import numpy as np import pandas as pd from sko.DE_gai import DE_gai Q_real = heat_flux.heat_flux_solve() # 温度实验迭代 def obj_func(x): Q_et = heat_flux.heat_flux_solve(x[0], 1, x[1]) shiyingdu0 = np.sum(np.square(Q_et[0]-Q_real[0])) shiyingdu1 = np.sum(np.square(Q_et[1]-Q_real[1])) shiyingdu2 = np.sum(np.square(Q_et[2]-Q_real[2])) shiyingdu = shiyingdu0 + shiyingdu1 + shiyingdu2 return shiyingdu def temprature_main(): t1_generation = [] t3_generation = [] for i in range(9): F = 0.1*(i+1) de = DE(func=obj_func, n_dim=2, size_pop=100, max_iter=100, lb=[0, 0 ], ub=[1, 1], F = F) best_x, best_y, t_best = de.run() print('best_x:', best_x, '\n', 'best_y:', best_y)
def main(i): x = np.linspace(0, 4, i) y = heat_flux.heat_flux_solve(l_divide=i)[1] return x, y