forked from rishemjit/CODO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSitoSolver.m
70 lines (51 loc) · 2.05 KB
/
SitoSolver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function x = SitoSolver(funct,nvars,options)
% PopulationType', 'bitString', ...
% 'PopInitRange', [0;1], ...
% 'SocietySize', 7, ...
% 'DiversityFactor',0.95,...
% 'NeighbourhoodSize',2,...
% 'InitialPopulation',[], ...
% 'CreationFcn',[], ...
% 'Display', [], ...
% 'MaxIteration', [], ...
% 'FitnessLimit',[],...
% 'Tolerance', []);
% It is populationSize in options structure
No_of_Individuals = (options.SocietySize).^2; % it should have proper square root
row = sqrt(No_of_Individuals);
No_of_Features = nvars ; % passed by user here
Max_Iter = options.MaxIteration ; % goes in options structure
Neighbourhood = options.NeighbourhoodSize; % goes in options structure
exponent = 0; % exponent for distance (Lp and Ls)
K = options.DiversityFactor ;
column= row;
Society_Strength = [] ;
disp = {'off','on'};
lowArg = lower(options.Display);
dispFlag = strmatch(lowArg,disp)-1;
% check if InitialPopulation and CreationFcn are empty than run the default
if (isempty(options.InitialPopulation)&& isempty(options.CreationFcn))
% creation function this is the default one
for r = 1 : row
for c = 1: column
noOnes = round(No_of_Features * rand);
onesIndices = 1+ round((No_of_Features -1)* rand(noOnes,1));
Society_Attitude(r,c,onesIndices) = 1;
end
end
elseif (isempty(options.InitialPopulation)&& ~( isempty(options.CreationFcn)))
options = feval(options.CreationFcn,options);
Society_Attitude = options.InitialPopulation ;
else
Society_Attitude = options.InitialPopulation ;
end
% check to see if Fitness Function exists in the path
funcname = func2str(funct);
if ~exist(funcname,'file')
error('MATLAB:sitoOptimset:FcnNotFoundOnPath', ...
'the function ''%s'' does not exist on the path.',funcname);
end
% Society_Attitude = round(rand(row,row,No_of_Features));% randomly initialize attitude matrix(20,20,No_of_Features )
%%
x = OsitoSolver(Society_Attitude,funct,dispFlag);
end