(完整word版)优化设计Matlab编程作业

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

优化设计
无约束优化
min f(x)= 21x +22x -21x 2x -41x
初选x0=[1,1]
程序:
Step 1: Write an M-file objfun1.m.
function f1=objfun1(x)
f1=x(1)^2+2*x(2)^2-2*x(1)*x(2)-4*x(1);
Step 2: Invoke one of the unconstrained optimization routines
x0=[1,1];
>> options = optimset('LargeScale','off');
>> [x,fval,exitflag,output] = fminunc(@objfun1,x0,options)
运行结果:
x =
4.0000 2.0000
fval =
-8.0000
exitflag =
1
output =
iterations: 3
funcCount: 12
stepsize: 1
firstorderopt: 2.3842e-007
algorithm: 'medium-scale: Quasi-Newton line search'
message: [1x85 char]
非线性有约束优化
1. Min f(x)=321x +2
2x +21x -32x +5
Subject to: 1g (x)=1x +2x +18≤0
2g (x)=51x -32x -25≤0
3g (x)=131x -412
2x 0≤
4g (x)=14≤1x 130≤
5g (x)=2≤2x 57≤
初选x0=[10,10]
Step 1: Write an M-file objfun2.m
function f2=objfun2(x)
f2=3*x(1)^2+x(2)^2+2*x(1)-3*x(2)+5;
Step 2: Write an M-file confun1.m for the constraints.
function [c,ceq]=confun1(x)
% Nonlinear inequality constraints
c=[x(1)+x(2)+18;
5*x(1)-3*x(2)-25;
13*x(1)-41*x(2)^2;
14-x(1);
x(1)-130;
2-x(2);
x(2)-57];
% Nonlinear inequality constraints
ceq=[];
Step 3: Invoke constrained optimization routine
x0=[10,10]; % Make a starting guess at the solution
>> options = optimset('LargeScale','off');
>> [x, fval] = ...
fmincon(@objfun2,x0,[],[],[],[],[],[],@confun1,options)
运行结果:
x =
3.6755 -7.0744
fval =
124.1495
2. min f (x )=2
22154x x +
s.t. 0632)(211≤-+=x x x g
01)(212≥+=x x x g 初选x0=[1,1]
Step 1: Write an M-file objfun3.m
function f=objfun3(x)
f=4*x(1)^2+5*x(2)^2
Step 2: Write an M-file confun3.m for the constraints.
function [c,ceq]=confun3(x)
%Nonlinear inequality constraints
c=[2*x(1)+3*x(2)-6;
-x(1)*x(2)-1];
% Nonlinear equality constraints
ceq[];
Step 3: Invoke constrained optimization routine
x0=[1,1];% Make a starting guess at the solution
>> options = optimset('LargeScale','off');
>> [x, fval] = ...
fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)
运行结果:
Optimization terminated: no feasible solution found. Magnitude of search
direction less than 2*options.TolX but constraints are not satisfied.
x =
1 1
fval =
-13
实例:螺栓连接的优化设计
图示为一压气机气缸与缸盖连接的示意图。

已知D1=400mm,D2=240mm ,缸内工作压力p=8.5Mpa ,螺栓材料为45Cr ,抗拉强度Mpa 1000b =σ,屈服强度Mpa 320s =σ,拉压疲劳极限Mpa 3301-=σ,许用疲劳安全系数[7.1]S a =,取残余预紧力F F 6.1'
'=,采用铜皮石棉密封垫片,螺栓相对刚度8.0=c K 。

从安全、可靠、经济的角度来选择螺栓的个数n 和螺栓的直径d 。

解:
1. 目标函数
取螺栓组连接经济成本n C 最小为目标。

当螺栓的长度、材料和加工条件一定时,螺栓的总成本与n ,d 值成正比,故本问题优化设计的目标函数为 min 21)(x x nd C x f n ===
由此可见,设计变量为螺栓个数n 和直径d 为
n x [= 1[]x d T = T x ]2
2.约束条件
(1)强度约束条件:螺栓在脉动载荷下工作,因此螺栓组连接须满足疲劳强度条件
()()()[]a
a a S K K S ≥++-+=-min min 122σσψσψσσσσσ 其中a σ为应力幅值;min σ为最小应力;σK 为疲劳极限综合影响系数,取σK =4.4;σψ为应力折算系数,取σψ=0.23. 气缸最大载荷p D P 224
1π=
螺栓最大工作载荷n P F F +=,,0,210max 4
1d F πσ+ 螺栓最小工作载荷n p F F K F F /8.000,
-=-=σ, 21,
min 41D F πσ= 螺栓应力幅值2min
max σσσ-=a
对于普通螺纹,小径d d 85.01=,于是疲劳强度约束条件为
()[]01≤-=a a S S X g
(2)密封约束条件:考虑密封安全,螺栓间距应小于8d ,故密封约束条件为
()08400821
1
2≤-=-=x x d n D X g ππ (3)扳手工作空间约束条件:考虑扳手工作空间,螺距间距应大于2d ,故扳手工作空间约束条件为()0400221
213≤-=-
=x x n D d X g ππ (4)非约束条件 (),011≤-=x X g ()025≤-=x X g
螺栓连接的优化数学模型
综上所述,本问题的数学模型可表达如下
设计变量:[]T
x x x 21,= 目标函数:()21m in x x x f =
约束条件:()5,4,3,2,1,0..=≤u x g t s u
M 文件
function f=stud_obj(x)
f=x(1)*x(2);
global p Ksigam psai sigam_1
p=8.5*le6;
Ksigam=4.4;psai=0.23;sigam_1=330;D2=240;
p=1/4*pi*D2^2*le-6*p;
function [c,ceq]=stud_conl(x)
global p Ksigam psai sigam_1
p,x
F0=(1.6*p+p)/x(1);
d1=0.85*x(2);
A=1/4*pi*d1^2;
F1=F0-0.8*p/x(1);
sigma_max=F0/A;
sigma_min=F1/A;
sigma_1=(sigma_max-sigma_min)/2;
Sa=(2*sigma_1+(Ksigma-psai)*sigma_min)/((Ksigma+psai)*(2*sigma_a+sigm a_min));
c=[1.7-Sa;
400*pi/x(1)-8*x(2);
-400*pi/x(1)+2*x(2);
16-x(1);
-x(2)];
ceq=[];
x0=[7,20];
[x,feval]=fmincon(@stud_obj,x0,[],[],[],[],[],[],@stud_conl)
运行结果:
x =
16.00 28.84
fval =
461.39
根据实际问题的意义取整、标准化:n=16,d=30,经验证n和d的取值满足约束条件。

相关文档
最新文档