?? readme.txt
字號:
SGA(Simple Genetic Algorithm)是一種強(qiáng)大的智能多變量優(yōu)化算法,它模仿種群繁殖規(guī)律來進(jìn)行
優(yōu)化。
本SGA可以優(yōu)化變量,求最小值,最大值(當(dāng)把函數(shù)倒數(shù)也就求最小值啦)
并且支持浮點(diǎn)編碼,grey編碼,二進(jìn)制編碼;輪賭法選擇,錦標(biāo)賽選擇;單點(diǎn)交叉,均布交叉,浮點(diǎn)交叉;
單點(diǎn)變異,浮點(diǎn)變異;
調(diào)用時
SGA很簡單不能很好解決問題,如果需要其他版本的可以和我聯(lián)系。
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;
環(huán)境:MATLAB6.5+ToolBox
使用說明:
1,首先在TestGA.m文件
修改參數(shù)
例一
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
選擇了浮點(diǎn)編碼,tournament選擇,浮點(diǎn)交叉,浮點(diǎn)變異。
注:采用浮點(diǎn)編碼時,以后的交叉,變異只能是浮點(diǎn),且lenchrom向量中都為1,向量長度為待優(yōu)化變量個數(shù)。
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
選擇了二進(jìn)制編碼,tournament選擇,均布交叉,單點(diǎn)變異。
注:采用二進(jìn)制編碼和grey編碼時,交叉方法只能是simple,uniform,變異方法只能是simple
lenchrom向量中表示變量表示成二進(jìn)制的位數(shù)。
例三
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選擇,均布交叉,單點(diǎn)變異。
2,然后在AimFcn.m中給出目標(biāo)函數(shù)
目標(biāo)函數(shù)名可以自己定,例如aim(x),參數(shù)只能是x,它是向量啦。
象u=x+y+z等函數(shù),就用x(1),x(2),x(3)表示x,y,z 啦。
3,運(yùn)行TestGA.m文件就可以了。
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -