文件名称:大地电磁測深遗传算法反演
文件大小:20KB
文件格式:RAR
更新时间:2018-07-02 09:42:18
GA MT
程序完整
function [x,traceInfo]=HGA(bounds,evalFN,FN1,FN2,pc,pm,ps,la,mref,maxGen)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output Arguments:
% x - the best solution found during the course of the run
% bPop - a trace of the best population
% traceInfo - a matrix of best and means of the ga for each generation
%
% Input Arguments:
% bounds - a matrix of upper and lower bounds on the variables
% evalFN - the name of the evaluation .m function
% FN1 - 为数据目标函数;
% FN2 - 为模型目标函数
% la -a initial factot of regularization;
% mref -a reference model
% pc -Probability of cross
% pm -Probability of mutation
% maxGen -Maximum Number of Generations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M=40; %定义种群规模
startPop =initialize(M,bounds);
xZomeLength =size(startPop,2)+1; %返回个体的变量数目加上适值所占一位
numVar =xZomeLength-1; %变量数目
popSize =size(startPop, 1); %得到个体大小
endPop =zeros(popSize,xZomeLength); %最终得到的种群
c1 =zeros(1,xZomeLength); %得到一个个体,为交叉准备
c2 =zeros(1,xZomeLength); %得到另一个个体,为交叉准备
gen =1; %Current Generation Number,当前的种群数
xOverFNs =['arithXover heuristicXover simpleXover']; %交叉函数名称表,以空格分开
mutFNs =['multiNonUnifMutation nonUnifiMutation unifMutation']; %变异函数表
xOverFNs =parse(xOverFNs); %分析交叉函数
mutFNs =parse(mutFNs);
numXOvers =size(xOverFNs, 1 );
numMuts =size(mutFNs, 1);
while(gen<=maxGen)
for i=1:popSize
startPop(i,xZomeLength)=feval(evalFN,startPop(i,1:numVar),la,mref);
end
[bval,bindx]=max(startPop(:,xZomeLength));
best=startPop(bindx,:);
traceInfo(gen,1)=gen; %每一代种群的最优个体和代数
traceInfo(gen,2)=startPop(bindx,xZomeLength); %找出适应值最优个体
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%选择操作
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
endPop =select(startPop);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%交叉操作
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ct=0;
a=rand(popSize, 1);
for i=1:popSize
if(a(i, 1 )
【文件预览】:
程序
----arithXover.m(2KB)
----unifMutation.m(2KB)
----反演主程序.txt(216B)
----simpleXover.m(2KB)
----multiNonUnifMutation.m(2KB)
----delta.m(1KB)
----HGA.m(6KB)
----initialize.m(1KB)
----parse.m(1KB)
----evalFN.m(107B)
----FN2.m(145B)
----select.m(853B)
----nonUnifiMutation.m(2KB)
----hs_err_pid6104.log(6KB)
----FN1.m(21KB)
----heuristicXover.m(2KB)
----fmodeling.m(22KB)