资源简介
实数编码的单目标遗传算法程序,含不等式约束的处理,对于初学者提供很好地范例
代码片段和文件信息
function gaDat=ga(g)
%
% Basic Genetic Algorithm
%
% gaDat=ga(gaDat)
% gaDat : Data structure used by the algorithm.
%
% Data structure:
% Parameters that have to be defined by user
% gaDat.FieldD=[lb; ub]; % lower (lb) and upper (up) bounds of the search space.
% % each dimension of the search space requires bounds
% gaDat.Objfun=‘costFunction‘; % Name of the 0bjective function to be minimize
%
% Parameters that could be defined by user in other case there is a default value
% gaDat.MAXGEN={gaDat.NVAR*20+10}; % Number of generation gaDat.NVAR*20+10 by default
% gaDat.NIND={gaDat.NVAR*50} ; % Size of the population gaDat.NVAR*50 by default
% gaDat.alfa={0}; % Parameter for linear crossover 0 by default
% gaDat.Pc={0.9}; % Crossover probability 0.9 by default
% gaDat.Pm={0.1}; % Mutation probability 0.1 by default
% gaDat.ObjfunPar={[]}; % Additional parameters of the objective function
% % have to be packed in a structure empty by default
% gaDat.indini={[]}; % Initialized members of the initial population empty
% % by default
%
% Grupo de Control Predictivo y Optimizaci髇 - CPOH
% Universitat Polit鑓nica de Val鑞cia.
% http://cpoh.upv.es
% (c) CPOH 1995 - 2012
if nargin==1
gaDat=g;
else
error(‘It is necessary to pass a data structure: gaDat.FieldD and gaDat.Objfun‘)
end
% If the parameter doesn‘t exist in the data structure it is created with the default value
if ~isfield(gaDat‘NVAR‘)
gaDat.NVAR=size(gaDat.FieldD2);
end
if ~isfield(gaDat‘MAXGEN‘)
% gaDat.MAXGEN=gaDat.NVAR*20+10;
gaDat.MAXGEN= 1000;
end
if ~isfield(gaDat‘NIND‘)
% gaDat.NIND=gaDat.NVAR*50;
gaDat.NIND= 100;
end
if ~isfield(gaDat‘alfa‘)
gaDat.alfa=0;
end
if ~isfield(gaDat‘Pc‘)
gaDat.Pc=0.9;
end
if ~isfield(gaDat‘Pm‘)
gaDat.Pm=0.1;
end
if ~isfield(gaDat‘ObjfunPar‘)
gaDat.ObjfunPar=[];
end
if ~isfield(gaDat‘indini‘)
gaDat.indini=[];
end
gaDat.MAXGEN = 2000;
gaDat.NIND = 100;
% Internal parameters
gaDat.Chrom=[];
gaDat.ObjV=[];
gaDat.xmin=[];
gaDat.fxmin=inf;
gaDat.xmingen=[];
gaDat.fxmingen=[];
gaDat.rf=(1:gaDat.NIND)‘;
gaDat.gen=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generation counter
gen=0;
% Initial population ---------------------------------------
gaDat.Chrom=crtrp(gaDat.NINDgaDat.FieldD); % Real codification
% Individuals of gaDat.indini are randomly added in the initial population
if not(isempty(gaDat.indini))
nind0=size(gaDat.indini1);
posicion0=ceil(rand(1nind0)*gaDat.NIND);
gaDat.Chrom(posicion0:)=gaDat.indini;
end
while (gaDat.gen gaDat.gen=gen;
gaDat=gaevolucion(gaDat);
% Increase generation counter ------------------
gaDat.xmingen(gen+1:)=gaDat.xmin;
gaDat.fxmingen(gen+1:)=gaDat.fxmin;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 14617 2013-12-22 12:46 单目标优化\ga.m
文件 257 2013-04-25 10:44 单目标优化\gaExample_4.m
文件 370 2012-11-10 03:08 单目标优化\gaiteration.m
文件 363 2012-11-10 18:12 单目标优化\garesults.m
文件 754 2013-04-25 10:57 单目标优化\objfun_example4.m
目录 0 2013-12-22 12:41 单目标优化\
相关资源
- 编程实现二维DCT变换
- 图像二值化
- 用FFT对信号进行频谱分析
- Tone-Reservation
- QGA 量子遗传算法
- 差分形式的阻滞增长模型
- 遗传算法的M文件
- 简单二阶互联系统的非线性动力学分
- 手写数字识别-模板匹配法
- Stock_Watson_动态因子分析模型
- 果蝇优化算法优化支持向量回归程序
- 自己做的一个简单GUI扑克纸牌识别-
- multi output SVR
- AR过程的线性建模过程与各种功率谱估
- PCNN TOOLBOX
- plstoolbox.zip
- 中国国家基础地理信息系统GIS数据
- 粒子群微电网优化调度
- 矩阵分析-经典教材-中文版-Roger.A.Ho
- 压缩感知TwIST
- 基于最小错误率的贝叶斯手写数字分
- 最全系统辨识源代码,包括多种最小
- 导弹制导实验
- 画跟踪精确度图的程序.zip
- 重力场大地水准面及重力异常阶次误
- prtools5.2.3工具包
- 脉冲耦合神经网络工具箱PCNN-toolbox
- SVM算法-回归拟合程序.zip
- Kriging代理模型EGO算法.zip
- Matalb实现停车场完整系统
评论
共有 条评论