Finding minimum value of function of several variables?

1 次查看(过去 30 天)
Hi everybody. I have a code to find minimum value of function of several variable (Mr) as below:
% GIOI THIEU
% Chuong trinh tinh toan toi uu hoa mat cat dam ban BTCT
% Tac gia: Le Tuan Dung
% Bo mon Cong trinh - Co so Thai Nguyen - DHCNGTVT
%-------------------*************--------------------------
% PHAN1: THAM SO DAU VAO CUA BAI TOAN
% 1.1. Cac gia tri trong luong rieng:
% Trong luong rieng be tong dam va ban
gamabt=25; % Don vi: kN/m3
% Trong luong rieng lop phu
gamalp=22.5; % Don vi: kN/m3
% 1.2. Cuong do cua vat lieu
% Cuong do be tong dam (f'c)
fcdam=30; % Don vi: Mpa
% Cuong do be tong ban (f'c)
fcban=30; % Don vi: Mpa
% Cuong do cot thep DUL (dieu 5.9.3)
fpu=1860; % Cuong do keo dut (Mpa)
fpy=0.9*fpu; % Cuong do chay deo (Mpa)
fpe=0.8*fpy; % Cuong do huu hieu (sau khi tru toan bo mat mat US) (Mpa)
% Modun dan hoi cua thep DUL (dieu 5.4.4.2)
Eps=197000; % (Mpa)
% 1.3. Tham so mat cat ngang cau:
Bcau=12; % % Be rong MCN cau (m)
hbbien=0.1; % Chieu day ban lien ket ben ngoai (m)
hbtrong=0.21; % Chieu day ban len ket ben trong (m)
Sodam=12; % Cau co 12 dam chu
daylp=0.08; % Chieu day lop phu mat cau (m)
Aclc=0.231; % Dien tich chan lan can
mlc=0.04; % Khoi luong/chieu dai cua lan can (kg/m)
gtt=9.81; % Gia toc trong truong (m/s2)
Ldam=24; % Chieu dai dam (m)
agoi=0.35; % Dau dam cach goi cau (m)
% 1.4. Cac he so tinh toan mo men:
neta=0.95; % He so dieu chinh
gamatt1=1.25; % He so tai trong tinh tai giai doan 1
gamatt2=1.5; % He so tai trong tinh tai giai doan 2
gamall=1.75; % He so tai trong cua hoat tai
IM=0.25; % He so xung kich
phif=0.9; % He so suc khang uon
% He so quy quy khoi ung suat chu nhat:
if fcdam <= 28
beta1=0.85;
elseif 28<fcdam<56
beta1=0.85-0.05*(fcdam-28)/7;
else
beta1=0.65;
end
% 1.5. Tai trong Hoat tai:
Ptruck=[145 145 35]; % (kN)
Kctruck=4.3; % (m)
Ptandem=[110 110]; % (kN)
Kctandem=1.2; % (m)
qlan=9.3; % (kN/m)
% 1.6. Tham so kich thuoc cua mat cat ngang:
disp('MOI CAC BAN NHAP CAC THAM SO DAU BAI');
B1=input('Gia tri can duoi be rong B1(cm): ');
B2=input('Gia tri can tren be rong B2(cm): ');
bs1=input('Gia tri can duoi be rong suon bien bs1(cm): ');
bs2=input('Gia tri can tren be rong suon bien bs2(cm): ');
bsg1=input('Gia tri can duoi be rong suon giua bsg1(cm): ');
bsg2=input('Gia tri can tren be rong suon giua bsg2(cm): ');
H1=input('Gia tri can duoi chieu cao H1(cm): ');
H2=input('Gia tri can tren chieu cao H2(cm): ');
hnt1=input('Gia tri can duoi chieu cao nap tren hnt1(cm): ');
hnt2=input('Gia tri can tren chieu cao nap tren hnt2(cm): ');
hnd1=input('Gia tri can duoi chieu cao nap duoi hnd1(cm): ');
hnd2=input('Gia tri can tren chieu cao nap duoi hnd2(cm): ');
Bslk=input('Gia tri chieu rong ban be tong lien ket Bslk(cm): '); % Bslk= 1 (m)
hslk=input('Gia tri chieu day ban be tong lien ket hslk(cm): '); % hslk=0.1 (m)
ntao1=input('Gia tri can duoi cua so tao cap ntao1: ');
ntao2=input('Gia tri can tren cua so tao cap ntao2: ');
dtao=input('Nhap duong kinh cua mot tao thep DUL dtao(mm): ');
B=(B1:B2); % Be rong MCN (0,8 - 1,0 met)
bs=(bs1:bs2); % Be rong suon bien (0,1 - 0,2 met)
bsg=(bsg1:bsg2); % Be rong suon giua (0,1 - 0,2 met)
H=(H1:H2); % Chieu cao MCN (0,8 - 1,0 met)
hnt=(hnt1:hnt2); % Chieu day ban tren (0,1 - 0,2 met)
hnd=(hnd1:hnd2); % Chieu day ban duoi (0,15 - 0,25 met)
ntao=(ntao1:2:ntao2); % So tao cap DUL la so chan(30 - 40 tao cap)
% Kiem tra tham so nhap vao:
Ktra=[B1 B2 bs1 bs2 bsg1 bsg2 H1 H2 hnt1 hnt2 hnd1 hnd2 Bslk hslk ntao dtao];
V={'B1','B2','bs1','bs2','bsg1','bsg2','H1','H2','hnt1','hnt2','hnd1','hnd2','Bs','hs','ntao','dtao'};
if find(Ktra<0)>0
disp('GIA TRI NHAP PHAI LA SO DUONG');
end
for i=1:numel(Ktra)
if Ktra(i)<0
%Cach bieu dien ten bien so
fprintf('Nhap lai gia tri cua: %s \n',V{i});
end
end
% PHAN 2: TOI UU HOA MAT CAT
% 2.1. Xac dinh tai trong tinh tai:
% Trong luong phan ban lien ket:
qlk=(2*(hbbien+hbtrong)*Bcau/2)/(2*Sodam); % Don vi: kN/m
% Tai trong do trong luong lop phu mat cau
qlp=(Bcau*daylp*gamalp)/Sodam;
% Tai trong do trong luong phan lan can
qlc=Aclc*gamabt+mlc*gtt;
% 2.2. Xac dinh cac tai trong do hoat tai:
% Chieu dai nhip tinh toan
Ldamtt=Ldam-2*agoi;
% Gia tri tung do duong anh huong:
y1=Ldamtt/4;
y2=((Ldamtt/2-4.3)*y1)/(Ldamtt/2);
y3=((Ldamtt/2-8.6)*y1)/(Ldamtt/2);
y4=((Ldamtt/2-1.2)*y1)/(Ldamtt/2);
Mrmin=Inf;
imin=1;
jmin=1;
kmin=1;
zmin=1;
lmin=1;
mmin=1;
nmin=1;
for i=1:numel(B)
for j=1:numel(bs)
for k=1:numel(bsg)
for z=1:numel(H)
for l=1:numel(hnt)
for m=1:numel(hnd)
for n=1:numel(ntao)
% Be rong cua lo rong:
br=((B(i)-2*bs(j)-bsg(k))/2)*0.01; % (m)
% Chieu cao phan lo rong
hr=(H(z)-hnt(l)-hnd(m))*0.01; % (m)
% TINH TOÁN MAT CAT QUY DOI
% Chieu cao canh tren:
ht=hnt(l)*B(i)/B(i)*0.01; % (m)
% Chieu cao canh duoi:
hd=hnd(m)*B(i)/B(i)*0.01; % (m)
% Chieu cao phan suon dam:
hsd=H(z)*0.01-ht-hd; % (m)
% Be rong phan suon dam:
bsd=(2*bs(j)*0.01*hr+bsg(k)*0.01*hr)/hsd; % (m)
% Tai trong do trong luong ban than dam chu:
qdc=(B(i)*0.01*hd+bsd*hsd+B(i)*001*ht)*gamabt; % (kN/m)
% TINH TOAN GIA TRI MOMEN UON
% Momen uon do tinh tai:
Mttai=neta*(gamatt1*qdc*Ldamtt*Ldamtt/8+gamatt1*qlk*Ldamtt*Ldamtt/8+...
gamatt1*qlc*Ldamtt*Ldamtt/8+gamatt2*qlp*Ldamtt*Ldamtt/8);
% Tinh he so phan bo ngang dam giua:
K=2.5*power(Sodam,-0.2);
de=0;
e=1.04+de/7600;
gg1lan=K*power((B(i)*0.01)/(2.8*Ldamtt),0.5)*power(1,0.25); % He so pbn 1 lan dam giua
gg2lan=K*power(B(i)*10/7600,0.6)*power((B(i)*0.01)/Ldamtt,0.2)*power(1,006); % He so pbn 2 lan dam giua
% Tinh he so phan bo ngang dam bien:
gb1lan=0.2; % Tinh theo PP don bay
gb2lan=e*gg2lan;
glay=[gg1lan gg2lan gb1lan gb2lan];
% He so phan bo ngang de tinh toan:
gpbn=max(glay);
% Momen uon do xe tai thiet ke:
Mtruck=neta*gpbn*(1+IM)*gamall*(Ptruck(1)*y1+Ptruck(2)*y2+Ptruck(3)*y3); % kN.m
% Momen uon do xe 2 truc:
M2truc=neta*gpbn*(1+IM)*gamall*(Ptandem(1)*y1+Ptandem(2)*y4); % kN.m
Mxetk=[Mtruck M2truc]; % kN.m
% Momen uon do tai trong lan xe
Mlanxe=neta*gpbn*gamall*9.3*0.5*(1/4)*Ldamtt*Ldamtt; % kN.m
% Momen uon do hoat tai
Mhtai=max(Mxetk)+Mlanxe; % kN.m
% Momen uon su dung tinh toan
Mutt=Mttai+Mhtai;
% TINH TOAN DAC TRUNG HINH HOC MAT CAT QUY DOI
% Dien tich mat cat ngang:
Aqd=B(i)*0.01*hd+bsd*hsd+B(i)*0.01*ht; %(m2)
% Momen tinh cua mat cat so voi day mat cat:
Sqd=(1/2)*B(i)*0.01*hd*hd+(0.5*hsd+hd)*hsd*bsd+(H(z)*0.01-0.5*ht)*ht*B(i)*0.01; % (m3)
% K/cach tu trong tam cua tiet dien quy doi toi day
% mat cat:
yd=Sqd/Aqd; %(m)
% K/cach tu tho tren cung toi truc trung hoa:
yt=H(z)*0.01-yd; %(m)
% Momen quan tinh cua mat cat doi voi truc trung
% hoa:
Jqd=(B(i)*0.01*ht*ht*ht)/12+power((yt-0.5*ht),2)*ht*(B(i)*0.01)+bsd*power(hsd,3)/12+...
power((yt-ht-hsd/2),2)*hsd*bsd+(B(i)*0.01)*power(hd,3)/12+power((yd-0.5*hd),2)*hd*(B(i)*0.01);
% TINH TOAN DAC TRUNG HINH HOC MAT CAT LIEN HOP
% Modun dan hoi dam:
Edam=0.043*power(gamabt*100,1.5)*sqrt(fcdam); % Mpa
% Modun dan hoi dam:
Eban=0.043*power(gamabt*100,1.5)*sqrt(fcban); % Mpa
% He so quy doi tu be tong ban sang be tong dam:
n1=Eban/Edam;
% Dien tich mat cat ngang:
Alh=Aqd+n1*Bslk*0.01*hslk*0.01; %(m2)
% Mome tinh cua mat cat so voi day mat cat:
Slh=Sqd+n1*Bslk*0.01*hslk*0.01*(H(z)*0.01+0.5*hslk*0.01); % (m3)
% K/cach tu trong tam cua tiet dien lien hop toi
% day ban:
ydlh=Slh/Alh; % (m)
% K/cach tu tho tren cung toi truc trung hoa:
ytlh=H(z)*0.01+hslk*0.01-ydlh; % (m)
% Momen quan tinh cua mat cat lien hop:
Jlh=(B(i)*0.01)*power(ht,3)/12+power((ytlh-hslk*0.01-0.5*ht),2)*ht*(B(i)*0.01)...
+bsd*power(hsd,3)/12+power((ytlh-hslk*0.01-ht-0.5*hsd),2)*hsd*bsd+...
(B(i)*0.01)*power(hd,3)/12+power((ydlh-0.5*hd),2)*hd*(B(i)*0.01)+...
n1*(Bslk*0.01*power(hslk*0.01,3)/12+Bslk*0.01*hslk*0.01*power((ytlh-0.5*hslk*0.01),2)); % (m4)
% TINH TOAN DAC TRUNG HINH HOC MAT CAT CO COT THEP
% He so quy doi tu cot thep DUL sang be tong dam:
n2=Eps/Edam;
% Dien tich mat cat ngang:
Act=Alh+(n2-1)*pi*dtao*0.001*dtao*0.001*ntao(n)*(1/4); %(m2)
% K/cach tu tim hang cot thep ngoai cung toi tho
% duoi:
ctduoi=0.06; % (m)
% K/cach tim toi tim giua cac hang cot thep:
timct=0.045; % (m)
% K/cach tu trong tam cot thep toi day mat cat:
dpsduoi=ctduoi+timct/2; %(m)
% K/cach tu trong tam dien tich cot thep toi tho tren cung cua MC:
dps=H(z)*0.01+hslk*0.01-dpsduoi;
% Momen tinh cua mat cat so voi day mat cat:
Sct=Slh+(n2-1)*pi*dtao*0.001*dtao*0.001*ntao(n)*(1/4)*(H(z)*0.01+hslk*0.01-dps); % (m3)
% K/cach tu trong tam tiet dien lien hop toi day MC
ydct=Sct/Act; %(m)
% K/cach tu tho tren cung toi TTH:
ytct=H(z)*0.01+hslk*0.01-ydct; % (m)
% Momen quan tinh cua mat cat co cot thep:
Jct=(B(i)*0.01)*power(ht,3)/12+power((ytct-hslk*0.01-ht/2),2)*ht*(B(i)*0.01)+...
bsd*power(hsd,3)/12+power((ytct-hslk*0.01-ht-hsd/2),2)*hsd*bsd+...
(B(i)*0.01)*power(hd,3)/12+power((ydct-hd/2),2)*hd*B(i)*0.01+...
n1*(Bslk*0.01*power(hslk*0.01,3)/12+Bslk*0.01*hslk*0.01*power((ytct-(hslk*0.01)/2),2))+...
(n2-1)*pi*dtao*0.001*dtao*0.001*(1/4)*ntao(n)*power((ydct-dpsduoi),2); % (m4)
% XAC DINH SUC KHANG UON CUA MAT CAT NGANG
% Chieu cao khoi ung suat hinh chu nhat:
acn=beta1*ytct; %(m)
if ytct>(ht+hslk*0.01)
% Suc khang uon danh dinh:
Mn=pi*dtao*0.001*dtao*0.001*(1/4)*ntao(n)*fpe*1000*(dps-acn/2)+...
0.85*fcdam*1000*(B(i)*0.01-bsd)*ht*(acn/2-ht/2)+0.85*fcdam*1000*(Bslk*0.01-bsd)*hslk*0.01*(acn/2-(hslk*0.01)/2); % kN.m
else
Mn=pi*dtao*0.001*dtao*0.001/4*ntao(n)*fpe*1000*(dps-acn/2)+...
0.85*fcdam*1000*(Bslk*0.01-B(i)*0.01)*hslk*0.01*(acn/2-(hslk*0.01)/2); % kN.m
end
% Suc khang uon tinh toan:
Mr=phif*Mn; %kN.m
if (Mr<=Mrmin)&&(Mr>=Mutt)
Mrmin = Mr;
imin = i;
jmin = j;
kmin = k;
zmin = z;
lmin = l;
mmin = m;
nmin = n;
end
end
end
end
end
end
end
end
disp('DA CHAY XONG CHUONG TRINH');
if ytct>(ht+hslk*0.01)
disp('TRUC TRUNG HOA DI QUA SUON DAM');
else
disp('TRUC TRUNG HOA DI QUA BAN CANH TREN');
end
% CAC GIA TRI KICH THUOC MAT CAT NGANG VA SO TAO THEP TOI UU
disp(Mrmin);
disp(B(imin));
disp(bs(jmin));
disp(bsg(kmin));
disp(H(zmin));
disp(hnd(lmin));
disp(hnt(mmin));
disp(ntao(nmin));
And when program finished, it gives me:
Mrmin=Inf;
80
10
10
80
10
15
30
of cause they (above values) are lower bonds of values that i must enter in paragraph:
B1=input('Gia tri can duoi be rong B1(cm): ');
B2=input('Gia tri can tren be rong B2(cm): ');
bs1=input('Gia tri can duoi be rong suon bien bs1(cm): ');
bs2=input('Gia tri can tren be rong suon bien bs2(cm): ');
bsg1=input('Gia tri can duoi be rong suon giua bsg1(cm): ');
bsg2=input('Gia tri can tren be rong suon giua bsg2(cm): ');
H1=input('Gia tri can duoi chieu cao H1(cm): ');
H2=input('Gia tri can tren chieu cao H2(cm): ');
hnt1=input('Gia tri can duoi chieu cao nap tren hnt1(cm): ');
hnt2=input('Gia tri can tren chieu cao nap tren hnt2(cm): ');
hnd1=input('Gia tri can duoi chieu cao nap duoi hnd1(cm): ');
hnd2=input('Gia tri can tren chieu cao nap duoi hnd2(cm): ');
Bslk=input('Gia tri chieu rong ban be tong lien ket Bslk(cm): '); % Bslk= 1 (m)
hslk=input('Gia tri chieu day ban be tong lien ket hslk(cm): '); % hslk=0.1 (m)
ntao1=input('Gia tri can duoi cua so tao cap ntao1: ');
ntao2=input('Gia tri can tren cua so tao cap ntao2: ');
dtao=input('Nhap duong kinh cua mot tao thep DUL dtao(mm): ');
So, who can explanin to me why?
  1 个评论
Jan
Jan 2017-2-15
Why what? Why you have to enter the values or why they are the lower bounds? I do not understand the comments and have no idea, what's going on inside the code.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by