程序:
funf='f=-1*(x(1)*sqrt(325^2-x(1)^2)+x(2)*(sqrt(325^2-x(2)^2)-sqrt(325^2-x(1)^2))+x(3)*(sqrt(325^2-x(3)^2)-sqrt(325^2-x(2)^2))+x(4)*(sqrt(325^2-x(4)^2)-sqrt(325^2-x(3)^2))+x(5)*(sqrt(325^2-x(5)^2)-sqrt(325^2-x(4)^2))+x(6)*(sqrt(325^2-x(6)^2)-sqrt(325^2-x(5)^2))+x(7)*(sqrt(325^2-x(7)^2)-sqrt(325^2-x(6)^2))+x(8)*(sqrt(325^2-x(8)^2)-sqrt(325^2-x(7)^2))+x(9)*(sqrt(325^2-x(9)^2)-sqrt(325^2-x(8)^2))+x(10)*(sqrt(325^2-x(10)^2)-sqrt(325^2-x(9)^2))+x(11)*(sqrt(325^2-x(11)^2)-sqrt(325^2-x(10)^2))+x(12)*(sqrt(325^2-x(12)^2)-sqrt(325^2-x(11)^2)));' ;% 最大铁芯柱柱截面面积函数
fung='g=[x(2)-x(1)+2.5;x(3)-x(2)+2.5;x(4)-x(3)+2.5;x(5)-x(4)+2.5;x(6)-x(5)+2.5;x(7)-x(6)+2.5;x(8)-x(7)+2.5;x(9)-x(8)+2.5;x(10)-x(9)+2.5;x(11)-x(10)+2.5;x(12)-x(11)+2.5];';%宽度逐级递减的约束条件
fun=[funf fung];
x0=[ 37.5 35 32.5 30 27.5 25 22.5 20 17.5 15 12.5 10]; %初始值
options=[];
vlb=[ 37.5 35 32.5 30 27.5 25 22.5 20 17.5 15 12.5 10]; %取值下限
vub=[322.5 320 317.5 315 312.5 310 307.5 305 302.5 300 297.5 295]; %取值上限
[x,options]=constr(fun,x0,options,vlb,vub);
y=zeros(1,12);
x=x.*2;
x=(round(x./5)).*5; %以5为倍数的宽度
for i=1:12
yy=sum(y',1);
y(i)=sqrt(650^2-x(i)^2)-yy;
end
y=round(y);
x
save 1-12x.txt x -ASCII -TABS
y
save 1-12y.txt y -ASCII -TABS
s=x.*y;
mj=sum(s',1);
mj
save 1-12mj.txt mj -ASCII -TABS
zhan=mj/((325^2)*pi);
zhan
save 1-12zhan.txt zhan -ASCII -TABS
结果输出:
> In C:\MATLAB6p5\toolbox\optim\constr.m at line 55
第二问程序
1)
MODEL:
DATA:
N=12;
d=650;
ENDDATA
SETS:
can/1..N/:x ,Y,T;
ENDSETS
@FOR(can:X^2+Y^2<0.25*d^2);
@FOR(can(I)|I#GT#1:X(I-1)>X(I););
@FOR(can(I)|I#GT#1:Y(I-1)<Y(I););
@FOR(can:T=X/2.5);
@FOR(can:@GIN(T));
Y(1)>13;
X(1)<325;
X(N)>20;
MAX=@SUM(can(I):X*Y)-@SUM(can(I)| I #GT# 1:X(I)*Y(I-1));
END
表 铁心柱多级阶梯形最优方案
直径D 1级宽 2级宽 3级宽 4级宽 5级宽 6级宽 7级宽 8级宽 9级宽 10级宽 11级宽 12级宽 13级宽 14级宽 S S 面积利用率
80 65 70 65 60 55 50 40 5027 4520 90%
110 105 100 95 85 75 60 40 9503 8796 93%
140 135 130 115 100 85 65 40 15394 14320 93%
170 165 150 130 115 95 70 40 22698 21144 93%
195 185 165 145 130 110 90 55 29865 27740 93%
200 195 158 170 155 135 115 95 70 40 31416 29936 95%
230 225 215 205 190 170 150 130 110 80 45 41548 39588 95%
265 260 250 235 195 185 150 125 90 55 55154 52564 95%
270 265 250 230 230 105 180 155 155 125 95 55 57256 54236 95%
330 325 315 300 285 285 260 230 200 165 125 75 85530 81456 95%
390 395 370 350 330 305 275 245 210 170 125 75 119459 114360 96%
400 395 385 370 350 350 335 300 275 245 215 195 150 110 65 125664 121104 96%
530 520 505 485 455 425 390 355 355 315 270 220 160 95 220618 211996 96%
740 650 630 605 580 540 505 505 470 450 385 340 280 205 120 430084 399728 93%
2)
model:
data
l=37.5,35,32.5,30,27.5,25,20;
d=80;
enddata
sets:
m/1..7/:w,l;
endsets
max=@sum(m(I):w(i)*l(i));
@for(m(i):4w(i)^2+4*@sum(m(i):d(i))*@sum(m(i):d(I))<=d^2+2*d*es+es^2);
es<=5;
end
第三问程序
1)
s1-a1*r*r-0.5*w1*h1=0;
s2-a2*r*r-0.5*w2*h2+s1=0;
s3-0.5*pi*r*r+s1+s2=0;
2*s1-s2=0;
s2-s3=0;
0.25*w1*w1+h1*h1-r*r=0;
0.25*w2*w2+h2*h2-r*r=0;
pi=3.1416;
r=325;
s1>0;
a1>0;
a2>0;
a1<0.5*pi;
a2<0.5*pi;
h1-w1* @TAN(a1)=0;
h2-w2* @TAN(a2)=0;
2)
程序:
1.求油道大致位置
eq1=sym('x2*y2*1/2+atan(y2/x2)*325^2=0.3*((325^2)*pi)/5');
eq2=sym('x1*y1*1/2+atan(y1/x1)*325^2=0.1*((325^2)*pi)/5');
eq3=sym('x1^2+y1^2=325^2');
eq4=sym('x2^2+y2^2=325^2');
[x1,y1,x2,y2]=solve(eq1,eq2,eq3,eq4)
2.最优化取数
funf='f=-1*(x(1)*sqrt(325^2-x(1)^2)+x(2)*(sqrt(325^2-x(2)^2)-sqrt(325^2-x(1)^2))+x(3)*(sqrt(325^2-x(3)^2)-sqrt(325^2-x(2)^2))+x(4)*(sqrt(325^2-x(4)^2)-sqrt(325^2-x(3)^2))+x(5)*(sqrt(325^2-x(5)^2)-sqrt(325^2-x(4)^2))+x(6)*(sqrt(325^2-x(6)^2)-sqrt(325^2-x(5)^2))+x(7)*(sqrt(325^2-x(7)^2)-sqrt(325^2-x(6)^2))+x(8)*(sqrt(325^2-x(8)^2)-sqrt(325^2-x(7)^2))+x(9)*(sqrt(325^2-x(9)^2)-sqrt(325^2-x(8)^2)));' ;% 最大铁芯柱柱截面面积函数
fung='g=[x(2)-x(1)+2.5;x(3)-x(2)+2.5;x(4)-x(3)+2.5;x(5)-x(4)+2.5;x(6)-x(5)+2.5;x(7)-x(6)+2.5;x(8)-x(7)+2.5;x(9)-x(8)+2.59];';%宽度逐级递减的约束条件
fun=[funf fung];
x0=[305 302.5 300 297.5 295 292.5 290 287.5 285]; %初始值
options=[];
vlb=[305 302.5 300 297.5 295 292.5 290 287.5 285]; %取值下限
vub=[320 317.5 315 312.5 310 307.5 305 302.5 300]; %取值上限
[x,options]=constr(fun,x0,options,vlb,vub);
y=zeros(1,9);
x=x.*2;
x=(round(x./5)).*5; %以5为倍数的宽度
for i=1:9
yy=sum(y',1);
y(i)=sqrt(650^2-x(i)^2)-yy;
end
y=round(y);
x
y
s=x.*(y-156);
mj=sum(s',1);
mj