優(yōu)化設(shè)計上機_第1頁
優(yōu)化設(shè)計上機_第2頁
優(yōu)化設(shè)計上機_第3頁
優(yōu)化設(shè)計上機_第4頁
優(yōu)化設(shè)計上機_第5頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、優(yōu)化設(shè)計上機一、無約束優(yōu)化問題例1:minim i?f=已工七4工:+ 4i工金 + 1)建立目標(biāo)函數(shù)M文件:%目標(biāo)函數(shù)mbfun.m function f = mbfun(x)f = exp(x(1)*(4*x(1)八2+2*x(2)八2 + 4*x(1)*x(2)+2*x(2)+1);運行:%優(yōu)化x0=0,0; options = optimset(LargeScale,off);x,fval,exitflag,output = fminunc(mbfun,x0,options)%運行結(jié)果Optimization terminated: relative infinitj-norm of

2、gradient less than options. TolFun.0. 5000-1. 0000fval =8304e-015E output =iterations funcCount st epsize first orderopt algorithm message73312.4568e-008? mediuni-scale: Quasi-Newton line search1, Optimization terminated: relative inf initynorm of gradient less than options. TolFun.(2)例1自己修改并調(diào)試運行:改為

3、:minimizef x = exi+x2 4x2 + x2 + 4x1x2 + 2x2 + 1建立目標(biāo)函數(shù)M文件:%目標(biāo)函數(shù)mbfun.mfunction f = mbfun(x)f = exp(x(1)+x(2)*(4*x(1)八2+x(2)八2 + 4*x(1)*x(2)+2*x(2)+1);運行:%優(yōu)化x0=0,0; options = optimset(LargeScale,off);x,fval,exitflag,output = fminunc(mbfun,x0,options)%運行結(jié)果Opt iiriizat ion t eririinated: relative inf i

4、ni t y-no rm of gradient less than options. ToIFwl.0000-3. 0000fval =-1.4715ezitflag =iterations fui_icCoui_Lt stepsize firstorderopt algor itmessageoutput = 93915.2899e-007? inediujTL-scale: Quasi-Nev.H: on line searcl_L? Optiinization terminated: relative infinity-noriTL of gradient less than opti

5、ons. ToIFuil. ?二、有約束優(yōu)化問題例1:(to within options. TolCon = le-006): ineqlin ineqnonlin12-9. 54741. 0474iniiiLLnize f(x) = e4.ic; + Srtg + 心儼金 +2知 + 1)subject to the constraints _覽_ 2 - -L5 弋儼2 -10建立目標(biāo)函數(shù)M文件:%目標(biāo)函數(shù)mbfun.m function f = mbfun(x)f = exp(x(1)*(4*x(1)八2+2*x(2)八2 + 4*x(1)*x(2)+2*x(2)+1);建立非線性約束

6、函數(shù)M文件:%非線性約束函數(shù)confun.m function c, ceq = confun (x)c = 1.5 + x(1)*x(2) - x(1) - x(2);-x(1)*x(2) - 10;ceq =;運行:%優(yōu)化x0 = -1,1;options = optimset(LargeScale,off);x, fval = fmincon(mbfun,x0,confun,options)%運行結(jié)果Optimization terminated: first-ouder optima.1 ity measure less than opt ions.ToLFun and masimum

7、 const r aint violat ion is less than opt ions. ToLCon.Active inequalitiesupperlowerfval =. 0236(2)例2自己修改并調(diào)試運行:修改約束條件為:X1X2+X1 - X2 1X1X2 -5建立目標(biāo)函數(shù)M文件:%目標(biāo)函數(shù)mbfun.m function f = mbfun(x)f = exp(x(1)*(4*x(1)八2+2*x(2)八2 + 4*x(1)*x(2)+2*x(2)+1);建立非線性約束函數(shù)M文件:%非線性約束函數(shù)confun.m function c, ceq = confun (x)c

8、= -1 + x(1)*x(2) - x(1) - x(2);-x(1)*x(2) -5;ceq =;運行:%優(yōu)化x0 = -1,1;options = optimset(LargeScale,off);x, fval = fmincon(mbfun,x0,confun,options)%運行結(jié)果Optimization terminated: Magnitude of directional derivative in search direction less than 2*options. TolFun and maKimuni constraint violation is less

9、than options. TolCon.Active inequalities (to within options. TolCon = le-006): lower upper ineqlin ineqnonlin21. 8199-2. 7475fval =-1.4629三、自選題目:有約束:已知某機床主軸懸臂梁受到的切削力F=15000N。主軸內(nèi)經(jīng)d=30mm。懸臂端許用撓度y =0.05mm。要求主軸兩支撐跨度:300mm l 650mm,外徑:60mm D 140mm,懸臂端 長度:90mm 0女 E(x4 d4)2即 9.07058擋 W -1 0 x4 3042300 x 650

10、60 x 14090 x3 150則總體模型為:f(X) = 0.7854(x1 + x3)(x; 900)S. t. 9.07058x2(x1+ x3) 1 0 x4 304 2300 x 65060 x 14090 x3 A=;b=;Aeq=;beq=; lb=300,60,90; ub=650,140,150; options=optimset(largescale,off,display,iter); x,fval=fmincon(mbfun,x0,A,b,Aeq,beq,lb,ub,confun,options) %運行結(jié)果maxDirectionalFirst-orderIterF

11、-countf (k) const raintSt ep-sizederivat iveoptimality Procedure048270261.851e+007Infeasible st art point19 1.75511e+006011.07e+0065.31e+005214 1.75511e+00601-0. 1244. 99e+004 Hessian modified twice319 1.75327e+00601-1. 84e+0034.99e+004 Hessian modified twice424 1.47657e+00601-2. 67e+0052.7e+004529

12、1.47657e+00601-0. 05024.63e+004 Hessian modified twice3ptimization terininated: Searchi directionless than 2*opt ions. TolXand maximum const raint violat ion is less than opt ions. TolCon.Active inequalities (to within options. TolCon = le-006):lowerupperineqlininequonlinJ300. 000075. 634590. 0000 f

13、val =1.4766e+006(1)無約束:已知梯形截面管道的參數(shù)是:底邊長。,高度為h,面積A=64516mm2,斜邊與底邊的 夾角為&管道內(nèi)液體的流速與管道截面的周長s的倒數(shù)成比例關(guān)系。試按照使流體流速最 大的要求確定該管道的參數(shù)。_ 0:解:(1)建立數(shù)學(xué)模型: 截面周長:s = c +-sin 9截面面積:A = ch + h2 cot 9 = 64516貝|J: c = 64516 hcot9h則:s=64516h-hcot9 +k = 64516 工+ ksin 9 h tan 9 sin 9取h、0為設(shè)計變量:X=x1, x2=h,0為使流體的速度最大,則管道截面周長最小即可。

14、(2)目標(biāo)函數(shù):2x1sinx264516 x1=x1tanx2(3)編程調(diào)試運行: 建立目標(biāo)函數(shù)M文件:%目標(biāo)函數(shù)mbfun.mfunction f=mbfun(x) a=64516;f=a/x(1)-x(1)/tan(x(2)*pi/180)+2*x(1)/sin(x(2)*pi/180);運行:x0=25,45; x,fval=fminunc(mbfun,x0)%運行結(jié)果Optimization terminat ed: relative infinity-norm of gradient less than options. TolFun. k =192. 995860. 0005fval =668.5656編制繪制目標(biāo)函數(shù)等值線和曲面的程序 xx1=linspace100,300,25;xx1=linspace(100,300,25); xx2=linspace(30,120,25); x1,x2=meshgrid(xx1,xx2); f1=64516./x1-x1./tan(x2火pi/180)+2*x1./sin(x2火pi/180); subplot(1,2,1); h=contour(x1,x2,f1);h=contour(x1,x2,f1);

溫馨提示

  • 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)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論