遗传算法求解函数最大值(matlab).docx

F(x1 , x2)=100*(x1^2-x2)^2+(1-x1)^2;遗传算法求解函数的最大值 (MATLAB)%Generic Algorithm for function f(x1,x2) optimum clear all;close all;(最大值)%Parameters Size=80; G=100;CodeL=10;umax=2.048;umin=-2.048; F(x1 , x2)=100*(x1^2-x2)^2+(1-x1)^2; 遗传算法求解函数 的最大值 (MATLAB) %Generic Algorithm for function f(x1,x2) optimum clear all; close all; (最大值) %Parameters Size=80; G=100; CodeL=10; umax=2.048; umin=-2.048; E=round(rand(Size,2*CodeL)); %Initial Code %Main Program for k=1:1:G time(k)=k; for s=1:1:Size m=E(s,:); y1=0;y2=0; %Uncoding m1=m(1:1:CodeL); for i=1:1:CodeL y1=y1+m1(i)*2^(i-1); end x1=(umax-umin)*y1/1023+um

文档评论(0)

1亿VIP精品文档

相关文档