Documentation of fitdistc
Global Index (all files) (short | long)
| Local contents
| Local Index (files in subdir) (short | long)
Function Synopsis
fitdistc(OBJ_F, VLUB, FitDistOpt, Dummy, P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15)
Help text
FITness DISTance Correlation computation
This function computes the fitness-distance correlation
of a given objective function or using saved data.
A fitness distance scatter plot is generated.
Syntax: fitdistc(OBJ_F, VLUB, FitDistOpt, Dummy, P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15)
Input parameters:
OBJ_F - String containing the name of the objective function
VLUB - (optional) Matrix containing boundaries of variables
of objective function
if VLUB is empty, feval(OBJ_F, [],1) is used to
determine the boundaries to use
if OBJ_F is empty, VLUB contains the full name of
a text data file containing objective values (first
column) and variables of corresponding individuals
(second - last column), each row corresponds to
objective value and variables of one individual
FitDistOpt- (optional) Vektor containing options of fitness
distance calculation
FitDistOpt(1): Number of variables (dimensions) to use
if omitted, number of variables is
determined from size of VLUB
FitDistOpt(2): 0: Use points generated by an evenly
spaced grid
1: Use randomly generated points
if number of variables (dimensions) is
greater than 6, randomly created points
are used
FitDistOpt(3): Maximal number of points to use
Dummy - not used at the moment
P1-P15 - Additional parameters directly forwarded to the objective
function
Output parameter:
no output parameter
Examples:
% Compute fdc of objfun1 using default parameters
>> fitdistc('objfun1')
% Compute fdc of objfun1 in 5 dimensions, use 10000 evenly spaced points
>> fitdistc('objfun1', [], [5, 0, 10000])
See also: geamain, resplot, compdiv
Cross-Reference Information
Listing of function fitdistc
% Author: Hartmut Pohlheim
% History: 26.03.97 file created
function fitdistc(OBJ_F, VLUB, FitDistOpt, Dummy, P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15)
% Set standard input parameters
FitDistOptStandard = [10, 1, 2000]; % FitDistNvar = 10, PointsRand = 1, NPointsAll = 16
% Check input parameters
if nargin < 1, help fitdistc; end
if isempty(OBJ_F), READFILE = 1; else READFILE = 0; end
if nargin < 2, VLUB = []; end
if nargin < 3, FitDistOpt = []; end
if isnan(FitDistOpt), FitDistOpt = []; end
if length(FitDistOpt) > length(FitDistOptStandard), error(' Too many parameter in FitDistOpt'); end
if READFILE == 0,
if isempty(VLUB), VLUB = feval(OBJ_F, [], 1);
elseif size(VLUB, 1) ~= 2, error('Size of boundaries matrix is wrong (should be two rows) !'); end
FitDistOptStandard(1) = size(VLUB, 2);
FitDistOptIntern = FitDistOptStandard; FitDistOptIntern(1:length(FitDistOpt)) = FitDistOpt;
FitDistNvar = FitDistOptIntern(1);
PointsRand = FitDistOptIntern(2);
NPointsAll = FitDistOptIntern(3);
if isnan(FitDistNvar), FitDistNvar = FitDistOptStandard(1);
elseif FitDistNvar < 1, error('Parameter for number of variables must be greater 0 !'); end
if isnan(PointsRand), PointsRand = FitDistOptStandard(2);
elseif ~any(PointsRand == [0, 1]), error('Parameter for PointsRand must be 0 or 1 !'); end
if isnan(NPointsAll), NPointsAll = FitDistOptStandard(3);
elseif NPointsAll <= 10, error('Use more points for fitness-distance calculation !'); end
% Set VLUB to correct size
SelIx = rem([1:FitDistNvar]-1, size(VLUB,2))+1;
VLUB = VLUB(:, SelIx);
elseif READFILE == 1,
if isempty(VLUB), error('Name of file with data is needed (parameter 2) !'); end
FileName = VLUB;
[Head, Data] = hdrload(FileName);
ObjV = Data(:,1);
Chrom = Data(:,2:size(Data,2));
Nvar = size(Chrom,2);
end
% Read data from file
if READFILE == 0,
Nvar = size(VLUB,2);
if Nvar > 6, PointsRand = 1; end
if PointsRand == 0,
% Create matrix with rastered test cases (values of variables)
% each row contains the values of one test case
NPointsGrid = max(3, floor(NPointsAll.^(1/Nvar)));
PointsGrid = linspace(VLUB(1,1), VLUB(2,1), NPointsGrid);
for irun = 1:Nvar-1,
PointsGrid2 = expandm(PointsGrid, [1, NPointsGrid]);
PointsDim = linspace(VLUB(1,irun+1), VLUB(2,irun+1), NPointsGrid);
PointsGrid = [PointsGrid2; repmat(PointsDim, [1, NPointsGrid.^irun])];
end
PointsAll = PointsGrid';
Noise = (VLUB(2,:)-VLUB(1,:))./NPointsGrid./5;
Noise = repmat(Noise, [size(PointsAll,1),1]) .* rand(size(PointsAll));
PointsAll = PointsAll + Noise;
elseif PointsRand == 1,
% Create matrix with randomly distributed test cases
% each row contains the values (of variables) of one test case
PointsRand = rand(NPointsAll, Nvar);
PointsRand = PointsRand .* repmat(VLUB(2,:)-VLUB(1,:), [NPointsAll, 1]);
PointsRand = PointsRand + repmat(VLUB(1,:), [NPointsAll, 1]);
PointsAll = PointsRand;
end
% Build string of objective function
genevalstr = ['ObjV = ' OBJ_F '(Chrom'];
if ~any(OBJ_F < 48),
% Add additional parameters
for i = 1:nargin-4, genevalstr = [genevalstr, ',P', int2str(i)]; end
genevalstr = [genevalstr, ');'];
end
% Compute objective values
Chrom = PointsAll; eval(genevalstr);
% Save data to text file
Data = [ObjV Chrom];
% save tefidi_1.txt Data -ascii -tabs
end
% Calculate best individual
[BestObjV, BestChromPos] = min(ObjV(:,1));
BestChrom = Chrom(BestChromPos, :);
% fitness-distance calculation
[fdccoeff, Fitnesses, Distances] = compdiv('fdc', ObjV(:,1), Chrom, BestChrom);
% look for figure, set name, paperposition, position and all standard settings
UserDataString = 'geatbx_fitdist_plot';
figfitdist = findobj('UserData', UserDataString);
if isempty(figfitdist), figfitdist = figure('UserData', UserDataString, 'NumberTitle', 'Off'); end
if isempty(OBJ_F), Name = VLUB; else Name = feval(OBJ_F, [], 2); end
FigName = sprintf('FitDist: %s %s (Points=%d)', Name, OBJ_F, size(Chrom,1));
set(figfitdist, 'Name', FigName);
% Set PaperPosition for saving of figure
PaperPos = [0.5, 2.5, 8, 7];
set(figfitdist, 'PaperPosition', PaperPos);
% Set all standard settings defined in plotstd
plotstd(figfitdist);
figure(figfitdist);
% Plot of fitness distance scatter plot
plot(Distances, Fitnesses, '.');
DiffDistances = 0.05 * (max(Distances) - min(Distances))*(1-eps);
DiffFitnesses = 0.05 * (max(Fitnesses) - min(Fitnesses))*(1-eps);
set(gca, 'XLim', [min(Distances)-DiffDistances, max(Distances)+DiffDistances]);
set(gca, 'YLim', [min(Fitnesses)-DiffFitnesses, max(Fitnesses)+DiffFitnesses]);
Lan = 'g';
TextAdd = sprintf('%s: Dim = %d', Name, size(Chrom,2));
TitleAdd = sprintf(': %.4g (%s)', fdccoeff, TextAdd);
if Lan == 'g', title(sprintf('Fitneß-Distanz-Korrelation%s', TitleAdd));
else title(sprintf('Fitness Distance Correlation%s', TitleAdd)); end
if Lan == 'g', xlabel('Distanz zum besten Individuum'); ylabel('Zielfunktionswert der Individuen (Fitneß)');
else xlabel('distance to best individual'); ylabel('objective value of individuals (fitness)'); end
drawnow;
% End of function
This document is part of
version 3.7 of the
GEATbx: Genetic and Evolutionary Algorithm Toolbox for use with Matlab -
www.geatbx.com.
The Genetic and Evolutionary Algorithm Toolbox is
not public domain.
© 1994-2005 Hartmut Pohlheim, All Rights Reserved,
(support@geatbx.com).