GA:利用GA對一元函數進行優化過程,求x∈(0,10)中y的最大值——Jason niu
阿新 • • 發佈:2018-02-25
title variable ati 過程 優化 mea ... http []
x = 0:0.01:10; y = x + 10*sin(5*x)+7*cos(4*x); figure plot(x, y) xlabel(‘independent variable‘) ylabel(‘dependent variable‘) title(‘GA:y = x + 10*sin(5*x) + 7*cos(4*x)利用算法求解最優解—Jason niu‘) initPop = initializega(50,[0 10],‘fitness‘); [x endPop bpop trace] = ga([0 10],‘fitness‘,[],initPop,[1e-6 1 1],‘maxGenTerm‘,25,... ‘normGeomSelect‘,0.08,‘arithXover‘,2,‘nonUnifMutation‘,[2 25 3]); x hold on plot (endPop(:,1),endPop(:,2),‘ro‘) figure(2) plot(trace(:,1),trace(:,3),‘b:‘) title(‘GA算法的叠代進化曲線—Jason niu‘) hold on plot(trace(:,1),trace(:,2),‘r-‘) xlabel(‘Generation‘); ylabel(‘Fittness‘); legend(‘Mean Fitness‘, ‘Best Fitness‘)
GA:利用GA對一元函數進行優化過程,求x∈(0,10)中y的最大值——Jason niu