"ga" calculates twice in the 1st generation when you did not set initial parameters, e.g. initialScoresMatrix.
"UseParallel = 1" cannot promise any faster calculation when you put huge amount of small-sized data.
You can confirm those behavior with following simple codes:
opts = optimoptions('ga');
opts.Display = 'iter';
opts.MaxGenerations = 10;
opts.PopulationSize = 5;
opts.UseParallel = 1;
opts.InitialScoresMatrix = [0.5, 0.5, 5, 0.5, 0.5];
[x,fval,exitflag,output,population,scores] = ga(@myFun, 3, , , , , , , , opts);
function y = myFun(x)
y = abs(x(1) + x(2) + x(3));
I am not sure your "the first generation of GA calculations after many hours" but if it takes too long time to startup your parallel pool, there might be a license issue. When you have several licenses in your MATLAB (local, network, home, student, etc.), sometimes MATLAB takes long long long time to findout the license which includes a parallel computing toolbox license. You can confirm your licenses in your machine with following command:
If there were unnecessary license files, please delete thoese files.