MATLAB: Finding the Minimum Cost

newbie

Hey everyone,
I have a problem to solve…
I have to find the dimensions of a cylindrical tank that holds a specific volume at the lowest cost. It consists of a cylinder with 2 plates at either end.
Parameters are:
tank volume = 0.8 m^3
tank thickness = 3 cm
tank material density = 8000 kg/m^3
max diameter = 1.5 m
max cylinder length = 2 m
material cost = 4.5 $/kg
welding cost = 20 $/m
I know how to calculate any specific volume of material from the radius and the length for the material cost.
I also know how to calculate all the weld lengths for that too.
What I need help with is how could I make an IF ELSE statement that generates all the possible values of the radius and length of the cylinder where the volume = 0.8m^3 so that I can then sub those values into my cost evaluation formula.
Any help is greatly appreciated even if just a link to something I should read, Im really stuck.

Best Answer

You can do it numerically if you want using an exhaustive brute force method (which is also pretty fast): I've left out some parts for you to do, but when I ran it I got this:
The lowest cost was $6523.24.
The best length was ------. (You run it to find out)
The best radius was ------.
Here's the code:
tank_volume = 0.8 %m^3
tank_thickness = 3 %cm
tank_material_density = 8000% kg/m^3
max_diameter = 1.5% m

max_cylinder_length = 2% m
material_cost = 4.5 %$/kg
welding_cost = 20 %$/m
lowestCost = inf;
for cylinderLength = 0.001 : 0.001 : 2
radius = sqrt(tank_volume / (pi * cylinderLength));
surfaceAreaTop = 2 * pi * radius^2;
surfaceAreaSide = ?????????;
surfaceArea = surfaceAreaTop * 2 + surfaceAreaSide;
tank_weight = ?????????; * tank_thickness/100;
totalCost = tank_weight * material_cost + welding_cost * cylinderLength;
if totalCost < lowestCost
% Save lowestCost, bestLength, bestRadius.
?????????;
end
end
fprintf('The lowest cost was $%.2f.\nThe best length was %.3f.\nThe best radius was %f.\n',...
lowestCost, bestLength, bestRadius);
Related Question