Setting a seed population from the Matlab interface
This commit is contained in:
parent
3e7ef7a9e5
commit
0c6685fa67
@ -59,6 +59,8 @@ int.optParamValues = [];
|
||||
int.hexMask=hex2dec('ffffffff');
|
||||
int.dataType=''; % to be set later!
|
||||
int.outputAllStatsFields=1;
|
||||
int.seedPop=[];
|
||||
int.seedPopFit=[];
|
||||
|
||||
if (isa(fhandle, 'function_handle'))
|
||||
int.f = fhandle;
|
||||
|
@ -1,11 +1,17 @@
|
||||
function desc = getDesc(int, ID)
|
||||
% Return the String description of an indicated optimizer
|
||||
% with member descriptions.
|
||||
% For an integer ID, return the String description of the indicated optimizer
|
||||
% with member descriptions. In case ID is of a different type, it is attempted
|
||||
% to retrieve a String description for that object directly.
|
||||
|
||||
import eva2.gui.BeanInspector;
|
||||
import eva2.server.modules.GOParameters;
|
||||
import eva2.OptimizerFactory;
|
||||
|
||||
params = OptimizerFactory.getParams(ID, int.mp);
|
||||
desc = BeanInspector.getDescription(params.getOptimizer, false);
|
||||
if isnumeric(ID)
|
||||
params = OptimizerFactory.getParams(ID, int.mp);
|
||||
desc = BeanInspector.getDescription(params.getOptimizer, false);
|
||||
else
|
||||
desc = BeanInspector.getDescription(ID, false);
|
||||
end
|
||||
|
||||
|
||||
|
@ -95,6 +95,11 @@ if ((nargin == 2) || (nargin == 3))
|
||||
error('invalid Display option, only off/final/notify/iter are recognized');
|
||||
end
|
||||
|
||||
if isempty(int.seedPop) % set the seed data
|
||||
int.mp.clearSeedPopulation;
|
||||
else
|
||||
int.mp.setSeedPopulation(int.seedPop, int.seedPopFit);
|
||||
end
|
||||
int=runEvalLoopJE(int, 1, optType, outputFilePrefix, -1, -1, -1);
|
||||
|
||||
else
|
||||
|
27
resources/MatlabInterface/@JEInterface/setSeedPopFit.m
Normal file
27
resources/MatlabInterface/@JEInterface/setSeedPopFit.m
Normal 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
|
32
resources/MatlabInterface/@JEInterface/setSeedPopulation.m
Normal file
32
resources/MatlabInterface/@JEInterface/setSeedPopulation.m
Normal file
@ -0,0 +1,32 @@
|
||||
function int=setSeedPopulation(int, seedData)
|
||||
% 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(seedData)
|
||||
%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
|
||||
|
||||
for i=1:size(seedData,1)
|
||||
if (isempty(int.args))
|
||||
fit(i,:) = feval(int.f, seedData(i,:));
|
||||
else
|
||||
fit(i,:) = feval(int.f, seedData(i,:), int.args);
|
||||
end
|
||||
end
|
||||
int=setSeedPopFit(int,seedData,fit);
|
||||
else
|
||||
int.seedPop=[]; % reset it
|
||||
int.seedPopFit=[];
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user