首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Matlab > 遗传算法,想学果断看过来

遗传算法,想学果断看过来

资 源 简 介

clc; clear; %%%%%%%%%%%%%%%%%%%%初始化%%%%%%%%%%%%%%%%%%%%%%% M=50; %种群大小 Pc=0.6; %交叉概率 Pm=0.001; %变异概率 l_limit=-10; %求解区间下限 h_limit=10; %求解区间上限 delta=1/10000; %所需精度 generations=500 ; %繁衍代数 a=(h_limit-l_limit)/delta+1; %临时变量 f=@(x)(sin(x)./x); %目标函数 for icnt=0:inf if a<2^icnt break; end end if mod(icnt,2)==0 l=icnt; %染色体长度 else l=icnt+1; end delta=(h_limit-l_limit)/(2^l-1); %实际精度 x=l_limit:0.01:h_limit; plot(x,f(x),"LineWidth",3),grid %函数图象 %%%%%%%%%%%%%%%%%%%%初始化%%%%%%%%%%%%%%%%%%%%%%%% [x,b,c,d]=fminunc(f,-10) %%%%%%%%%%%%%%%%%%%%构造种群%%%%%%%%%%%%%%%%%%%%%% group=round(unifrnd(0,2^l-1,1,M)); %%%%%%%%%%%%%%%%%%%%构造种群%%%%%%%%%%%%%%%%%%%%%% for lcnt=1:generations %%%%%%%%%%%%%%%%

文 件 列 表

yichuan_mine.m

相 关 资 源

您 可 能 感 兴 趣 的

同 类 别 推 荐

VIP VIP
0.313823s