![]() |
MATLAB中,在得到神经网络函数后,如何用遗传算法求得该函数的最小值?
MATLAB2009a命令流:
ST=[5.22 4.02 11.88 1350.00 412.31 5.80 7.96 38.07 3602.00 376.83 0.81 8.31 17.73 1476.00 830.06 5.85 5.27 41.19 444.00 975.70 4.05 1.58 43.32 3122.00 1493.32 0.62 6.54 46.86 1558.00 745.65 1.78 4.58 28.98 966.00 751.00 3.50 7.47 6.96 1616.00 343.51 6.13 3.25 15.69 386.00 1000.00 6.18 7.22 56.76 528.00 935.95 1.01 5.21 11.07 3770.00 591.61 6.21 3.67 51.51 3826.00 2137.76 6.13 2.13 34.26 2300.00 849.12 3.11 1.58 61.74 238.00 1144.55 5.12 4.88 6.63 938.00 611.56 0.91 8.15 28.50 1412.00 777.82 2.70 8.07 8.34 3286.00 624.50 5.86 7.20 59.67 60.00 1300.00 5.07 2.53 2.22 172.00 1216.55 6.14 7.23 48.45 676.00 822.19 4.20 2.74 51.00 2596.00 937.55 0.23 7.31 54.09 2928.00 550.45 5.44 1.82 6.99 2592.00 987.93 5.98 6.46 25.92 1804.00 170.00 4.35 7.69 17.55 2188.00 245.76 ]; for m = 1:25 STAR(m,1:5)=ST(m,1:5); end %%对25组数据进行RBF拟合 p1=STAR(:,1:4);%训练样本的输入单元 t1=STAR(:,5);%训练样本的输出单元 P=p1';T=t1';%转置 [p,pp] = mapminmax(P);%数据归一化 [t,tt] = mapminmax(T);%数据归一化 spread=1; goal=1e-5; df=1; mn=40; net=newrb(p,t,goal,spread,mn,df); %%%%%%%%%%%%%%%%%遗传算法 fit = @(x) sim(net,x); options = gaoptimset('Generations',100,'PopulationSize',20,... 'CrossoverFraction', 0.8, 'ParetoFraction', 0.5); [x fval] = ga(fit,4, [], [], [], [], [-1;-1;-1;-1], [1;1;1;1]); x; 在最后遗传算法时总是说: ??? Error using ==> network.sim at 178 Inputs are incorrectly sized for network. Matrix must have 4 rows. 以及一大堆错误了 求大侠们帮帮忙 |
所有时间均为北京时间。现在的时间是 16:56。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.