Code covered by the BSD License  

Highlights from
Speeding Up Optimization Problems with Parallel Computing

image thumbnail

Speeding Up Optimization Problems with Parallel Computing

by

Stuart Kozola (view profile)

 

Files from the webinar: Speeding up optimization problems with parallel computing

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

mutationNcK(parents,options,GenomeLength,FitnessFcn,state,thisScore,thisPopulation)
function mutationChildren = mutationNcK(parents,options,GenomeLength,FitnessFcn,state,thisScore,thisPopulation)
% Oren Rosen
% 4/1/2008
% Copyright 2008 The MathWorks, Inc.
%
% This function is used for the N-choose-K bit-string genetic algorithm.
% The mutation algorithm is written to work on a population of length N
% bitstrings, each with exactly K bits equal to one. The children that are
% produced are simply random permutations of the parents. Because of this,
% the "K bits equal to one" constraint is automatically satisfied.
%
% This implementation was a quick and intuitive way to structure this
% function. It is by no means optimized and the end user is encouraged to
% experiment with other methods.

mutationChildren = zeros(length(parents),GenomeLength);
numVars = length(thisPopulation(1,:));

for i=1:length(parents)
    % Each parent produces a child.
    child = thisPopulation(parents(i),:);
    % The child is a random permutation of the parent's bits.
    mutationChildren(i,:) = child( randperm(numVars) );
end

Contact us