大地电磁測深遗传算法反演
程序完整 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 )<pc) ct=ct+1; end end ctt=0; while(ctt<=ct) for i=1 :numXOvers a=round(rand*(popSize-1)+1); b=round(rand*(popSize-1)+1); xN=deblank(xOverFNs(i,:)); [c1 c2]=feval(xN,endPop(a,:),endPop(b,:),bounds); if c1(1:numVar)==endPop(a,(1:numVar)) c1(xZomeLength)=endPop(a,xZomeLength); elseif c1(1:numVar)==endPop(b,(1:numVar)) c1(xZomeLength)=endPop(b,xZomeLength); else c1(xZomeLength)=feval(evalFN,c1(1:numVar),la,mref); end if c2(1:numVar)==endPop(a,(1:numVar)) c2(xZomeLength)=endPop(a,xZomeLength); elseif c2(1:numVar)==endPop(b,(1:numVar)) c2(xZomeLength)=endPop(b,xZomeLength); else c2(xZomeLength)=feval(evalFN,c2(1:numVar),la,mref); end endPop(a,:)=c1; endPop(b,:)=c2; end ctt=ctt+1; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %变异操作 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% mt=pm*popSize; mtt=0; while(mtt<mt) for i=1:numMuts a=round(rand*(popSize-1)+1); c1=feval(deblank(mutFNs(i,:)),endPop(a,:),bounds,gen,maxGen); if c1(1:numVar)==endPop(a,(1:numVar)) c1(xZomeLength)=endPop(a,xZomeLength); else c1(xZomeLength)=feval(evalFN,c1(1:numVar),la,mref); end endPop(a,:)=c1; end mtt=mtt+1; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %单纯形搜索算子 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% st=0; a=rand(popSize,1); for i=1:popSize if(a(i,1)<ps) st=st+1; end end stt=0; while(stt<=st) a=round(rand*(popSize-1)+1); %pack c1(1:numVar)=fminsearch(FN1,endPop(a,(1:numVar))); for i=1:numVar if c1(i)<bounds(i,1) c1(i)=bounds(i,1); elseif c1(i)>bounds(i,2) c1(i)=bounds(i,2); end end c1(xZomeLength)=feval(evalFN,c1(1:numVar),la,mref); endPop(a,:)=c1; stt=stt+1; end gen=gen+1; startPop=endPop; [bval,bindx]=min(startPop(:,xZomeLength)); startPop(bindx,:)=best; fl=FN1(best(1:numVar)); %最优个体保存策略 f2=FN2(best(1:numVar),mref); %更新止则化囚子 la=fl/(fl+f2); end [bval,bindx]=max(startPop(:,xZomeLength)); traceInfo(gen,1)=gen; traceInfo(gen,2)=startPop(bindx,xZomeLength); %最优个体的适应值 x=startPop(bindx,:); %遗传优化的最优解
- 1
- 粉丝: 0
- 资源: 1
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 神经网络 使用手写字数据集 实现分割任务 CNN
- 基于maxwell的4极6槽 内转子 11000rpm 输出转矩 156mNm 效率85% 180W 外径 48mm 内径27 轴向长度30mm 直流母线36V 永磁同步电机(永磁直流无刷)模型
- FPGA开发:SDRAM驱动代码,使用串口向sdram写数据,数据环回后被SDRAM送回到串口进行输出,中间使用FIFO进行跨时钟域处理,所用开发板DE2-115,SDRAM型号IS42S16320D
- ZTE C600&C620&C650命令参考
- python-workspace.zip.006
- FX5U FX40SSC 程序 FX5U FX 40SSC运动控制模块程序块 自己整合的针对FX 40SSC模块的功能块,支持点动故障码 状态码 相对定位 绝对定位 直接1指定轴号就可以
- 汽车二、三自由度模型 汽车二、三自由度模型 本人用了三种不同方法搭的汽车线性二自由度simulink模型,文档里包含有具体的车辆数值 适合初学者学习simulink使用(ps.模型输入为前轮转角,输出
- KUKA机器人码垛程序备份
- dbstudio-3.8.5.102.win64 神通数据库连接工具
- 开源TVBox影视盒子 小苹果影视盒子V1.5.7 2025新版
- 基于国产M0核MCU平台,全开源双电阻采样FOC高压 风机量产程序,包含龙博格电机观测器,SVPWM,顺逆风启动,五段式与七段式调制等源码,完全可以移植到别的MCU平台 适合电机算法研究
- 交替迭代法 matlab 无功优化 通过含固态变压器的无功优化算法,形成交替迭代潮流计算,最终计算出符合预期的电压曲线,程序方法包括包括牛拉法 前推回代等,参考性强
- 综合能源耦合微网优化程序matlab 程序基于冷热电联供综合能源耦合模型,采用cchp,并且含有压缩空气储能,采用粒子群优化求解
- DataGrip 2021.3 数据库连接工具
- 考虑碳交易的微网优化模型matlab
- FreeRTOS 是一款开源的、可抢占式的实时操作系统.docx