資源簡(jiǎn)介
用于多目標(biāo)優(yōu)化問(wèn)題的學(xué)習(xí)程序,解決帶有約束問(wèn)題的多目標(biāo)優(yōu)化問(wèn)題。
代碼片段和文件信息
function?excise_lanjiabiao_NSGA_2()
%%?Main?Function
%此程序運(yùn)用NSGA-II的方法求解帶有約束問(wèn)題的多目標(biāo)優(yōu)化問(wèn)題。
%優(yōu)化的目標(biāo)為:f1=x1;
%?????????????f2=(1+x2)/x1;
%約束的條件為:
%?????????????g1=x2+9*x1>=6;
%?????????????g2=9*x1-x2>=1;
%?????????????0.1= %?Main?program?to?run?the?NSGA-II?MOEA.
%?Read?the?corresponding?documentation?to?learn?more?about?multiobjective
%?optimization?using?evolutionary?algorithms.
%inp_para_definition=input_parameters_definition;
%%?Initialize?the?variables
%?Declare?the?variables?and?initialize?their?values
%?pop?-?population?種群數(shù)量
%?gen?-?generations?總共的后代個(gè)數(shù)
clear;clc;tic;
pop?=?input(‘輸入每一代的種群數(shù)?\n‘);?%?每一代的種群數(shù)
gen?=?input(‘輸入總共的后代數(shù)?\n‘);?%?總共的代數(shù)
M?=?2;?%?M?is?the?number?of?objectives.
V?=?2;?%?V?is?the?number?of?decision?variables.
%?Initialize?the?population?種群初始化
chromosome?=?initialize_variables(pop);
%%?Sort?the?initialized?population
%?Sort?the?population?using?non-domination-sort.?This?returns?two?columns
%?for?each?individual?which?are?the?rank?and?the?crowding?distance
%?corresponding?to?their?position?in?the?front?they?belong.
chromosome?=?non_domination_sort_mod(chromosome);
%%?Start?the?evolution?process
%?The?following?are?performed?in?each?generation
%?Select?the?parents
%?Perfrom?crossover?and?Mutation?operator
%?Perform?Selection
fprintf(‘雜交的后代數(shù)—以10遞增輸出?\n‘);
for?i?=?1?:?gen
????%?Select?the?parents
????%?Parents?are?selected?for?reproduction?to?generate?offspring.?The
????%?original?NSGA-II?uses?a?binary?tournament?selection?based?on?the
????%?crowded-comparision?operator.?The?arguments?are
????%?pool?-?size?of?the?mating?pool.?It?is?common?to?have?this?to?be?half?the
????%????????population?size.
????%?tour?-?Tournament?size.?Original?NSGA-II?uses?a?binary?tournament
????%????????selection?but?to?see?the?effect?of?tournament?size?this?is?kept
????%????????arbitary?to?be?choosen?by?the?user.
????pool?=?round(pop/2);
????tour?=?2;
????%下面進(jìn)行二人錦標(biāo)賽配對(duì),新的群體規(guī)模是原來(lái)群體的一半
????parent_chromosome?=?tournament_selection(chromosomepooltour);
????%?Perfrom?crossover?and?Mutation?operator
????%?The?original?NSGA-II?algorithm?uses?Simulated?Binary?Crossover?(SBX)?and
????%?Polynomial?crossover.?Crossover?probability?pc?=?0.9?and?mutation
????%?probability?is?pm?=?1/n?where?n?is?the?number?of?decision?variables.
????%?Both?real-coded?GA?and?binary-coded?GA?are?implemented?in?the?original
????%?algorithm?while?in?this?program?only?the?real-coded?GA?is?considered.
????%?The?distribution?indeices?for?crossover?and?mutation?operators?as?mu?=?20
????%?and?mum?=?20?respectively.
????mu?=?20;
????mum?=?20;
????%?針對(duì)對(duì)象是上一步產(chǎn)生的新的個(gè)體parent_chromosome
????%對(duì)parent_chromosome?每次操作以較大的概率進(jìn)行交叉(產(chǎn)生兩個(gè)新的候選人),或者較小的概率變異(一個(gè)新的候選人)操作,這樣
????%就會(huì)產(chǎn)生較多的新個(gè)體
????offspring_chromosome?=?genetic_operator(parent_chromosomemumum);
????%?Intermediate?population
????%?Intermediate?population?is?the?combined?population?of?parents?and
????%?offsprings?of?the?current?generation.?The?population?size?is?almost
評(píng)論
共有 條評(píng)論