📄 readme.txt
字号:
SGA(Simple Genetic Algorithm)是一种强大的智能多变量优化算法,它模仿种群繁殖规律来进行
优化。
本SGA可以优化变量,求最小值,最大值(当把函数倒数也就求最小值啦)
并且支持浮点编码,grey编码,二进制编码;轮赌法选择,锦标赛选择;单点交叉,均布交叉,浮点交叉;
单点变异,浮点变异;
调用时
SGA很简单不能很好解决问题,如果需要其他版本的可以和我联系。
if you get some problems,you can email to me
and if you want other advanced algorithm,i can contribute them.
everyday i can response to u.
xihuabin@tom.com
shoppingxo@163.net
qq:10901831
Xi Huabin(席华彬)
si vous avons quelquels problèmes,vous pouvez me donner votre Emails;
je peux recevoir Emails tous les jours,
et si vous voulez les nouvelles versions,pas problème!je vous les donne;
环境:MATLAB6.5+ToolBox
使用说明:
1,首先在TestGA.m文件
修改参数
例一
GAPara.MaxGen =100;
% maximum generation
GAPara.SizePop =200;
% size of population
GAPara.StrAimFcn='AimFcn';
% this is function of counting fitness
GAPara.CodeFcn ='float';
% method of coding, you can choose 'float';'grey';'binary'
GAPara.SelectFcn='roulette';
% method of select you can choose 'tournament';'roulette'
GAPara.CrossFcn ='float';
% method of crossover
GAPara.PCross =[0.7];
% probablity of crossover,between 0 and 1
GAPara.MutationFcn='float';
% method of mutation
GAPara.PMutation=[0.01];
% probability of mutation,between 0 and 1
GAPara.LenChrom =[1 1];
% length of bit of every varible
GAPara.Bound =[-10 10;-10 10];
% bounary of every variable
选择了浮点编码,tournament选择,浮点交叉,浮点变异。
注:采用浮点编码时,以后的交叉,变异只能是浮点,且lenchrom向量中都为1,向量长度为待优化变量个数。
bound为各个变量的范围
例二
GAPara.MaxGen =100;
% maximum generation
GAPara.SizePop =200;
% size of population
GAPara.StrAimFcn='AimFcn';
% this is function of counting fitness
GAPara.CodeFcn ='binary';
% method of coding, you can choose 'float';'grey';'binary'
GAPara.SelectFcn='tournament';
% method of select you can choose 'tournament';'roulette'
GAPara.CrossFcn ='uniform';
% method of crossover
GAPara.PCross =[0.7];
% probablity of crossover,between 0 and 1
GAPara.MutationFcn='simple';
% method of mutation
GAPara.PMutation=[0.01];
% probability of mutation,between 0 and 1
GAPara.LenChrom =[10 10];
% length of bit of every varible
GAPara.Bound =[-10 10;-10 10];
% bounary of every variable
选择了二进制编码,tournament选择,均布交叉,单点变异。
注:采用二进制编码和grey编码时,交叉方法只能是simple,uniform,变异方法只能是simple
lenchrom向量中表示变量表示成二进制的位数。
例三
GAPara.MaxGen =100;
% maximum generation
GAPara.SizePop =200;
% size of population
GAPara.StrAimFcn='AimFcn';
% this is function of counting fitness
GAPara.CodeFcn ='grey';
% method of coding, you can choose 'float';'grey';'binary'
GAPara.SelectFcn='roulette';
% method of select you can choose 'tournament';'roulette'
GAPara.CrossFcn ='uniform';
% method of crossover
GAPara.PCross =[0.7];
% probablity of crossover,between 0 and 1
GAPara.MutationFcn='simple';
% method of mutation
GAPara.PMutation=[0.01];
% probability of mutation,between 0 and 1
GAPara.LenChrom =[10 10];
% length of bit of every varible
GAPara.Bound =[-10 10;-10 10];
% bounary of every variable
选择了grey编码,roulette选择,均布交叉,单点变异。
2,然后在AimFcn.m中给出目标函数
目标函数名可以自己定,例如aim(x),参数只能是x,它是向量啦。
象u=x+y+z等函数,就用x(1),x(2),x(3)表示x,y,z 啦。
3,运行TestGA.m文件就可以了。
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -