| 查看: 860 | 回复: 0 | |||
[求助]
机械结构尺寸优化
|
|
Matlab初学者求助,求大神帮忙看看。设计变量:x=[l1 l2 l3 l4 l5 l6 l7 l8 l9 theta1 theta2]=[x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11],有四个中间变量theta3,theta4,theta5,theta6,四个中间变量存在如下关系: x(2)+x(3).*sin(theta1)+x(4).*sin(theta3)+x(5).*sin(theta6)=0 x(3).*cos(theta1)+x(4).*cos(theta3)-x(5).*cos(theta6)=0 -x(1)+x(9).*cos(theta2)+x(8).*cos(theta4)-x(3).*cos(theta1)-(x(4)+x(6)).*cos(theta3)-x(7).*cos(theta5)=0 x(9).*sin(theta2)+x(8).*sin(theta4)-x(3).*sin(theta1)-(x(4)+x(6)).*sin(theta3)-x(7).*sin(theta5)=0 设计变量初值:x0=[150 80 30 90 70 170 150 250 30 30 150] 上、下限:lb=[100 50 30 30 30 10 50 100 30 0 0]; ub=[250 200 150 250 250 250 350 350 150 360 360]; 优化的时候,总是出现问题:Error in lgjg_gjyh_mb (line 17) m1=x(2)+x(3).*sin(theta1)+x(4).*sin(theta3)+x(5).*sin(theta6); Error in fmincon (line 631) initVals.f = feval(funfcn{3},X,varargin{:}); Error in main_function (line 15) x=fmincon('lgjg_gjyh_mb',x0,[],[],[],[],lb,ub,'lgjg_gjyh_ys',opti);求大神帮忙看看是怎么回事啊! 以下是我的程序 主程序 %设计变量初值 x0=[150 80 30 90 70 170 150 250 30 30 150]; %设计变量的边界 lb=[100 50 30 30 30 10 50 100 30 0 0]; ub=[250 200 150 250 250 250 350 350 150 360 360]; %调用非线性优化函数 opti= optimset('Display','iter'); x=fmincon('lgjg_gjyh_mb',x0,[],[],[],[],lb,ub,'lgjg_gjyh_ys',opti); 目标函数文件: function f=lgjg_gjyh_mb(x) global theta1 theta2 theta3 theta4 theta5 theta6 %曲柄输入角增量 Dtheta=[0 24 48 72 96 120 144 168 192 216 240 264 288 312 336 360]; %连杆上F点给定的坐标 Sx=[0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150]; Sz=[0.8706 7.1790 11.8170 15.1354 17.4278 18.9300 19.8207 20.2211 20.1950 19.7485 18.8306 17.3327 15.0889 11.8756 7.4121 1.3600]; Sy=Sz-400; %目标函数 hd=pi/180; theta1=x(10)+Dtheta; %曲柄输入角 theta2=x(11)-Dtheta; %曲柄输入角 m1=x(2)+x(3).*sin(theta1)+x(4).*sin(theta3)+x(5).*sin(theta6); m2=x(3).*cos(theta1)+x(4).*cos(theta3)-x(5).*cos(theta6); m3=-x(1)+x(9).*cos(theta2)+x(8).*cos(theta4)-x(3).*cos(theta1)-(x(4)+x(6)).*cos(theta3)-x(7).*cos(theta5); m4=x(9).*sin(theta2)+x(8).*sin(theta4)-x(3).*sin(theta1)-(x(4)+x(6)).*sin(theta3)-x(7).*sin(theta5); [theta3, theta4, theta5, theta6]=solve(m1,m2,m3,m4,'theta3,theta4,theta5,theta6'); Fx=-x(1)+x(9).*cos(theta2.*hd)+x(8).*cos(theta4.*hd); %F点实际x坐标 Fy=x(9).*sin(theta2.*hd)+x(8).*sin(theta4.*hd); %F点实际y坐标 f=sqrt(sum((Fx-Sx).^2+(Fy-Sy).^2)/16); %F点坐标偏差均方差 约束函数文件 function[g,ceq]=lgjg_gjyh_ys(x) %曲柄存在条件约束 g(1)=x(3)-x(2); g(2)=x(3)-x(4); g(3)=x(3)-x(5); g(4)=x(3)+x(2)-x(4)-x(5); g(5)=x(3)+x(4)-x(2)-x(5); g(6)=x(3)+x(5)-x(4)-x(2); %边界条件 g(7)=30-x(3);g(8)=x(3)-150; g(9)=30-x(9);g(10)=x(9)-150; g(11)=x(3)+x(9)-x(1); g(12)=50-x(2);g(13)=x(2)-200; g(14)=100-x(1);g(15)=x(1)-250; g(16)=100-x(8);g(17)=x(8)-350; g(18)=30-x(4);g(19)=x(4)-250; g(20)=30-x(5);g(21)=x(5)-250; g(22)=10-x(6);g(23)=x(6)-250; g(24)=50-x(7);g(25)=x(7)-350; g(26)=-x(10);g(27)=x(10)-360; g(28)=-x(11);g(29)=x(11)-360; ceq=[]; %没有非线性等式约束 |
» 猜你喜欢
金属检测用的光谱仪
已经有19人回复
26申博求助
已经有0人回复
工程热物理与能源利用论文润色/翻译怎么收费?
已经有275人回复
关于缓冲体系离子浓度的计算
已经有0人回复
关于离子浓度计算
已经有1人回复
sci投稿求助
已经有5人回复
解决渗碳体倾斜角度问题
已经有0人回复
2026英国女王大学机械学院电池储能CSC全奖博士招聘
已经有10人回复
2026英国女王大学机械学院电池储能CSC全奖博士招聘
已经有0人回复
华南农业大学蒋恩臣教授、许细薇教授团队招聘生物质领域博士、硕士
已经有1人回复













回复此楼