Given a bunch of nested for loops, I wish to find the best combination of values according to some metric, and I want to keep track of the best combination and the best result.
I gave an example (below) of how a very basic version of what I want would look like sequentially. However, I realize that this problem can be easily parallelized, especially if I can generate all combinations and then run the check function for each combination at the same time.
In my specific use case, the check function takes the majority of the time, so it is a clear bottleneck in my algorithm. My intuition is that if I were to create an array of tasks, I could run these tasks all at once and achieve a considerable speedup.
Given my requirements, how would I implement this in Julia? In Java, I know I could use something like ForkJoinPool and add a slew of tasks that way, but I am unsure of the Julia equivalent.
function check(parameters)
return value(parameters)
end
bestCheck = 0
bestParameters = []
for a in 1:30
for b in 1:50
for c in 1:90
temp = check(a,b,c)
if temp > bestCheck
bestCheck = temp
bestParameters = [a b c]
end
end
end
end
println(bestCheck)
println(bestParameters)