How to iterate fast through thousands of combinations?

12 views (last 30 days)
Hey,
I’m working at my master thesis and trying to figure out an optimizer in Matlab. I’m not new to Matlab but to optimizer and solver. Anyway I already solved some problems with fmincon.
For my actual problem I tried different ways but I got stuck now. So I hope you can help me a bit.
I have different materials, e.g. 400, and three arias where I can set them. At each area can be another material. Additional the thickness can be adjusted by a scalar factor, too (e.g. maximum of 5). I solved it by using 6 nested for loops. The first three iterate the thickness and the others the material type. For this example there would be 400^3*5^3 = 8 000 000 000 iterations and that takes a long time.
I want to find the best combination with the thinnest thickness. For that I have already a fun/fitness function giving back a value which is to minimise.
I tried already fmincon but you can’t set the input values to integers. So I tried ga but here it gets stuck in some local minima. Also the solution always changes because it starts at a random point. I guess, it doesn’t get a good solution, because the materials aren’t sorted or based on an equation. They have just random properties.
My question is now, is there a good solution to iterate fast through all the materials?
Thanks in advance
Cheers Toby

Accepted Answer

John D'Errico
John D'Errico on 11 Nov 2017
Nope. Sorry, but there is no magic here.
You have an optimization of a "function", an objective that essentially lives only on an integer set.
Worse, it sounds as if your variables are essentially an index into various materials with different physical properties. So this is not even something where a search can try to move in some direction.
No, fmincon will not work. GA is your best chance in the form of an optimization, but as you found, if your function is this arbitrary thing, it will depend on where GA starts, and GA will probably not perform well anyway.
So any tool must essentially test every combination, since there is no rhyme or reason to what will work. Just brute force evaluation of every possible combination. No, you don't need to write that in the form of a deeply nested for loop. You could do it far simpler by writing a simple function that would take an index list, and return the next set of indexes that follows. Like counting. Just increment the last index, until such time as it rolls over, so trivial to write. (As it turns out, this code is effectively already provided for you in MATLAB, it is called ind2sub.)
Again though, there is no magic, because your objective is some nasty thing with no good properties. At best, if you have the parallel processing toolbox, AND a computer with a large number of cores to do the work, you can set all of them running in parallel. Then listen as the system fan kicks on full blast to try to cool your computer.
  2 Comments
Toby
Toby on 11 Nov 2017
Edited: Toby on 12 Nov 2017
Thank you. I guessed it will be the answer but now I know.
I used already an index list for the material combinations but not for the nested loops. But I will, so I can use the parallel calculation. Thanks for this suggestion.
I'll try to use this as a model.
Cheers Toby
John D'Errico
John D'Errico on 12 Nov 2017
Good. This seems like a natural problem for parallel computation.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!