I have written a script which is supposed to call the function at the bottom for each unique combination of values in the parameter vectors. That function is a simulation which I intend to run over all the unique combinations of those parameters. The simulation is run on a cluster, and the
sim_ind for each of these jobs is pulled from the environment.
Currently, my solution is to build a matrix with each row corresponding to a unique set of parameters. Then the
sim_ind value (passed from the environment) is used to determine which unique set of parameters will be used in that iteration by indexing the matrix.
The following is the code that I am using, which works:
% getting sim_ind from env AI = getenv('PBS_ARRAYID'); sim_ind = str2num(AI); time_slots = 40000; % parameter vectors up_down_ratio_arr = ; traffic_load_arr = [ 0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10, 100, Inf ]; blocked_modes_ind_arr = [1 2 3]; traffic_model_arr = [1 2]; % total number of unique combinations uniq = length(up_down_ratio_arr) * length(traffic_load_arr) * length(blocked_modes_ind_arr) * length(traffic_model_arr); parameters = zeros(uniq, 4); % propagating the parameter list matrix counter = 0; for i = up_down_ratio_arr for j = traffic_load_arr for k = blocked_modes_ind_arr for l = traffic_model_arr counter = counter + 1; parameters(counter, 1) = i; parameters(counter, 2) = j; parameters(counter, 3) = k; parameters(counter, 4) = l; end end end end % wrapping the sim_ind ind = mod(sim_ind, uniq); % mod maps all multiples of the largest index to zero if ind == 0 ind = uniq; end % retrieving a parameter set up_down_ratio = parameters(ind,1); traffic_load = parameters(ind,2); blocked_modes_ind = parameters(ind,3); traffic_model = parameters(ind,4); % call the routine MainCode_Single_Backahul_Cell_Sch(time_slots, up_down_ratio, traffic_load, blocked_modes_ind, traffic_model, ceil(sim_ind/uniq) );
Is there a better way?
I have a version in which I use
mod to map each value of the
sim_ind parameter to a value that exists in the range of each vector. The problem with this solution was that not all the combination were unique. For example, in the following code
traffic_load_arr is of size 10, and
traffic_model_arr is of size 2. Therefore, whenever the 8th element of
traffic_load_arr is selected; i.e.
mod(sim_ind, 10) == 8, then the 2nd element of
traffic_model_arr must also be selected. As a results, the parameter combination of
traffic_load == 10 and
traffic_model == 2 will never be formed.
I would appreciate for all code to be cross compatible with MATLAB and Octave.