I have this original function that I want to switch to a multiprocessor:
def optimal(t0, tf, frequences, delay, ratio = 0): First = True # First for s in delay: delay = 0 # delay between signals, timelines = list() for i in range(len(frequences)): timelines.append(time_builder(frequences[i], t0+delay, tf)) delay += s trio_overlap = trio_combination(timelines, ratio) valid = True for items in trio_overlap.values(): if len(list(set(items))) == len(items): continue else: valid = False if not valid: continue overlap = duo_combination(timelines) optimal = ... depending of conditions return optimal
If valid = True after the test, it will calculate the optimization parameter named optim_param and try to minimize it. If it falls under a certain threshold, optim_param < 0.3 , I optim_param < 0.3 loop and take this value as my answer.
My problem is that as my model develops, complexity starts to grow, and it takes too long to compute single threads. I would like to handle the calculations in parallel. Since each process will have to compare the result with the value of s with the current optimal, I tried to implement a queue.
This is my first multiprocessing experience, and even if I think I'm on the right track, it seems to me that my code is dirty and incomplete. Can i get help?
Thanks: D
source share