資源描述:
《雙層規(guī)劃模型的遺傳算法求解的matlab源碼》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、雙層規(guī)劃模型的遺傳算法求解的Matlab源碼雙層規(guī)劃模型的遺傳算法求解的Matlab源碼function[BESTX,BESTY,ALLX,ALLY]=GAU(KU,KD,NU,ND,PmU,PmD,V,Q,R,m,t,p0,CF,Alpha,Beta,C0,Q0,h,a,b,d,Cr)%GreenSim團(tuán)隊(duì)原創(chuàng)作品,轉(zhuǎn)載請(qǐng)注明%Email:greensim@163.com%GreenSim團(tuán)隊(duì)主頁(yè):http://blog.sina.com.cn/greensim%[color=red]歡迎訪問GreenSim——算法仿真團(tuán)隊(duì)→[url=http://
2、blog.sina.com.cn/greensim]http://blog.sina.com.cn/greensim[/url][/color]%%輸入?yún)?shù)列表%KU??????上層迭代次數(shù)%KD??????下層迭代次數(shù)%NU??????上層種群規(guī)模,要求是偶數(shù)%ND??????下層種群規(guī)模,要求是偶數(shù)%PmU?????上層變異概率%PmD?????下層變異概率%其余參數(shù)均為模型參數(shù)%%輸出參數(shù)列表%xbest???下層模型的最優(yōu)決策變量%BESTX???K×1細(xì)胞結(jié)構(gòu),每一個(gè)元素是M×1向量,記錄每一代的最優(yōu)個(gè)體%BESTY???K×1矩陣,記錄每一
3、代的最優(yōu)個(gè)體的評(píng)價(jià)函數(shù)值%ALLX????K×1細(xì)胞結(jié)構(gòu),每一個(gè)元素是M×N矩陣,記錄全部個(gè)體%ALLY????K×N矩陣,記錄全部個(gè)體的評(píng)價(jià)函數(shù)值%%第一步:種群初始化,確保滿足約束的初始化n=length(C0);%決策變量的個(gè)數(shù)%種群初始化,每一行是一個(gè)樣本farm=zeros(NU,n);fori=1:NU???Ta=randperm(n);???Tb=unidrnd(n-1)+1;???farm(i,sort(Ta(1:Tb)))=1;???GT=farm(i,:);???GT=JZU(GT,V,Q);???farm(i,:)=GT;end%
4、輸出變量初始化ALLX=cell(KU,1);%細(xì)胞結(jié)構(gòu),每一個(gè)元素是N×n矩陣,記錄每一代的個(gè)體ALLY=zeros(KU,NU);%K×N矩陣,記錄每一代評(píng)價(jià)函數(shù)值BESTX=cell(KU,1);%細(xì)胞結(jié)構(gòu),每一個(gè)元素是1×n向量,記錄每一代的最優(yōu)個(gè)體BESTY=zeros(KU,1);%K×1矩陣,記錄每一代的最優(yōu)個(gè)體的評(píng)價(jià)函數(shù)值k=1;%迭代計(jì)數(shù)器初始化%%第二步:迭代過程whilek<=KU%%以下是交叉過程???newfarm=zeros(2*NU,n);???Ser=randperm(NU);%兩兩隨機(jī)配對(duì)的配對(duì)表???AA=farm(
5、Ser(1),:);???BB=farm(Ser(2),:);???P0=unidrnd(n-1);???aa=[AA(1:P0),BB((P0+1):end)];%產(chǎn)生子代a???bb=[BB(1:P0),AA((P0+1):end)];%產(chǎn)生子代b???ifsum(aa)<2???????Ta=randperm(n);???????Tb=unidrnd(n-1)+1;???????aa=zeros(1,n);???????aa(1,sort(Ta(1:Tb)))=1;???end???ifsum(bb)<2???????Ta=randperm(n)
6、;???????Tb=unidrnd(n-1)+1;???????bb=zeros(1,n);???????bb(1,sort(Ta(1:Tb)))=1;???end???aa=JZU(aa,V,Q);???bb=JZU(bb,V,Q);???newfarm(2*NU-1,:)=aa;%加入子代種群???newfarm(2*NU,:)=bb;??????fori=1:(NU-1)???????AA=farm(Ser(i),:);???????BB=farm(Ser(i+1),:);???????P0=unidrnd(n-1);???????aa=[AA
7、(1:P0),BB((P0+1):end)];???????bb=[BB(1:P0),AA((P0+1):end)];???????ifsum(aa)<2???????????Ta=randperm(n);???????????Tb=unidrnd(n-1)+1;???????????aa=zeros(1,n);???????????aa(1,sort(Ta(1:Tb)))=1;???????end???????ifsum(bb)<2???????????Ta=randperm(n);???????????Tb=unidrnd(n-1)+1;?????
8、??????bb=zeros(1,n);???????????bb(1,sort(Ta(1:T