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

下載本文檔

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

文檔簡(jiǎn)介

1、源程序:packageHyBrid;publicclasshybridpublicstaticintcount=1;publicstaticdoublex=1,30;publicstaticdoubler=3,c=0.7,w1=0;publicstaticdoubledv=newdouble2;publicstaticdoublex1=newdouble2;publicdoublefunction(doublex1,doublex2)目標(biāo)函數(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);/*判斷條件一的正負(fù)*/if(g100)FUN-=r/g10;elseFUN+=(1.0/r)*

4、Math.pow(g10,2);/*判斷條件二的正負(fù)*/if(g200)FUN-=r/g20;elseFUN+=(1.0/r)*Math.pow(g20,2);/*判斷條件三的正負(fù)*/if(g300)FUN-=r/g30;elseFUN+=(1/r)*Math.pow(g30,2);/*判斷條件四的正負(fù)*/if(g400)FUN-=r/g40;elseFUN+=(1/r)*Math.pow(g40,2);/*判斷條件五的正負(fù)*/if(g500)FUN-=r/g50;elseFUN+=(1/r)*Math.pow(g50,2);/*判斷條件六的正負(fù)*/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)存放初始點(diǎn)doublea=1.12,eps=0.0001;初試步長(zhǎng)、精度doubleresX=newdouble2;存放最小值點(diǎn)intmax=0,mid=0,min=0;doublefmax=-1000,fmin=1000,fmid=0;分別標(biāo)記三個(gè)點(diǎn)中的好點(diǎn)、壞點(diǎn)、不壞不好點(diǎn)hybrids=newhybrid();doublenumber=newdouble72;number0=newdouble2;/number0存放起點(diǎn)xOnumber00=x0;number01=x1;number1=newdouble2;

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

評(píng)論

0/150

提交評(píng)論