californiaengineer.files.wordpress.com€¦  · web viewsince the main goal of the optimization...

15
Packaging Container Optimization

Upload: others

Post on 07-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Packaging Container Optimization

Paul HitchingsMay 7, 2017

ME 422 – Optimizaiton with MatLabProfessor Dr. Austin Park

Page 2: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

AbstractEngineers face design problems on a daily basis. Sometimes the question is a simple one, such as how much tension a cable can withstand, or how much compression a beam can tolerate. Other times, the design incorporates multiple variables each with their own constraints. For more complex designs, the use of computer programs is somewhat commonplace in the industry. Complex analyses can be performed and structures can be load tested before they are even built. To this end, many engineers and other design professionals use a tool called MATLAB. In essence, MATLAB is a program that allows programmers and engineers to perform very advanced calculations, often matrix based, in a very short amount of time. This might not seem like a big deal for a simple cable tension problem, but when there are dozens or hundreds of variables and matrix sizes reach 1000 by 1000, hand calculations become not only impractical but impossible. Matlab, in a manner of seconds, can perform complex calculations like finding the inverse or Eigenvalues of a matrix.

For this report, the design problem chosen was taken from the textbook and involves the optimization of a shipping container. If the object was simply to maximize volume, then a shape such as a cube would be an obvious choice. While a sphere has more volume per surface area, spheres are not a practical shape for a shipping container. The shipping container design problem detailed in the textbook on page 106 is a multivariable and non-linear problem with equality, inequality and side constraints. Using MATLAB, I will perform basic analysis on the problem to find the optimum solution given the design parameters.

Design Objective For this shipping container example 2.5, the goal is to reduce the total cost of construction, which is estimated as a function of the total surface area. The cost must be minimized while the other constrains are simulataneously met. Details of the design problem are outlined hereto.

Methodology of SolutionThis design problem will be tackled in three primary ways. First, a 3D graphical solution will be created, then a 2D contour plot will be drawn and ultimately a numerical solution will be achieved. The code used for this project is primarily found in the book, but minor modifications are made and will be detailed thusly. Before any code can be written, however, the problem must be put into standard format for MATLAB.

The original standard format is as follows;

Minimize f(a,b,c) = 2*cost/m2*(a*b+b*c+c*a)Subject to the following constraints:

Equality Constrainth1(a,b,c) = a*b*c = volumeInequality Constraintsg1(a,b,c) = 2*(a+b) ≤ Perimiter contsraintg2(a,b,c) = b-3*a ≤ 0g3(a,b,c) = c – (2/3)*b ≤ 0

Page 3: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Side Constraints0 ≤ a ≤ 0.50 ≤ b ≤ 0.5

To correctly input the above optimization problem into MATLAB and for ease of coding, the volume equality constraint was rewritten to be an inequality contraint as follows;

g(a,b,c) = volume - a*b*c ≤ 0

With this reorganization, MATLAB will find a volume that at a minimum, meets the constraint requirement. Since the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is slightly bigger than the minimum required.

For the purpose of demonstrating that the MATLAB code can be used with different parameter values and constraints, I adjusted the parameters as follows;

Cost per m2 = $2.00Minimum volume = 0.05 m3

Perimeter constraint = 2m0 ≤ a ≤ 1m0 ≤ b ≤ 1m0 ≤ c ≤ 5m

In the case of the c value, while the textbook problem did not detail an upper limit on c, or the height, it seemed nonetheless sensible to not have a height that was astronomically large. As it stands, 5m is probably too large for the upper limit on the height, but fortunately the optimization solution did find the height to be unreasonable. The optimization problem, with the adjusted parameters and new inequality constraint is detailed below in standard format;

Minimize f(a,b,c) = 2*2*(a*b+b*c+c*a)Subject to the following constraints:

Inequality Constraintsg1(a,b,c) = 0.5 - a*b*c ≤ 0g2(a,b,c) = 2*(a+b) ≤ 2g3(a,b,c) = b-3*a ≤ 0g4(a,b,c) = c – (2/3)*b ≤ 0

Side Constraints0 ≤ a ≤ 1m0 ≤ b ≤ 1m0 ≤ c ≤ 5m

Now that the standard format has been found, it can be input into the 3D graphical code, the 2D contour plot code and the numerical solution code.

Page 4: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Results and AnalysesBefore proceeding, it should be noted that instead of using the variable names a,b and c, the variable sets (x,y,z) (X,Y,Z) and (x1, x2 and x3) were used. There is no difference between the three sets of variables as far as MATLAB is concerned. It should also be noted that before the parameters were customized, each set of code (3D, 2D, numerical) was run using the original parameters to ensure that the solution found via the code indeed matched the solution provided in the textbook. Since the code produced the correct results, the parameters were modified and the new optimal solution was found.

The first method used to analyze possible solutions was the 3D graphical solution, as detailed in the textbook on pages 108-112. The 3D grahpical solution code, as altered by the author, is included hereto as attachment “A”. Aside fromchanges to the parameters, the only changes made to the code were the colors of the inequality constraints, for ease of visibility.

The 3D code used initially produces the below figure;

Figure 1

The planes shown in green/blue, red/magenta and blue/black, represent the inequality constraints. The red/blue/green planes indicate the correct side of the plane that the solution will be found. The curved shapes, which are technically green but appear yellow, indicate the cost function, with the lower cost being associated with the curves to the left, which are nearer to the 0,0,0 vertex. Because of the challenge in seeing the solution area, the figure was rotated and other views are shown below.

Page 5: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Figure 2

Figure 3

Page 6: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Figure 4While each rotation does shed new light on the solution area, because of the number of curves drawn for the cost optimization function, it is difficult to pinpoint a narrow range of values. Given what is known about the figure, the solution must be inside the large triangular prism and will coincide with the curve of the minimized objective function. In reality, the above figures only show several values of z, each represented by their own curve. Numerically speaking, there are infinite cost function curves for each set of dimensions but of course, trying to show an infinite number of cost functions in 3D would create a very solid and difficult to decipher figure.

Since the optimum parameters can lie anywhere on the cost minimization function, to estimate a range of ideal parameter values based solely on the 3D representation is somewhat impractical.

For this reason, the 2D plot program detailed on pages 113 – 117 was used, the code for which is attached hereto as attachment “B”. The 2D code generates not just one set of contour plots, but multiple sets of contour plots based on increasing values of z (height, also c or x3).

Several figures are shown below, each detailing a separate z values. The three magenta lines in the plot represent the constraint functions, the light blue countour lines represent different values of the cost function for different parameters, while the dark blue line represent the solution to the cost function based on the side constraints. We begin with figure 5, which shows the objective cost function just crossing the triangle that represents all possible solutions at a container height of 0.22m. While the 2D graphical solution does present a much clearer region than the 3D plot, it is still nearly

Page 7: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

impossible to determine the exact value of the objective function. The countour line below the cost function is 1.5709 whereas the line above the cost function has a value of 2.0945. So how does one determine the value of the dark blue line? And if the blue line represents a range of values, how does the designer choose the exact location on the solution plot for the optimum parameter values? Perhaps looking at additional figures will shed light on the solution.

Figure 5 Figure 6

Figure 7 Figure 8

Page 8: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Figure 9 Figure 10

Figure 11 Figure 12

With each new plot generated, the cost function shifts from the upper right part of the plot to the lower left-hand side. As previously mentioned, finding the value of the cost function from the contour plots is not readily possible, though the values of the contour lines above and below the plot are visible. Looking at the above figures and the increasing z-values, it seems that the smaller values of z produce contour lines in the region with lower cost values.

Page 9: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

Figure 7 Figure 8

Beginning at figure 9, or z = 0.3m, the contour plots show that for z values increasing beyond 0.3m, the contour line values in the acceptable region increase. This would indicate that the optimum value of the height (z,c, or x3) is somewhere around 0.3m. But again, the solution is represented by a curve, so what point on the curve produces the lowest cost of production based on surface area? This question is best answered by performing numerical analysis, which follows.

To perform the numerical analysis using MATLAB, the function “fmincon” was used for ease of simplicity and for its ability to deal with multiple inequality constraints. To determine how to use the fmincon function, Mathworks documentation was used, which in the case of this function, was relatively simple to decipher. As part ofo the fmincon code, three scripts, or files, are created. The first, is a file that simply contains the objective function, included hereto as Attachment “C”. The second file includes all the ineqaulity constrains and is included hereto as Attachment “D”. The main part of the code, solves the optimization problem using the fmincon function and is included hereto as Attachment “E”. The results of the fmincon operation are included at the end of the lengthy command window, a copy of which is included in its entirety hereto as Attachment “F”.

The solution provided by numerical MATLAB analysis is as follows

a (depth) = 0.3634mb(width) = 0.4543mc(height) = 0.3029m

Total cost to build container = $1.6510Total volume of container = 0.050006554598m3

Page 10: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

ConclusionsAs previously mentioned, because the code was tested against the parameters provided in the book, we can be certain that the above parameters as chosen by MATLAB do represent the minimum cost given the constraints provided in the design problem. Beyond blind faith in the code, the designer must always look at the values and perform some “common sense” analysis. At first glance, the solution does seem sensible, all of the parameters are within the desired range, the cost is low and the minimum volume was achieved. If, for example, the height of the was 4m, with the base being under 0.5m on each side, the designer might need to analyze the code to ensure everything is being calculated correctly. Mathematics tells us that the most volume per surface area is found in a sphere, so it stands to reason that to reach a given volume with constraint on the surface area, a shape as close to a sphere as possible is desired. Since this design problem is modeling a box, it stands to reason that the dimensions of the box will mimic that of a cube. Indeed, each length of the container falls within the range of 0.3m to 0.45m. It is likely that given an absense of the other constraints, that MATLAB would have chosen a perfect cube to maximize volume while minimizing surface area. Taking the design problem one step further, if MATLAB was given the option to use a multi-sided figure, such as a dodecahedron, that MATLAB would continue increasing the numbers of faces until the shape resembled a sphere as closely as possible. That being said, this project focuses on the design of a cube, so other shapes that might be more efficient in terms of the design goals are not being analyzed.

This project analyzed the performance of three different methods for finding the optimal solution to a design problem, 3D mapping, 2D mapping and numerical solution using fmincon. Each method presented unique challenges, advantages and drawbacks. For simple design problems with no more than three variables, the 3D graphical solution does provide a novel presentation of the data. However, after the 3D figure is generated and viewed, it becomes readily apparent that finding the exact and optimal ranges of the desired parameters is challenging if not impossible. And to state the obvious, if the design problem has more than three design variables, the 3D graphical solution model becomes impossible. Because of the challenges associated with the 3D model, the 2D contour map method attempted next.

The 2D contour plot method provided much clearer numerical information in regards to possible parameter values, but again, determine the exact values of the design parameters remains challenging. The objective cost function shown in the dark bule lines, does not have an exact value detailed in the plots, so the designer must look at the values of the contour lines above and below the cost function to determine the approximate value. The other unique challenge with the 2D method is that the program produces a figure for each value of z, or height. This method becomes hugely impractical if an engineer needs to look at dozens or hundreds of figures just to get a rough idea of what range the parameters fall into. And as is the case with the 3D method, the 2D method works only with a limited number of dimensions being less than or equal to 3.

One advantage to both the 3D and 2D method is their applicability to both linear and non-linear programming challenges. So at a minimum, at least the practicing engineer is able to see a rough estimate of the design parameter region after mapping the solution ranges in both 3D and 2D. But as mentioned eariler, design problems do not always come in only 3 dimensions. As such, a numerical method was used next .

Page 11: californiaengineer.files.wordpress.com€¦  · Web viewSince the main goal of the optimization problem is to reduce total surface area, it is of little concern if the volume is

The numerical method using the fmincon function has a distinct number of advantages. Firstly, the amount of code required to find the solution is minimal compared to the code required for 3D and 2D methods. Another key convenience with the numerical solution is its ability to handle an infinite number of variables. Since the fmincon function method utilizes matrices (the main feature of MATLAB), the user can enter a matric of any size required. There is only a slight different in program run time between analyzing a 3x3 matrix vs. a 50x50 matrix. Of course, if the engineer is working on a 100x100 or 1000x1000 matrix, the computer will require several moments to compute the answer. Nevertheless, since both the 3D and 2D methods are completely incabale of handling anything beyond 3 dimensions, it stands to reason that using numerical solutions would be industry practice.

Beyond the multidimensional capabilities of the fmincon method, separating the objective function, constraint functions and the main program into three separate files, means that engineers can quickly make modifications to both the objective function and the constraint functions without having to edit the main code. This can save time and reduce the complexity of editing the code days/weeks/months after it has been originally created. Naturally, the main reason for using fmincon is its ablity to handle non-linear programming problems. But what if the engineer has a linear problem? It still can be advisable to use a method that can facilitate non-linear programming, because should the objective function develop from a linear into a non-linear problem, the engineer will not have to write an entire new set of programs, but can use the fmincon method with the new non-linear design problem. Using a non-linear method for a linear problem might be seen as overkill, but the fmincon code is so simple, there really is not any wasted productivity in preparing for a more complex design problem in the future.

References

1. Applied Optimization with MATLAB programming , Venkataraman P., John Wiley and Sons, Inc. 2009 Hoboken NJ

2.3.