优化设计实验报告无约束非线性规划问题)sin(1)(min 2235x ex x x x f x-+-++=fun='(x^5+x^3+x^2-1)/(exp(x^2)+sin(-x))'; ezplot(fun,[-2,2]);[xopt,fopt,exitflag,output]=fminbnd(fun,-2,2) 输出: xopt =0.2176 fopt =-1.1312 exitflag = 1output =iterations: 12funcCount: 13algorithm: 'golden section search, parabolic interpolation' message: [1x112 char]二维无约束非线性函数最优解)12424()(min 22122211++++=x x x x x e X f xfun='exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1)'; x0=[0,0];options=optimset('largescale','off','display','iter','tolx',1e-8,'tolfun',1e-8);[x,fval,exitflag,output,grad,hessian]=fminunc(fun,x0,options) f='exp(x)*(4*x^2+2*y^2+4*x*y+2*y+1)'; ezmesh(f);First-order Iteration Func-count f(x) Step-size optimality0 3 1 2 1 9 0.717044 0.125092 1.05 2 15 0.073904 10 1.28 3 21 0.000428524 0.430857 0.0746 4 24 0.000144084 1 0.0435 5 27 1.95236e-008 1 0.000487 6 30 6.63092e-010 1 9.82e-005 7 33 1.46436e-015 1 4.91e-008Local minimum possible.fminunc stopped because it cannot decrease the objective function along the current search direction.Computing finite-difference Hessian using user-supplied objective function. x =0.5000 -1.0000fval =1.4644e-015exitflag = 5output =iterations: 8funcCount: 36stepsize: 1firstorderopt: 4.9136e-008algorithm: 'medium-scale: Quasi-Newton line search'message: [1x364 char]grad =1.0e-007 *-0.4914-0.4914hessian =13.1946 6.59536.5953 6.5949多目标线性规划问题⎪⎪⎪⎪⎩⎪⎪⎪⎪⎨⎧≤+≤+-≤---≤--+=+++=4823120233030..23)(min 708090100)(max 4231432142243211x x x x x x x x t s x x x f x x x x x f 已知设计变量和分目标的初值x0=[20,10,30,0],分目标的初始值f0=[10000,40],分目标的权重w=[1,2e-4]。
编写函数:function [f]=fun_opt(x)f(1)=-(100*x(1)+90*x(2)+80*x(3)+70*x(4)); f(2)=3*x(2)+2*x(4); 输入:、 A=[-1 -1 0 0; 0 0 -1 -1; 3 0 2 0;0 3 0 2];b=[-30 -30 120 80]; Aeq=[];beq=[];lb=zeros(1,4);ub=[]; x0=[20,10,30,0]; f0=[10000,40];w=[1 2e-4];[xopt,fopt]=fgoalattain(@fun_opt,x0,f0,w,A,b,Aeq,beq,lb,ub) 输出:Active inequalities (to within options.TolCon = 1e-006): lower upper ineqlin ineqnonlin 4 1 1 3 2xopt =17.7035 12.2965 33.4447 0fopt =1.0e+003 *-5.5526 0.0369要求设计一个内燃机用气门弹簧,工作载荷F=680N,工作行程h=16.59mm ,工作频率f r =25Hz ,要求寿命N ≥106循环次数。
弹簧丝材料采用50CrV A ,许用应力[τ]=405MPa.如下图所示弹簧的结构要求:弹簧丝直径mm d mm 95.2≤≤,弹簧外径mm D mm 6030≤≤,工作圈数63≤≤n ,支承圈数n 2=1.8(采用YI 型端部结构),弹簧指数C ≥6,弹簧压并高度λb =1.1h=18.25mm 。
试在满足弹簧的强度条件、刚度条件、稳定性条件、旋绕比条件和结构尺寸边界条件等约束条件下,确定弹簧的弹簧丝直径d ,中径D 2和工作圈数n 等三个设计参数,使它重量最轻、自由高度最小和自振频率最高。
(弹簧钢的材料密度ρ=7.5*10-6kg/mm 3,循环次数N ≥103时弹簧的曲度系数K=1.6/C 0.14,重力加速度g=9.80665m/s 2)D D2tad1、确定设计变量⎪⎪⎪⎭⎫ ⎝⎛=⎪⎪⎪⎭⎫ ⎝⎛=n D d x x x x 23212、建立目标函数1)弹簧的结构重量最轻)8.1(10*8148.1)(322141+=-x x x x f2)弹簧的自由高度最小25.18)3.1()(312++=x x x f3)弹簧的自振频率最高(取倒数作为分目标函数,追求最小值)1322613/10*809.2)(x x x f x f r--==3、建立约束函数6)(03)(060)(030)(05.9)(05.2)(0)/(10*659.1680)(0)/(10*56.3250)(03.525.18)3.1()(0/6)(0405/10*7706.2)(31131021921817163224155322154213312286.2186.0231≤-=≤-=≤-+=≤--=≤-=≤-=≤-=≤-=≤-++=≤-=≤-=x x g x x g x x x g x x x g x x g x x g x x x x g x x x x g x x x x g x x x g x x x g编写M 函数如下:function [f]=TH_dmbyh_fTS(x,L,H); p=7.5e-6;gl=9.80665;f1=p*gl*pi^2*x(1)^2*x(2)*(x(3)+1.8)/4; f(1)=(f1-L(1))/(H(1)-L(1));f2=x(1)*(x(3)+1.3)+18.25; f(2)=(f2-L(2))/(H(2)-L(2));f3=2.809e-6*x(2)^2*x(3)/x(1); f(3)=(f3-L(3))/(H(3)-L(3));function [g,ceq]=TH_dmbyh_gTS(x,L,H);F=680;t=405;K=1.6;HD=5.3;fr=25;h=16.59;G=8e4; g(1)=8*K*F/pi*x(2)^0.86/x(1)^2.86-t; g(2)=6-x(2)/x(1);g(3)=(x(3)+1.3)*x(1)+18.25-HD*x(2); g(4)=10*fr-3.56e5*x(1)/x(2)^2/x(3); g(5)=F-h*G/8*x(1)^4/x(2)^3/x(3); ceq=[];输入参数如下: x0=[6.2;39;5]; lb=[2.5;27.5;3]; ub=[9;51;6]; a=zeros(6,3); a(1,1)=-1;a(2,1)= 1;a(3,1)=-1;a(3,2)=-1; a(4,1)= 1;a(4,2)= 1;a(5,3)=-1;a(6,3)= 1;b=[-2.5;9;-30;60;-3;6]';L=[0.9434 42.5514 1.709e-3];for i=1:4H=[11*L(1)-i*L(1) 11.5*L(2)-i*L(2) 13.5*L(3)-i*L(3)]; [x,fn]=fminimax('TH_dmbyh_fTS',x0,a,b,[],[],lb,ub,'TH_dmbyh_gTS', [],L,H);for j=1:3ff(j)=fn(j)*(H(j)-L(j))+L(j);endf1(i)=ff(1);f2(i)=ff(2);f3(i)=1./ff(3);enddisp ' ******** 圆柱螺旋弹簧多目标优化设计最优解 ********'fprintf (1,' d = %3.4f mm \n',x(1))fprintf (1,' D2 = %3.4f mm \n',x(2))fprintf (1,' n = %3.4f 圈 \n',x(3))fprintf (1,' W = %3.4f N \n',ff(1))fprintf (1,' H0 = %3.4f mm \n',ff(2))fprintf (1,' fr = %3.4f Hz \n',1/ff(3))g=TH_dmbyh_gTS(x,L,H);disp ' ######## 最优点的性能约束函数值 ########'fprintf (1,' g1* = %3.4f \n',g(1))fprintf (1,' g2* = %3.4f \n',g(2))fprintf (1,' g3* = %3.4f \n',g(3))fprintf (1,' g4* = %3.4f \n',g(4))fprintf (1,' g5* = %3.4f \n',g(5))disp ' ======== 最优点的边界约束函数值 ========'fprintf (1,' g6* = %3.4f \n',-b(1)-x(1))fprintf (1,' g7* = %3.4f \n',x(1)-b(2))fprintf (1,' g8* = %3.4f \n',-b(3)-x(2))fprintf (1,' g9* = %3.4f \n',x(2)-b(4))fprintf (1,' g10* = %3.4f \n',-b(5)-x(3))fprintf (1,' g11* = %3.4f \n',x(3)-b(6))输出结果:Active inequalities (to within options.TolCon = 1e-006):lower upper ineqlin ineqnonlin3 5 128******** 圆柱螺旋弹簧多目标优化设计最优解 ********d = 5.6515 mmD2 = 33.9089 mmn = 3.0000 圈W = 0.9434 NH0 = 42.5514 mmfr = 583.2604 Hz######## 最优点的性能约束函数值 ######## g1* = -0.0000g2* = 0.0000g3* = -137.1656g4* = -333.2627g5* = -766.8830======== 最优点的边界约束函数值 ========g6* = -3.1515g7* = -3.3485g8* = -3.9089g9* = -26.0911g10* = 0.0000g11* = -3.0000。