I have modeled a physical system with like 28 parameters. The simulation computes another list of about 10 output parameters. Now I need to explore the parameter space: some of the input parameters I keep constant, and some have several values. The input structure is like this:
input_params = {
'input1': [0.3], # fixed
'input2': [1.5, 4.5, 4], # variable param: [start, end, number_of_intermediate_values]
'input3': [1200.0], # fixed
'input4': [-0.1, -0.5, 10], # variable param: [start, end, number_of_intermediate_values]
'input5': [1e-3], # fixed
}
The output of the simulation program is like this (for a combination of inputs):
output_params = {
'output1': 3.9,
'output2': -2.5,
'output3': 100.0,
}
I would like to generate an n-dimensional array so that I can explore it afterwards with maximum flexibility. For the above example, it should be an array like this:
results = np.zeros(shape=(1,4,1,10,1,8))
where the first axis is for input1
(one value), the second axis for input2
(four values) and so on, and the last axis contains all the data [input1, input2, input3, input4, input5, output1, output2, output3]
(5 + 3 = 8 values). For this example it would be a 4 x 10 x 8 = 320 values array shaped as described.
My question is: How can I generate this structure, and then populate it (iterate over each axis) without writing 28 nested for
loops by hand?
Or maybe my data structures aren't right and there exists a better solution?
I am open to a solution using pandas (because I would like to be able to handle parameter names as strings). Or simple python dicts. Execution speed is not that important, since the bottleneck is the computing time of each simulation (it needs to reach a steady state) and I can afford spending a few milisecs between simulations.
I also need flexibility in how I choose which parameters are fixed and which are variable (and how many values they have).