Skip to content
Snippets Groups Projects
Commit 4072d570 authored by Achilles Kappis's avatar Achilles Kappis
Browse files

Update selParents.m to use parfor when it is available

parent fa7d8fc3
No related branches found
No related tags found
1 merge request!11Minor update of some of the optimisation functions
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
% Author: Achilles Kappis % Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com % e-mail: axilleaz@protonmail.com
% %
% Date: 09/02/2024 (DD/MM/YYYY) % Date: 21/11/2024 (DD/MM/YYYY)
% %
% Copyright: MIT % Copyright: MIT
% -------------------------------------------------- % --------------------------------------------------
...@@ -188,7 +188,7 @@ function [parents, parentsVec] = selParents(selType, fitVals, pop, offsprPerc, n ...@@ -188,7 +188,7 @@ function [parents, parentsVec] = selParents(selType, fitVals, pop, offsprPerc, n
idx = randi(size(pop, 1), nOffspr, nParent); idx = randi(size(pop, 1), nOffspr, nParent);
% Put the parents into the array % Put the parents into the array
for ii = nParent:-1:1 parfor ii = 1:nParent
parents(:, :, ii) = pop(idx(:, ii), :); parents(:, :, ii) = pop(idx(:, ii), :);
end end
...@@ -214,7 +214,7 @@ function [parents, parentsVec] = selParents(selType, fitVals, pop, offsprPerc, n ...@@ -214,7 +214,7 @@ function [parents, parentsVec] = selParents(selType, fitVals, pop, offsprPerc, n
% Choose parents % Choose parents
% ==================================================== % ====================================================
% Do it for each offspring % Do it for each offspring
for offsprIdx = nOffspr:-1:1 parfor offsprIdx = 1:nOffspr
% Get parent indices based on their probability % Get parent indices based on their probability
parentIdx = pickValProb(1:size(pop, 1), fitVals, nParent); parentIdx = pickValProb(1:size(pop, 1), fitVals, nParent);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment