用简单遗传算法SGA实现的关于控制图的程序

源代码在线查看: readme.txt

软件大小: 18 K
上传用户: ahkid
关键词: SGA 算法 控制 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				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选择,均布交叉,单点变异。
				
							

相关资源