📄 ex8_4.m
字号:
% Example 8.4:
% Chapter 8: Discrete Optimization
% Section 8.3.1
% Applied Optimization with MATLAB
% P.Venkataraman
% Published by John Wiley
%
% Exhaustive Enumeration
%
% Discrete optimization for I beam from stock list
%-------------------------------------------------------------
format compact
clear
% create the stock list of standard "S" and "W" beams
% list icludes only till depth of 12 inches
Ibeam = [3 2.33 .170 .260; ...
3 2.509 .349 .260; ...
4 2.663 .193 .293; ...
4 2.796 .326 .293; ...
5 3.004 .214 .326; ...
5 3.264 .494 .326; ...
6 3.332 .232 .359; ...
6 3.565 .465 .359; ...
7 3.662 .252 .392; ...
7 3.860 .450 .392; ...
8 4.001 .271 .425; ...
8 4.171 .441 .425; ...
10 4.661 .311 .491; ...
10 4.944 .594 .491; ...
12 5.000 .350 .544; ...
12 5.078 .428 .544; ...
12 5.252 .472 .659; ...
12 5.477 .687 .659; ...
4.16 4.069 .280 .345; ... % wide flange I beam
5.01 5.000 .240 .360; ...
5.15 5.030 .270 .430; ...
5.90 3.940 .170 .215; ...
6.03 4.000 .230 .280; ...
5.99 5.990 .230 .260; ...
6.28 4.030 .260 .405; ...
6.20 6.020 .260 .365; ...
6.38 6.080 .320 .455; ...
7.89 3.940 .170 .205; ...
7.99 4.000 .230 .255; ...
8.14 5.250 .230 .330; ...
8.25 8.070 .360 .560; ...
8.50 8.110 .400 .685; ...
8.75 8.220 .510 .810; ...
9.00 8.280 .570 .935; ...
9.87 3.960 .190 .210; ...
9.99 4.000 .230 .270; ...
10.11 4.010 .240 .330; ...
10.24 4.020 .260 .395; ...
10.47 5.810 .300 .510; ...
11.91 3.970 .200 .225; ...
11.99 3.990 .220 .265; ...
12.16 4.005 .235 .350];
[n1 n2] = size(Ibeam);
% create the corresponding Id number of the beams
IbeamStr = {'S3X5.7','S3X7.5','S4X7.7','S4X9.5','S5X10', ...
'S5X14.75','S6X12.5','S6X17.25','S7X15.3','S7X20', ...
'S8X18.4','S8X23','S10X25.4','S10X35.0','S12X31.8', ...
'S12X35.0','S12X40.8','S12X50', ...
'W4X13','W5X16','W5X19','W6X9','W6X12', ...
'W6X15','W6X16','W6X20','W6X25','W8X10', ...
'W8X13','W8X18','W8X40','W8X48','W8X58', ...
'W8X67','W10X12','W10X15','W10X17','W10X19','W10X30', ...
'W12X14','W12X16','W12X19'};
m1 = size(IbeamStr); % verifying number of entries
% start enumeration:
% common properties
L = 96; E = 29e06; rho = 0.284; FS = 1.4;
W = 2000*FS; sigy = 36e03; tauy = 21e03;
% initialize solution
fstar = inf;
xstar = [inf inf inf inf];
gstar = [inf inf inf];
istar = 1;
%
for i = 1:n1
x1 = Ibeam(i,1); x2 = Ibeam(i,2);
x3 = Ibeam(i,3); x4 = Ibeam(i,4);
area = 2*x2*x4 + x1*x3 - 2*x3*x4;
inertia = (x2*x1^3/12)- ((x2-x4)*(x1 - 2*x3)^3/12);
q = 0.5*x2*x4*(x1-x4) + 0.5*x3*(x1 -x4)^2;
f = rho*L*area;
g1 = W*L^3 -12*E*inertia;
g2 = W*L*x1 -8*inertia*sigy;
g3 = W*q - 2*inertia*x3*tauy;
if (g1 <= 0) & (g2 <= 0) & (g3 <= 0) & (f < fstar)
fstar = f;
gstar = [g1 g2 g3];
istar = i;
end
end
% Optimum Values
if ( istar > 1) & (istar <= n1)
% solution found
fprintf('\nSolution found\n')
fprintf('----------------\n')
str1 =char(IbeamStr(1,istar));
str = strcat('Optimum Beam is :',str1);
fprintf(str)
fprintf('\nMass of the Beam : %8.3f (lb)\n',fstar)
fprintf('Depth, Width, Web Thickness, Flange Thickness (inches)\n')
fprintf('%8.3f %8.3f %8.3f %8.3f\n',Ibeam(istar,:))
fprintf('Constraints: Deflection, Normal Stress, Shear Stress (<= 0)\n')
fprintf('%8.3f %8.3f %8.3f\n',gstar)
else
% no solution
fprintf('\nNo Solution found\n')
fprintf('--------------------\n')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -