m基于GA遗传算法的PMSM永磁同步电机参数最优计算matlab仿真( 二 )

< MAXGEN;genPe0 = 0.995;pe1 = 0.005; FitnV=ranking(Objv);Selch=select('sus',Chrom,FitnV);Selch=recombin('xovsp', Selch,Pe0);Selch=mut( Selch,pe1);phen1=bs2rv(Selch,FieldD);size(Objv)size(Chrom)size(FitnV)Rs = [];Rr = [];M= [];Ld = [];Lq = [];p= [];J= []; for a=1:1:NINDRs(a) = phen1(a,1);Rr(a) = phen1(a,2); M(a)= phen1(a,3); Ld(a) = phen1(a,4); Lq(a) = phen1(a,5); p(a)= floor(phen1(a,6))+1; J(a)= phen1(a,7); %计算对应的目标值epls= func_obj(Rs(a),Rr(a),M(a),Ld(a),Lq(a),p(a),J(a));E= epls;JJ(a,1) = E;end Objvsel=(JJ);[Chrom,Objv]=reins(Chrom,Selch,1,1,Objv,Objvsel);gen=gen+1; %保存参数收敛过程和误差收敛过程以及函数值拟合结论index1= isnan(JJ);index2= find(index1 == 1);JJ(index2) = [];Error2(gen) = min(JJ);[VV,II]=min(JJ);Rs3(gen)= [mean(Rs)]; %转子电阻Rr3(gen)= [mean(Rr)]; %定子电阻M3(gen)= [mean(M)]; %磁链Ld3(gen)= [mean(Ld)]; %d轴电感Lq3(gen)= [mean(Lq)]; %q轴电感p3(gen)= [mean(p)];%极对数J3(gen)= [mean(J)]; %转动惯量if gen<=64Rs4= [Rs4,mean(Rs3(1:gen))]; %转子电阻Rr4= [Rr4,mean(Rr3(1:gen))]; %定子电阻M4= [M4,mean(M3(1:gen))]; %磁链Ld4= [Ld4,mean(Ld3(1:gen))]; %d轴电感Lq4= [Lq4,mean(Lq3(1:gen))]; %q轴电感p4= [p4,mean(p3(1:gen))];%极对数J4= [J4,mean(J3(1:gen))]; %转动惯量elseRs4= [Rs4,mean(Rs3(gen-64:gen))]; %转子电阻Rr4= [Rr4,mean(Rr3(gen-64:gen))]; %定子电阻M4= [M4,mean(M3(gen-64:gen))]; %磁链Ld4= [Ld4,mean(Ld3(gen-64:gen))]; %d轴电感Lq4= [Lq4,mean(Lq3(gen-64:gen))]; %q轴电感p4= [p4,mean(p3(gen-64:gen))];%极对数J4= [J4,mean(J3(gen-64:gen))]; %转动惯量endend [V,I] = min(JJ);VRs_best = Rs(I) Rr_best = Rr(I)M_best= M(I)Ld_best = Ld(I) Lq_best = Lq(I)p_best= p(I) J_best= J(I)save result.mat Rs_best Rr_best M_best Ld_best Lq_best p_best J_best02_042m
【m基于GA遗传算法的PMSM永磁同步电机参数最优计算matlab仿真】4.完整