Hey there,
I’m trying to write a script that creates dictionaries with simulation parameters.
I need these to eventually call
pmap(job_function, parameter_dicts)
where each worker gets its own parameter set and does its thing.
My question is how to elegantly create these dictionaries.
So far the only way I’ve been able to come up with is this:
# assign all parameters (optionally Vector of values)
param1 = [1,2]
param2 = 5
param3 = [4,5]
....
param20 = [10,12,15]
parameter_dicts = Dict[]
# Iterate over all possible parameter combinations
for param1 ∈ param1,
param2 ∈ param2,
param3 ∈ param3,
... ,
param20 ∈ param20
#Create dict with the parameters
d = Dict( :param1 => param1,
:param2 => param2,
:param3 => param3,
...
:param20 => param20)
push!(parameter_dicts, d)
end
which is obviously a very long and unreadable script.
Suggestions would be welcome!