Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update niching_func.m #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions matlab/niching_func.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@
%1. Composition Function 1, n=6
%==============================================================================
function fit = CF1(x)
global initial_flag
persistent func_num func o sigma lambda bias M
persistent func_num func o sigma lambda bias M initial_flag dim

[ps,D] = size(x);
func_num = 6;
lb = -5; ub = 5;
if initial_flag==0
if initial_flag==0 || D ~= dim % if run this function for the first time or run the same function with different dimensions of x
load data/optima.mat % saved the predefined optima
if length( o(1,:) ) >= D
o = o(:,1:D);
else
o = lb + (ub - lb) * rand(func_num,D);
end
dim = size(o,2); % record the dimension
initial_flag=1;
func.f1 = str2func('FGriewank');
func.f2 = str2func('FGriewank');
Expand All @@ -238,20 +238,20 @@
%2. Composition Function 2, n=8
%==============================================================================
function fit = CF2(x)
global initial_flag
persistent func_num func o sigma lambda bias M
persistent func_num func o sigma lambda bias M initial_flag dim

[ps,D] = size(x);
func_num = 8;
lb = -5; ub = 5;
if initial_flag==0
if initial_flag==0 || D ~= dim % if run this function for the first time or run the same function with different dimensions of x
initial_flag=1;
load data/optima.mat % saved the predefined optima
if length( o(1,:) ) >= D
o = o(:,1:D);
else
o = lb + (ub - lb) * rand(func_num,D);
end
dim = size(o,2); % record the dimension
func.f1 = str2func('FRastrigin');
func.f2 = str2func('FRastrigin');
func.f3 = str2func('FWeierstrass');
Expand All @@ -274,20 +274,20 @@
%3. Composition Function 3, n=6
%==============================================================================
function fit = CF3(x)
global initial_flag
persistent func_num func o sigma lambda bias M
persistent func_num func o sigma lambda bias M initial_flag dim

[ps,D] = size(x);
func_num = 6;
lb = -5; ub = 5;
if initial_flag==0
if initial_flag==0 || D ~= dim % if run this function for the first time or run the same function with different dimensions of x
initial_flag=1;
load data/optima.mat % saved the predefined optima, a 10*100 matrix;
if length( o(1,:) ) >= D
o = o(:,1:D);
else
o = lb + (ub - lb) * rand(func_num,D);
end
dim = size(o,2); % record the dimension
func.f1 = str2func('FEF8F2');
func.f2 = str2func('FEF8F2');
func.f3 = str2func('FWeierstrass');
Expand Down Expand Up @@ -318,20 +318,20 @@
%4. Composition Function 4, n=8
%==============================================================================
function fit = CF4(x)
global initial_flag
persistent func_num func o sigma lambda bias M
persistent func_num func o sigma lambda bias M initial_flag dim

[ps,D] = size(x);
func_num = 8;
lb = -5; ub = 5;
if initial_flag==0
if initial_flag==0 || D ~= dim % if run this function for the first time or run the same function with different dimensions of x
initial_flag=1;
load data/optima.mat % saved the predefined optima, a 10*100 matrix;
if length( o(1,:) ) >= D
o = o(:,1:D);
else
o = lb + (ub - lb) * rand(func_num,D);
end
dim = size(o,2); % record the dimension
func.f1 = str2func('FRastrigin');
func.f2 = str2func('FRastrigin');
func.f3 = str2func('FEF8F2');
Expand Down