forked from rishemjit/CODO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Order3Deceptive.m
36 lines (33 loc) · 1.07 KB
/
Order3Deceptive.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
% order3deceptive(x) function is massively multimodal deceptive problem.
% Input : Vector of individual's attitudes
% Output : scalar (fitness value) computed at x
function [y]= Order3Deceptive(x)
% check to see the number of features
No_of_Features = length(x);
% Hamming_string to codeWords
if ~isempty(x)
% set codeWord size
sizeCodeword = 3;
noCodewords = No_of_Features/sizeCodeword;
codeWords = zeros(noCodewords,sizeCodeword);
x_index = 1 ;
% array of codeWords
for k = 1:sizeCodeword:(No_of_Features - sizeCodeword+1)
first_value = k;
last_value = k+(sizeCodeword-1);
codeWords(x_index,:)= x(first_value:last_value);
x_index = x_index + 1 ;
end
end
% fitness values
f=[-28;-26;-22;0;-14;0;0;-30];
r=[];
for l = 1:noCodewords
codeWord = int2str(codeWords(l,:));
% convert binary value to decimal value
dec_value = bin2dec(codeWord);
% assigning fitness value according to decimal value
r = [r f(dec_value+1)];
end
y=sum(r);
end