Suppose that I have this code in MATLAB:
% Predefined data
SX = [1, 2, 3, 4];
parfor xx = 1:4
naming2 = SX(xx);
[BestM, BestX{xx}, fina_M{xx}, final_D{xx}, BestAA{xx}, final_Data{xx}] = Optmz(naming2, v_data);
end
Optmz is an optimization algorithm. This optimization algorithm should run to optimize a regression model (with different output and optimized inputs-feature selection). As you know heuristic optimization algorithms are based on random numbers. We have different initial random numbers in every parlor loop? Is this a proper structure to decrease time of my application? I'm currently using for loop in above structure.
This is a part of printed output. Iterations are not sorted. Any problem? Based on above code we should have four iterations with same number. I need total different calculations in all 4 workers with different initial random number generator. For example, like the way we run our calculations in sequence without parallel computing. Run first one, second one, third one and finally fourth one.
******Iteration 24, Best Cost = 0.041201******
******Iteration 26, Best Cost = 0.034994******
******Iteration 26, Best Cost = 0.036624******
******Iteration 26, Best Cost = 0.039317******
******Iteration 25, Best Cost = 0.039584******
******Iteration 27, Best Cost = 0.034994******
******Iteration 27, Best Cost = 0.036624******
******Iteration 27, Best Cost = 0.039317******
******Iteration 28, Best Cost = 0.034994******
******Iteration 26, Best Cost = 0.039242******
******Iteration 28, Best Cost = 0.036624******
******Iteration 28, Best Cost = 0.03931******
******Iteration 29, Best Cost = 0.034994******
******Iteration 29, Best Cost = 0.036624******
******Iteration 27, Best Cost = 0.039048******
******Iteration 29, Best Cost = 0.03931******
******Iteration 30, Best Cost = 0.034994******
******Iteration 30, Best Cost = 0.036624******
******Iteration 28, Best Cost = 0.039048******
parforloops, the accessed indices are never guaranteed to be in order. Guaranteeing order and parallelization is usually an oxymoron. - rayryeng