freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

動物集群運(yùn)動行為模型系列之五-資料下載頁

2025-05-23 18:29本頁面
  

【正文】 pbest 粒子以前搜索到的最優(yōu)值,最后一列包括這些值的適應(yīng)度w_max = 。 % w_max 權(quán)系數(shù)最大值w_min = 。v_max = 2。 % **最大速度,為粒子的范圍寬度c1 =2。 % 學(xué)習(xí)因子1c2 = 2。 % 學(xué)習(xí)因子2best_record = zeros(1,max_gen)。 % best_record記錄最好的粒子的適應(yīng)度。arr_present(:,end)=ini_fit(arr_present,pop_size,part_size)。pbest = arr_present。 %初始化各個(gè)粒子最優(yōu)值[best_value best_index] = min(arr_present(:,end))。 %初始化全局最優(yōu),即適應(yīng)度為全局最小的值,根據(jù)需要也可以選取為最大值gbest = arr_present(best_index,:)。x=[3::3]。y=[3::3]。z=@(x,y) 3*(1x).^2.*exp((x.^2) (y+1).^2) ... 10*(x/5 x.^3 y.^5).*exp(x.^2y.^2) ... 1/3*exp((x+1).^2 y.^2)。for i=1:max_gen grid on。 ezmesh(z) ,hold on, grid on,plot3(arr_present(:,1),arr_present(:,2),arr_present(:,3),39。*39。), text(,39。食物39。)。title(39。鳥群覓食39。)。hold off。drawnow F(i)=getframe。pause()。 w = w_max(w_maxw_min)*i/max_gen。 reset = 0。 % reset = 1時(shí)設(shè)置為粒子群過分收斂時(shí)將其打散,如果=1則不打散 if reset==1 bit = 1。 for k=1:part_size bit = bitamp。(range(arr_present(:,k)))。 end if bit==1 % bit=1時(shí)對粒子位置及速度進(jìn)行隨機(jī)重置 arr_present = ini_pos(pop_size,part_size)。 % present 當(dāng)前位置,隨機(jī)初始化 v = ini_v(pop_size,part_size)。 % 速度初始化 for k=1:pop_size arr_present(k,end) = fitness(arr_present(k,1:part_size))。 end warning(39。粒子過分集中!重新初始化……39。)。 % 給出信息 display(i)。 end end for j=1:pop_size v(j,:) = w.*v(j,:)+c1.*rand.*(pbest(j,1:part_size)arr_present(j,1:part_size))... +c2.*rand.*(gbest(1:part_size)arr_present(j,1:part_size))。 % 粒子速度更新 (a) c = find(abs(v))。 %**最大速度設(shè)置,粒子的范圍寬度 v(c) = sign(v(c))*。 %, arr_present(j,1:part_size) = arr_present(j,1:part_size)+v(j,1:part_size)。 % 粒子位置更新 (b) arr_present(j,end) = fitness(arr_present(j,1:part_size))。 if (arr_present(j,end)pbest(j,end))amp。(Region_in(arr_present(j,:),region)) % 根據(jù)條件更新pbest,如果是最小的值為小于號,相反則為大于號 pbest(j,:) = arr_present(j,:)。 end end [best best_index] = max(arr_present(:,end))。 % 如果是最小的值為min,相反則為max if bestgbest(end)amp。(Region_in(arr_present(best_index,:),region)) % 如果當(dāng)前最好的結(jié)果比以前的好,則更新最優(yōu)值gbest,如果是最小的值為小于號,相反則為大于號 gbest = arr_present(best_index,:)。 end best_record(i) = gbest(end)。 display(i)。endpso = gbest。display(gbest)。 function fit = fitness(present)fit=3*(1present(1)).^2.*exp((present(1).^2) (present(2)+1).^2) ... %**需要求極值的函數(shù),本例即peaks函數(shù) 10*(present(1)/5 present(1).^3 present(2).^5).*exp(present(1).^2present(2).^2) ... 1/3*exp((present(1)+1).^2 present(2).^2)。 function ini_present=ini_pos(pop_size,part_size)ini_present = 3*rand(pop_size,part_size+1)。 %初始化當(dāng)前粒子位置,使其隨機(jī)的分布在工作空間 %** 6即為自變量范圍 function ini_velocity=ini_v(pop_size,part_size)ini_velocity =3/2*(rand(pop_size,part_size))。 %初始化當(dāng)前粒子速度,使其隨機(jī)的分布在速度范圍內(nèi) function flag=Region_in(pos_present,region)[m n]=size(pos_present)。flag=1。for j=1:n1 flag=flagamp。(pos_present(1:j)=region(j,1))amp。(pos_present(1:j)=region(j,2))。end function arr_fitness=ini_fit(pos_present,pop_size,part_size)for k=1:pop_size arr_fitness(k,1) = fitness(pos_present(k,1:part_size))。 %計(jì)算原始種群的適應(yīng)度end26
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1