So I'm trying to iterate over the list of partitions of something, say
`1:n` for some `n` between 13 and 21. The code that I ideally want to run
looks something like this:
valid_num = @parallel (+) for p in partitions(1:n)
int(is_valid(p))
end
println(valid_num)
This would use the `@parallel for` to map-reduce my problem. For example,
compare this to the example in the Julia documentation:
nheads = @parallel (+) for i=1:200000000
Int(rand(Bool))
end
However, if I try my adaptation of the loop, I get the following error:
ERROR: `getindex` has no method matching
getindex(::SetPartitions{UnitRange{Int64}}, ::Int64)
in anonymous at no file:1433
in anonymous at multi.jl:1279
in run_work_thunk at multi.jl:621
in run_work_thunk at multi.jl:630
in anonymous at task.jl:6
which I think is because you cannot call `p[3]` if `p=partitions(1:n)`,
which explains the getindex error.
I've tried using `pmap` to solve my problem, but because the number of
partitions can get really big, really quickly (there are more than 2.5
million partitions of `1:13`, and when I get to `1:21` things will be
huge), constructing such a large array becomes an issue. I left it running
over night and it still didn't finish.
Does anyone have any advice for how I can efficiently iterate over
partitions in parallel? I have access to a ~30 core computer and my task
seems easily parallelizable, so I would be really grateful if anyone knows
a good way to do this in Julia.
Thank you so much!