資源描述:
《多目標(biāo)遺傳算法代碼.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
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;%每一代的種群數(shù)gen=100;%總共的代數(shù)pro=2;%問(wèn)題選擇1或者2,見(jiàn)switchswitchprocase1%Misthenumberofobjectives.M=2
3、;%Visthenumberofdecisionvariables.Inthiscaseitis%difficulttovisualizethedecisionvariablesspacewhilethe%objectivespaceisjusttwodimensional.V=6;case2M=3;V=12;case3%case1和case2用來(lái)對(duì)整個(gè)算法進(jìn)行常規(guī)驗(yàn)證,作為調(diào)試之用;case3為本工程所需;M=2;%(outputparameters個(gè)數(shù))V=8;%(inputparameters個(gè)數(shù))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;%下面進(jìn)行二人錦標(biāo)賽配對(duì),新的群體規(guī)模是原來(lái)群體的一半pa
7、rent_chromosome=tournament_selection(chromosome,pool,tour);%PerfromcrossoverandMutationoperator%TheoriginalNSGA-IIalgorithmusesSimulatedBinaryCrossover(SBX)and%Polynomialcrossover.Crossoverprobabilitypc=0.9andmutation%probabilityispm=1/