Setting a seed population from the Matlab interface

This commit is contained in:
Marcel Kronfeld
2011-03-28 15:13:56 +00:00
parent 3e7ef7a9e5
commit 0c6685fa67
5 changed files with 76 additions and 4 deletions

View File

@@ -0,0 +1,27 @@
function int=setSeedPopFit(int, seedData, seedDataFit)
% int=setSeedPopulation(int, seedData)
% Set the seed data for optimization. A 2-D array of doubles is expected
% which will be converted to the appropriate data type if necessary.
% The seed data must fit the problem dimension, while the population size
% will be adapted if necessary. If the seed data is an empty array, the
% seed population will be initialized randomly as by default.
% int: the interface instance
% seedData: 2-D array of dimension popSize x problemDim or [] to reset
% and use random initial population
if length(seedData)>1
%size(int.range,1)
%int.dataType
%int.dim
if size(seedData,2)~=int.dim
error(['Mismatching dimension: seed data should be of size popSize x problemDim. Current problemDim is ' num2str(int.dim)]);
end
if size(seedData,1)~=size(seedDataFit,1)
error('Mismatching dimension of fitness array: expecting equal no. lines in seedData and seedDataFit!');
end
int.seedPop=seedData;
int.seedPopFit=seedDataFit;
else
int.seedPop=[]; % reset it
int.seedPopFit=[];
end