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

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


2024年1月24日发(作者:)

凹内r

d X1州fci-r

©0⑥

3 hlu

FU-

卢f

F

F

♦ 忡下¥为+1 —

*— S-ll-« F41:Si —

■1**■

温不平?」11,・

—喜M -

〜FT文词一

化设计

hl4HU

MATLAB

oftiHMirjirCfiffliiiiJPHI

时y片 34ml3

*L9TR0i. Jill!-

LkftLgWf 1S1CSI

F

掰f 1 ■

>AAA»WI %

:k Dnfl w I ■ J k^lXM

prfaMk tjn nn Alflhw

无约束优化

X2

+

x 2-2

x 1

x 2-4

初选

x0=[1,1]

x 1

程序:

min f(x)=

Step 1: Write an

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 = 0Ptimset('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)=3

x:

+

x 2+2

x 1-3

x 2+5

Subject to:

g 2(x)=5

X1-3

X2

-25

<

0

g (x)=13

X -41

X 2

<

0

3

g

4(x)=14

<

X

1

<

130

1 2

g5

(x)=2

<

X 2

<

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 confunl.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)

=4x2 +

5x2

s.t.

g 1(x)

=

2X]

+

3x2

-

6

<

0

g (x)

=

x x +1

>

0

初选 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* but constraints are not satisfied.

x =

11

fval =

-13

实例:螺栓连接的优化设计

图示为一压气机气缸与缸盖连接的示意图。已知

D1=400mm,D2=240mm,缸内工作压力

p=8.5Mpa,螺栓材料为45Cr,抗拉强度。b

=

1000Mpa,屈服强度。$

=

320Mpa,拉压

疲劳极限。=330Mpa,许用疲劳安全系数[S ]

=

1.7,取残余预紧力F”=

1.6F,采用

-1 a

铜皮石棉密封垫片,螺栓相对刚度Kc

= 0.8。从安全、可靠、经济的角度来选择螺栓的个

数n和螺栓的直径d。

解:

1 .目标函数

取螺栓组连接经济成本Cn最小为目标。当螺栓的长度、材料和加工条件一定时,螺栓

的总成本与n,d值成正比,故本问题优化设计的目标函数为

min

f (x)

=

C = nd = x x

由此可见,设计变量为螺栓个数n和直径d为

x = [ n

d ]

T =

[ x x ]

T

2

.约束条件

(1)强度约束条件:螺栓在脉动载荷下工作,因此螺栓组连接须满足疲劳强度条件

[]

S 二才

W --

>

S 」

K +W

及6

+6

/

2o

+(K -w 4

1 --------- 6 ------ min

i a a

其中6

a为应力幅值;6

mi方最小应力;K6为疲劳极限综合影响系数,取K6 =4.4; W

6

为应力折算系数,取W6=0.23.

气缸最大载荷P

=

--D D2

p 4

2

P

螺栓最大工作载荷F =

F „ +- ,

o

+

0

F

-

n max

1

4

i

nd 2

min

螺栓应力幅——max ------- min

值。

螺栓最小工作载荷F =

F0-K

2

『二Fo

-

0.8p /n ,。对于普通螺纹,小径d =

0.85d,于是疲劳强度约束条件为

1

g

[(X )=S ]-

S < 0

(2)密封约束条件:考虑密封安全,螺栓间距应小于8d,故密封约束条件为

f )

nD 0 , 400n

o

g X )=———―

8d = 一

8x

2

n x

2

i

(3)扳手工作空间约束条件:考虑扳手工作空间,螺距间距应大于2d,故扳手工作空间约

束条件为g &)=

2d 一吗=2x 一料n<

0

3

n

2

x

i

(4)非约束条件

g(X)=一x <

0, g

(X )=一x <

0

螺栓连接的优化数学模型

综上所述,本问题的数学模型可表达如

设计变量:

目标函数:

x =

lx , x >

)s.t.g

(x<

0,u = 1,2,3,4,5

约束条件:

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*d1A2;

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的取值满足约束条件。


发布者:admin,转转请注明出处:http://www.yc00.com/web/1706055095a1437918.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信