Programming Logics FORUMS

Full Version: Bridge Design Optimizer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So here's a little background.
I'm making a program that optimizes the cost of a bridge in a bridge designing program, given the length, the compression it has to support, and the tension it has to support.
Each bar in the bridge (truss bridge design) has two variables you can edit (for the purposes of this program): size (x mm by x mm) and material.

With each size, each material gets stronger, but the strongest of the size before is weaker than the weakest of the current size. Ex: 120x120 M3 is weaker than 130x130 M1 (M3 being the strongest, M1 being weakest).

There are 32 somewhat arbitrary sizes which I already put into my program, and three materials that have been also.
I have also input the 96 values for each of the costs for each cross section of material (all combinations) possible.

What I have done so far:
My program will take in any number of members, given their length, compression force, and tensile force, and optimize them individually--that is, make each bar the lowest it can be. I have thoroughly tested this part of the program, and it is very successful. It will correctly output the type of material and size needed to minimize individual costs.

How it works:
I have a main class and a Member class. The Member class holds basic information:
-The size "number" (the sizes are held in an array in the main class, and the Members just hold the index)
-The needed compression strength
-The needed tensile strength
-The length
-The current material

The main class iterates through each member (all are stored in one array) with a basic for loop. Inside this loop, there is a while statement that checks if the bar will hold. If not, it makes it the next biggest material, or the next size and the weakest material.

I am very confident that this part of the program works.

What I need to do:
Optimize lowest cost. Now, it sounds like my program already does it, but here's the catch: each unique kind of bar (120x120 M1 and 120x120 M2 are different) costs an extra $1000. What I was originally going to do was to have the program iterate through every single possibility and calculate the cost, giving the lowest cost and the corresponding members. I soon realized that with an average of about 25 members, this would be (32 x 3)^25 possibilities, which would take years to compute. I have never really worked with a program that needs such a high efficiency as this one.

In addition, 25 "for" loops nested within each other wouldn't be practical, as the number of members can vary greatly.

So, I'm not asking for help in the form of code. I need someone to help me create an algorithm that would be able to test only a few reasonable possibilities, in addition to making a program that can work for a varying number of members. Don't worry about the specifics, I only need the concepts, as I have much experience coding. I guess I'm just having trouble solving this problem.

Thanks for your time! (even if you're not going to answer, you still read a lot of my rambling Tongue)

P.S.--Putting filters of "has to be higher than the lowest and lower than the highest" don't work, as this still leaves you with 25 nested "for" loops and a long, long time to wait.
Reference URL's