https://kotlinlang.org logo
#coroutines
Title
# coroutines
t

thomasnield

06/09/2018, 7:29 PM
Hey all, I got a fun challenge for purposes of data science and operations research problems. Is there a way to parallelize this binary tree traversing problem? I have tried to use coroutines but I frequently run into two problems: 1) Waiting for the entire search to complete 2) Memory issues for larger values of
treeRowCount
. Thoughts on an implementation?
v

voddan

06/10/2018, 6:37 AM
How do you get the values you are optimizing agains? Can I assume you have a (pure) function
(Node) -> Double
which calculates a value for each node on the fly and you are looking for a minimum ?
t

thomasnield

06/10/2018, 5:59 PM
@voddan it's a bit more of a shared state strategy where the current minimum is checked and accessed across each node iteration I got this problem fixed and running in a few seconds on a single thread. Turns out I didn't make my sort greedy, which was critical to reduce the search space quickly. I'll send you the code later if you're interested.
v

voddan

06/10/2018, 6:25 PM
Yes I am interested) Please send the code if it is not a big trouble
My concern was about where you get your input from. Normally each node has a value (weight), provided from outside the system. But here you explained that you don't keep the nodes in memory, so I was wondering how you get the weights to different threads
4 Views