優(yōu)化設(shè)計混合懲罰函數(shù)法程序_第1頁
優(yōu)化設(shè)計混合懲罰函數(shù)法程序_第2頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、源程序:packageHyBrid;publicclasshybridpublicstaticintcount=1;publicstaticdoublex=1,30;publicstaticdoubler=3,c=0.7,w1=0;publicstaticdoubledv=newdouble2;publicstaticdoublex1=newdouble2;publicdoublefunction(doublex1,doublex2)目標函數(shù)return120*xl+x2;publicdoubleg1(doublex1,doublex2)約束條件一doubleG1=-x1;returnG1;p

2、ublicdoubleg2(doublex1,doublex2)約束條件二doubleG2=-x2;returnG2;publicdoubleg3(doublex1,doublex2)約束條件三doubleG3=1-0.25*x2;returnG3;publicdoubleg4(doublex1,doublex2)約束條件四doubleG4=1-7*x1*x2/45;returnG4;publicdoubleg5(doublex1,doublex2)/約束條件五doubleG5=1-7*Math.pow(x1,3)*x2/45;returnG5;publicdoubleg6(doublex1,

3、doublex2)/約束條件六doubleG6=1-Math.pow(x2,2)*x1/320;returnG6;publicdoublefun(doublex,doubler)/構(gòu)建懲罰函數(shù)doubleFUN=0;doublef=function(x0,x1);doubleg10=g1(x0,x1);doubleg20=g2(x0,x1);doubleg30=g3(x0,x1);doubleg40=g4(x0,x1);doubleg50=g5(x0,x1);doubleg60=g6(x0,xl);/*判斷條件一的正負*/if(g100)FUN-=r/g10;elseFUN+=(1.0/r)*

4、Math.pow(g10,2);/*判斷條件二的正負*/if(g200)FUN-=r/g20;elseFUN+=(1.0/r)*Math.pow(g20,2);/*判斷條件三的正負*/if(g300)FUN-=r/g30;elseFUN+=(1/r)*Math.pow(g30,2);/*判斷條件四的正負*/if(g400)FUN-=r/g40;elseFUN+=(1/r)*Math.pow(g40,2);/*判斷條件五的正負*/if(g500)FUN-=r/g50;elseFUN+=(1/r)*Math.pow(g50,2);/*判斷條件六的正負*/if(g600)FUN-=r/g60;els

5、eFUN+=(1/r)*Math.pow(g60,2);returnf+FUN;publicdoublereflect(doublea,doublex3,doublexh)反射doubleresult1=newdouble2;resultl0=x30+a*(x30-xh0);resultll=x3l+a*(x3l-xhl);returnresultl;publicdoublestretch(doublec,doublex3,doublex4)延伸doubleresult2=newdouble2;result20=x30+c*(x40-x30);result21=x31+c*(x41-x31);

6、returnresult2;publicdoubleshrink(doubleb,doublex3,doublexh)收縮doubleresult3=newdouble2;result30=x30+b*(xh0-x30);result31=x31+b*(xh1-x31);returnresult3;publicvoidnarrow(doublex0,doublex1,doublex2,doublexe)縮小x00=0.5*(x00+xe0);x01=0.5*(x01+xe1);x10=0.5*(x10+xe0);x11=0.5*(x11+xe1);x20=0.5*(x20+xe0);x21=0

7、.5*(x21+xe1);publicdoublesimple(doublex)存放初始點doublea=1.12,eps=0.0001;初試步長、精度doubleresX=newdouble2;存放最小值點intmax=0,mid=0,min=0;doublefmax=-1000,fmin=1000,fmid=0;分別標記三個點中的好點、壞點、不壞不好點hybrids=newhybrid();doublenumber=newdouble72;number0=newdouble2;/number0存放起點xOnumber00=x0;number01=x1;number1=newdouble2;

8、/number1存放點xlnumber10=0.9659*a+number00;number11=0.2588*a+number01;number2=newdouble2;/number2存放點x2number20=0.2588*a+number00;number21=0.9659*a+number01;for(inti=0;ifmax)max=i;fmax=s.fun(numberi,r);elseif(s.fun(numberi,r)fmin)min=i;fmin=s.fun(numberi,r);for(intj=0;jeps|Math.abs(s.fun(number1,r)-s.fu

9、n(number3,r)eps|Math.abs(s.fun(number2,r)-s.fun(number3,r)eps)for(inti=0;ifmax)max=i;fmax=s.fun(numberi,r);elseif(s.fun(numberi,r)fmin)min=i;fmin=s.fun(numberi,r);for(intj=0;js.fun(numbermin,r)&s.fun(number4,r)s.fun(numbermid,r)numbermax0=number40;numbermax1=number41;fmax=s.fun(number4,r);elseif(s.f

10、un(number4,r)s.fun(numbermin,r)number5=s.stretch(2,number3,number4);if(s.fun(number5,r)=fmax)number6=s.shrink(0.5,number3,numbermax);if(s.fun(number6,r)fmax)s.narrow(number0,number1,number2,numbermin);elsenumbermax0=number60;numbermax1=number61;fmax=s.fun(number6,r);elseif(s.fun(number4,r)s.fun(numb

11、ermid,r)numbermax0=number40;numbermax1=number41;fmax=s.fun(number4,r);number6=s.shrink(0.5,number3,numbermax);if(s.fun(number6,r)fmax)s.narrow(number0,number1,number2,numbermin);elsenumbermax0=number60;numbermaxl=number6l;fmax=s.fun(number6,r);System.out.printf(第+count+次單純形優(yōu)化結(jié)果:x1=+%-5.4ft+x2=+%-5.4

12、ft+f(x1,x2)=+%-5.4ftnn,numbermin0,numbermin1,s.function(numbermin0,numbermin1);resXO=numberminO;resX1=numbermin1;returnresX;publicstaticvoidmain(Stringargs)hybridh=newhybrid();doublegetX=newdouble2;dow1=h.fun(x,r);for(inti=0;i=0.0001);System.out.printf(最后結(jié)果是:+x1=+%-5.4f+tx2=+%-5.4f+tf(x1x2)=+%-5.4f,

13、x0,x1,h.fun(x,r);程序運行結(jié)果:第初單純形優(yōu)化結(jié)果:盤1=06291x2=252石71f(xl,x2.)=100.7550第23次單純形優(yōu)化結(jié)果:蠱1=063Q6x2=252450f(xl,x2)=1009194第次單純形彳尤化結(jié)果:xl=06313x2=25.2787f(xl,x2)=1010344第曲灰單純形優(yōu)化結(jié)果:xl=06319X2-252254f(xl,x2)-=101l1石g第空初單純形優(yōu)化結(jié)果:xl=06324x2=25.2372f(xl,k2.)=101丘第27次單純形優(yōu)化結(jié)果:套1=06327x2=25f(xl,x2)=1012158第籾單純形彳尤化結(jié)果:蠱1=06329x2=25f(xl,x2)=101.2414第決單純形優(yōu)化結(jié)果:xl=06331X2-252S37f(xl,k2)=1012574第3。初單純形優(yōu)化結(jié)果:盤1=

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論