I have prepared code in matlab for genetic algorithm from toolbox for number of iteration (nit)
[x,fval,exitflag,output,population,score] = GAcode(nvars,lb,ub,InitialPopulationRange_Data,PopulationSize_Data,EliteCount_Data,CrossoverFraction_Data,MaxGenerations_Data,FunctionTolerance_Data,ConstraintTolerance_Data);
where at the end H1 and H2 gives function and variable value for all the iterations respectively. 'GAcode' is file generated from toolbox. The code works properly.
I am trying to use parallel computing for increasing speed. Firstly started parallel pool and in preferences defined number of workers as 8. In file 'GA code' i have given
options = optimoptions(options,'UseParallel', true);
While using, parfor for i=1:nit, following error is obtained "Unable to classify the variable 'H2' in the body of the parfor-loop." If i remove H2 code runs properly.
How can i obtain H1 and H2 value after each iteration with parallel computing ?
For current setup even when the "for" loop for number of iterations is removed and done for single iteration no speed improvement is observed in parallel computing applying above options rather with parallel it is 63 sec and without it is 58 sec. The results are ok. What am i doing wrong ?
Thanks for your help.