Code Execution Error.

I have very basic knowledge of Matlab and I want to execute a Matlab code. There is some error in code and I am unable to figure out that error.
run.m file
Here is code.
close all;
warning off;
% pctRunOnAll warning off;
% dbstop if error
benchmark = 'benchmark_func2013_large';
if strcmp(benchmark, 'benchmark_func2013_large')
rmpath('./benchmark_func2008');
addpath('./benchmark_func2013_large')
func_name = {'Shifted Elliptic Function'
'Shifted Rastrigin''s Function'
'Shifted Ackley''s Function'
'7-nonseparable, 1-separable Shifted and Rotated Elliptic Function'
'7-nonseparable, 1-separable Shifted and Rotated Rastrigin''s Function'
'7-nonseparable, 1-separable Shifted and Rotated Ackley''s Function'
'7-nonseparable, 1-separable Shifted Schwefel''s Function'
'20-nonseparable Shifted and Rotated Elliptic Function'
'20-nonseparable Shifted and Rotated Rastrigin''s Function'
'20-nonseparable Shifted and Rotated Ackley''s Function'
'20-nonseparable Shifted Schwefel''s Function'
'Shifted Rosenbrock''s Function'
'Shifted Schwefel''s Function with Conforming Overlapping Subcomponents'
'Shifted Schwefel''s Function with Conflicting Overlapping Subcomponents'
'Shifted Schwefel''s Function'};
save_func_name = {...
'Elliptic', 'Rastrigin', 'Ackley', ... % Fully-separable Functions
'Partially1Elliptic','Partially1Rastrigin', 'Partially1Ackley', 'Partially1Schwefel', ... % Partially Additive Separable Functions I
'Partially2Elliptic','Partially2Rastrigin', 'Partially2Ackley', 'Partially2Schwefel',... % Partially Additive Separable Functions II
'Rosenbrock', 'ConformingOverlappingSchwefel', 'ConflictingOverlappingSchwefel',... % Overlapping Functions
'Schwefel'... % Hybrid Composition Function
};
initialRange = [-100, -5, -32, -100, -5, -32, -100, -100, -5, -32, -100, -100, -100, -100, -100
100, 5, 32, 100, 5, 32, 100, 100, 5, 32, 100, 100, 100, 100, 100];
initialRange = num2cell(initialRange, 1);
searchRange = initialRange; % Search range equal to Initial range for most of functions
D = 1000 * ones(1, 15);
D(13:14) = 905 * ones(1, 2);
D = num2cell(D);
elseif strcmp(benchmark, 'benchmark_func2008')
rmpath('./benchmark_func2013_large');
addpath('./benchmark_func2008');
javaclasspath('./benchmark_func2008/FractalFunctions.jar')
func_name = {'Shifted Sphere Function'
'Shifted Schwefel''s Function'
'Shifted Rosenbrock''s Function'
'Shifted Rastrigin''s Function'
'Shifted Griewank''s Function'
'Shifted Ackley''s Function'
'FastFractal "DoulbeDip" Function'};
save_func_name = {'Sphere',...
'Schwefel',...
'Rosenbrock',...
'Rastrigin',...
'Griewank',...
'Ackley',...
'DoubleDip'};
initialRange = [-100, -100, -100, -5, -600, -32, -1
100, 100, 100, 5, 600, 32, 1];
initialRange = num2cell(initialRange, 1);
searchRange = initialRange; % Search range equal to Initial range for most of functions
D = 1000;
end
runs = 4;
maxFEs = 3000 * 1000;
parameters = struct(...
'save_func_name', save_func_name,...
'runs', runs,...
'maxFEs', maxFEs,...
'D', D,...
'initialRange', initialRange,...
'searchRange', searchRange...
);
for func_num = 1:15
opts.lbound = parameters(func_num).searchRange(1);
opts.ubound = parameters(func_num).searchRange(2);
opts.dim = parameters(func_num).D;
opts.epsilon = 1e-3;
addpath('benchmark_func2013');
[seps, nonseps, FEs] = dg('benchmark_func', func_num, opts);
filename = sprintf('./results/F%02d', func_num);
save (filename, 'seps', 'nonseps', 'FEs', '-v7');
end
dg.m file
function [seps, allgroups, FEs] = dg(fun, fun_number, options);
ub = options.ubound;
lb = options.lbound;
dim = options.dim;
epsilon = options.epsilon;
r = ub - lb;
dims = [1:1:dim];
seps = [];
allgroups = {};
FEs = 0;
while (length(dims) >= 1)
allgroups;
n = length(dims)
group = [dims(1)];
group_ind = [1];
p1 = lb * ones(1,dim);
p2 = p1;
p2(dims(1)) = ub;
delta1 = feval(fun, p1, fun_number) - feval(fun, p2, fun_number);
FEs = FEs + 2;
for i=2:n
p3 = p1;
p4 = p2;
temp = 0;
p3(dims(i)) = temp;
p4(dims(i)) = temp;
delta2 = feval(fun, p3, fun_number) - feval(fun, p4, fun_number);
FEs = FEs + 2;
if(abs(delta1-delta2) > epsilon)
group = [group ; dims(i)];
group_ind = [group_ind ; i];
end
end
if(length(group) == 1)
seps = [seps ; group];
else
allgroups = {allgroups{1:end}, group};
end
if(length(dims) > 0)
dims(group_ind) = [];
end
end
end
It throws following error.
error: feval: function 'benchmark_func' not found
error: called from
dg at line 63 column 15
run at line 93 column 23
More Detail about code could be found on following Github Link.

Answers (0)

Tags

Asked:

on 29 Mar 2020

Edited:

on 29 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!