SGAPublic
所属分类:matlab编程
开发工具:matlab
文件大小:5KB
下载次数:9
上传日期:2010-04-19 08:43:41
上 传 者:
wxrdyf12
说明: 基于遗传算法求最优解的有用程序语言
方便校演程序结果文件
(Optimal solution based on genetic algorithms to facilitate a useful programming language school speech program results file)
文件列表:
SGAPublic\AimFunc.m (105, 2003-07-26)
SGAPublic\Code.m (887, 2010-04-19)
SGAPublic\Cross.m (3484, 2003-07-24)
SGAPublic\Decode.m (953, 2003-07-16)
SGAPublic\Genetic.m (4081, 2003-07-26)
SGAPublic\Mutation.m (2295, 2003-07-16)
SGAPublic\Select.m (1502, 2003-07-26)
SGAPublic (0, 2010-04-19)
SGA(Simple Genetic Algorithm)是一种强大的智能多变量优化算法,它模仿种群繁殖规律来进行
优化。
本SGA可以优化变量,求最小值,最大值(当把函数倒数也就求最小值啦)
并且支持浮点编码,grey编码,二进制编码;轮赌法选择,锦标赛选择;单点交叉,均布交叉,浮点交叉;
单点变异,浮点变异;
调用时
Genetic(目标函数名)
if you get some problems,you can email to me
shoppingxo@hotmail.com
qq:10901831
Xi Huabin(席华彬)
使用环境:MATLAB6.5+ToolBox
使用SGA时,
首先需要一个目标函数(像AimFunc.m),该函数返回适应度
输入变量为待优化变量x
输出为一个适应度。
然后
修改Genetic.m中可以修改的地方
例一
maxgen=200; % maximum generation
sizepop=100; % size of population
AimFunc=StrAimFunc; % this is function of counting fitness
fselect='tournament'; % method of select
% you can choose 'tournament';'roulette'
fcode='float'; % method of coding
% you can choose 'float';'grey';'binary'
pcross=[0.6]; % probablity of crossover,between 0 and 1
fcross='float'; % method of crossover
% you can choose 'float';'simple';'uniform'
pmutation=[0.2]; % probability of mutation,between 0 and 1
fmutation='float'; % method of mutation
% you can choose 'float';'simple';
lenchrom=[1 1 1 1 1]; % length of bit of every varible
bound=[0 1;...
0 1;...
0 1;...
0 1;...
0 1];
选择了浮点编码,tournament选择,浮点交叉,浮点变异。
注:采用浮点编码时,以后的交叉,变异只能是浮点,且lenchrom向量中都为1,向量长度为待优化变量个数。
bound为各个变量的范围
例二
maxgen=200; % maximum generation
sizepop=100; % size of population
AimFunc=StrAimFunc; % this is function of counting fitness
fselect='tournament'; % method of select
% you can choose 'tournament';'roulette'
fcode='binary'; % method of coding
% you can choose 'float';'grey';'binary'
pcross=[0.6]; % probablity of crossover,between 0 and 1
fcross='uniform'; % method of crossover
% you can choose 'float';'simple';'uniform'
pmutation=[0.2]; % probability of mutation,between 0 and 1
fmutation='simple'; % method of mutation
% you can choose 'float';'simple';
lenchrom=[10 10 10 10 10]; % length of bit of every varible
bound=[0 1;...
0 1;...
0 1;...
0 1;...
0 1];
选择了二进制编码,tournament选择,均布交叉,单点变异。
注:采用二进制编码和grey编码时,交叉方法只能是simple,uniform,变异方法只能是simple
lenchrom向量中表示变量表示成二进制的位数。
例三
maxgen=200; % maximum generation
sizepop=100; % size of population
AimFunc=StrAimFunc; % this is function of counting fitness
fselect='roulette'; % method of select
% you can choose 'tournament';'roulette'
fcode='grey'; % method of coding
% you can choose 'float';'grey';'binary'
pcross=[0.6]; % probablity of crossover,between 0 and 1
fcross='uniform'; % method of crossover
% you can choose 'float';'simple';'uniform'
pmutation=[0.2]; % probability of mutation,between 0 and 1
fmutation='simple'; % method of mutation
% you can choose 'float';'simple';
lenchrom=[10 10 10 10 10]; % length of bit of every varible
bound=[0 1;...
0 1;...
0 1;...
0 1;...
0 1];
选择了grey编码,roulette选择,均布交叉,单点变异。
近期下载者:
相关文件:
收藏者: