A pipe is set to be designed given the parameters shown in table 1. The aim is to find the cheapest design for a column that can support the load P without experiencing buckling stress. As shown in the parameters table, the pipes' diameter and thickness are limited to a range of dimensions.
The cost of the pipe is directly dependent on the weight and the diameter, shown in the equation on the left. The weight has a coefficient of 4=(c1) and the diameter has a coefficient of 2=(c2). This means that the diameter is going to be more important than the thickness when optimizing for cost.
The weight can be calculated using the equation shown on the left where it is dependent on both variables.
The momentum of inertia can be found given the equation on the left, where the equation is dependent on the diameter and the thickness.
The last equation depicts the buckling stress for the pipe given the parameters and variables. This equation unlike others is dependent heavily on the dimensions because of the moment of inertia equation being in the numerator.
This is a nonlinear constrained optimization problem. There is a constraint for the thickness and diameter of the pipe. The moment of inertia equation and stress equations are non-linear. There is also a constraint for the stress which needs to be met by using both of the equations.
Given the parameters I implemented a random search method for finding the suitable d and t. (code can be found at the bottom of page) The code randomly searches for the max given the bounds. By changing the number of points the solution can be found with better accuracy.
For the alternative approach,I used Matlabs built-in max function to find the max for d and t given the buckling parameter. The maximum found is plotted above along with the bounds for the smallest and largest d and t values.
Using these values I found the cost for each.
(i). $2.83 for min d and t
(ii). $13.95 for optimized d and t
(iii). $106 for max d and t
In Matlab, the meshgrid function is used to create grids of points in 3-dimensional space. This function takes three vectors as input, representing the coordinates of the points in the x, y, and z dimensions, respectively. The meshgrid function then returns three arrays, each containing the coordinates of a grid point in 3-dimensional space. I could not get my meshgrid to plot so I tried rewriting my code several times and had no luck.
-Define the objective function and the constraints
-Set the optimization options
-Set the initial starting point for the optimization
-Set the bounds (lower and upper) for the optimization variables
-Set the maximum number of iterations
-Initialize the best solution and its objective value
-Iterate until the maximum number of iterations is reached
-Evaluate the objective function and the constraints at the random point
-Check if the random point is feasible or change bounds
The graphical approach to solving nonlinear optimization problems involves plotting the objective function and the constraints on a graph and then visually identifying the optimal solution by examining the intersection of the objective function and the constraints. This approach can be effective when the problem is relatively simple and the objective function and constraints can be easily plotted on a graph. This approach can also help identify where the local extrema may be, this is crucial when deciding bounds.
However, the graphical approach can be limited in its ability to handle more complex nonlinear optimization problems, where the objective function and constraints may have multiple local mins or maxs, or where the problem may have a large number of variables. In these cases, the graphical approach may not be able to accurately identify the global optimum, leading to a potential error between the graphical solution and the true optimal solution.
%% problem 2
%parameters
d1 = 1;
d2 = 10;
t1 = .1;
t2 = 1;
nop= 1000; %number of points
d = linspace (d1,d1,nop);
t = linspace (t1,t2,nop);
E = 900000;
H = 275;
P = 2000;
%% handle functions and set up of variables for plot
[D,T] = meshgrid(d,t);
% set up meshgrid for values
I = @(d,t)(pi./8).*d.*t.*((d.^2) +(t.^2));
%for grid and for stress equation
x = I(D,T);
%define I as x for next equation
bstress = @(d,t)((pi.^2).* x .* E)./ ((H.^2).* d.* t);
%for grid
y = bstress(D,T);
% equation for stress (z equation)
w = @(d,t)pi.*d.*t.*H.*.0025;
%for grid
z = w(D,T);
%specific points for marker at d1,t1 and d2,t2
I1 = (pi/8)*d1*t1 * ((d1^2) + (t1^2));
I2 = (pi/8)*d2*t2 * ((d2^2) + (t2^2));
b1stress = ((pi^2) * E * I1)/ ((H^2) * d1 * t1);
b2stress = ((pi^2) * E * I2)/ ((H^2) * d2 * t2);
w1 = pi.*d1*t1*H.*.0025;
w2 = pi.*d2*t2*H.*.0025;
maxx = max(x);
maxy = max(y);
maxz = max(z);
%plot
figure;
hold all;
contour3(x,y,z,'ShowText','on')
plot3(I1,b1stress,w1,'k*','MarkerSize',5,'LineWidth',2,'Color','r');
plot3(I2,b2stress,w2,'k*','MarkerSize',5,'LineWidth',2,'Color','r');
plot3(maxx,maxy,maxz,'k*','MarkerSize',5,'LineWidth',2,'Color','g');
xlabel('x')
ylabel('y')
The surf function did not represent the values properly so the conto
% parameters for equation and bounds
x1 = 1;
x2 = 10;
y1 = .1;
y2 = 1;
nop= 100; %number of points
x = linspace (x1,x1,nop);
y = linspace (y1,y2,nop);
E = 900000;
H = 275;
P = 2000;
fun = @(x,y)(pi./8).*x.*y.*((x.^2) +(y.^2)); % equation used
%parameter for max's
maxiter = 1e5; %maximum number of iterations
maxf = 0; % store the maximum value of the function
maxx = 0; % store the value of x that corresponds to function max.
maxy = 0; % store the value of y that corresponds to function max.
% select upper and lower bounds for x and y
xl = 1;
xu = 10;
yl = .1;
yu = 1;
for i = 1:maxiter
rx = rand(1,1); % ranges from 0 to 1
ry = rand(1,1); % ranges from 0 to 1
x = xl + (xu - xl)*rx;
y = yl + (yu - yl)*ry;
f = fun(x,y);
if( f > maxf )
maxf = f;
maxx = x;
maxy = y;
end
end
% vectors of x and y for solving z - same as before- rewrote because the code stopped working
xg = 1:.01:10;
yg = .1:0.001:1;
% turn vectors into matrices that represent entire 2-D space
[X,Y] = meshgrid(xg,yg);
% evaluate Z = f(x,y)
Z = pi./8.*X*Y*((X.^2) +(Y.^2));