資源描述:
《多目標(biāo)遺傳算法代碼》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、WORD格式可編輯%functionnsga_2(pro)%%MainFunction%MainprogramtoruntheNSGA-IIMOEA.%Readthecorrespondingdocumentationtolearnmoreaboutmultiobjective%optimizationusingevolutionaryalgorithms.%initialize_variableshastwoarguments;Firstbeingthepopulationsize%andthesecondtheprob
2、lemnumber.'1'correspondstoMOP1and'2'%correspondstoMOP2.%inp_para_definition=input_parameters_definition;%%Initializethevariables%Declarethevariablesandinitializetheirvalues%pop-population%gen-generations%pro-problemnumber%clear;clc;tic;pop=100;%每一代的種群數(shù)gen=100;%總共的
3、代數(shù)pro=2;%問題選擇1或者2,見switchswitchprocase1%Misthenumberofobjectives.M=2;%Visthenumberofdecisionvariables.Inthiscaseitis%difficulttovisualizethedecisionvariablesspacewhilethe%objectivespaceisjusttwodimensional.V=6;case2M=3;V=12;case3%case1和case2用來對整個算法進(jìn)行常規(guī)驗證,作為調(diào)試之用;ca
4、se3為本工程所需;M=2;%(outputparameters個數(shù))V=8;%(inputparameters個數(shù))K=10;end%Initializethepopulationchromosome=initialize_variables(pop,pro);%%Sorttheinitializedpopulation%Sortthepopulationusingnon-domination-sort.Thisreturnstwocolumns%foreachindividualwhicharetherankandth
5、ecrowdingdistance%correspondingtotheirpositioninthefronttheybelong.真是牛X了。chromosome=non_domination_sort_mod(chromosome,pro);%%Starttheevolutionprocess專業(yè)知識分享WORD格式可編輯%Thefollowingareperformedineachgeneration%Selecttheparents%PerfromcrossoverandMutationoperator%Perf
6、ormSelectionfori=1:gen%Selecttheparents%Parentsareselectedforreproductiontogenerateoffspring.The%originalNSGA-IIusesabinarytournamentselectionbasedonthe%crowded-comparisionoperator.Theargumentsare%pool-sizeofthematingpool.Itiscommontohavethistobehalfthe%population
7、size.%tour-Tournamentsize.OriginalNSGA-IIusesabinarytournament%selection,buttoseetheeffectoftournamentsizethisiskept%arbitary,tobechoosenbytheuser.pool=round(pop/2);tour=2;%下面進(jìn)行二人錦標(biāo)賽配對,新的群體規(guī)模是原來群體的一半parent_chromosome=tournament_selection(chromosome,pool,tour);%Per
8、fromcrossoverandMutationoperator%TheoriginalNSGA-IIalgorithmusesSimulatedBinaryCrossover(SBX)and%Polynomialcrossover.Crossoverprobabilitypc=0.9andmutati