欢迎来到天天文库
浏览记录
ID:48917211
大小:64.00 KB
页数:14页
时间:2020-02-06
《多目标遗传算法代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.%functionnsga_2(pro)%%MainFunction%MainprogramtoruntheNSGA-IIMOEA.%Readthecorrespondingdocumentationtolearnmoreaboutmultiobjective%optimizationusingevolutionaryalgorithms.%initialize_variableshastwoarguments;Firstbeingthepopulationsize%andthesecondtheproblemnumber.'1'correspondstoMOP1and'2'%c
2、orrespondstoMOP2.%inp_para_definition=input_parameters_definition;%%Initializethevariables%Declarethevariablesandinitializetheirvalues%pop-population%gen-generations%pro-problemnumber%clear;clc;tic;pop=100;%每一代的种群数gen=100;%总共的代数pro=2;%问题选择1或者2,见switchswitchprocase1%Misthenumberofobjectives.M=2
3、;%Visthenumberofdecisionvariables.Inthiscaseitis%difficulttovisualizethedecisionvariablesspacewhilethe%objectivespaceisjusttwodimensional.V=6;case2M=3;V=12;case3%case1和case2用来对整个算法进行常规验证,作为调试之用;case3为本工程所需;M=2;%(outputparameters个数)V=8;%(inputparameters个数)K=10;end%Initializethepopulationchromos
4、ome=initialize_variables(pop,pro);%%Sorttheinitializedpopulation%Sortthepopulationusingnon-domination-sort.Thisreturnstwocolumns%foreachindividualwhicharetherankandthecrowdingdistance%correspondingtotheirpositioninthefronttheybelong.真是牛X了。chromosome=non_domination_sort_mod(chromosome,pro);%%St
5、arttheevolutionprocess..%Thefollowingareperformedineachgeneration%Selecttheparents%PerfromcrossoverandMutationoperator%PerformSelectionfori=1:gen%Selecttheparents%Parentsareselectedforreproductiontogenerateoffspring.The%originalNSGA-IIusesabinarytournamentselectionbasedonthe%crowded-comparisio
6、noperator.Theargumentsare%pool-sizeofthematingpool.Itiscommontohavethistobehalfthe%populationsize.%tour-Tournamentsize.OriginalNSGA-IIusesabinarytournament%selection,buttoseetheeffectoftournamentsizethisiskept%arbitary,tobechoosenbytheuser.pool=round(pop/2);tour=2;%下面进行二人锦标赛配对,新的群体规模是原来群体的一半pa
7、rent_chromosome=tournament_selection(chromosome,pool,tour);%PerfromcrossoverandMutationoperator%TheoriginalNSGA-IIalgorithmusesSimulatedBinaryCrossover(SBX)and%Polynomialcrossover.Crossoverprobabilitypc=0.9andmutation%probabilityispm=1/
此文档下载收益归作者所有