forked from drwuHUST/MTGA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnceval.m
27 lines (27 loc) · 831 Bytes
/
fnceval.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
function [objective,rnvec,funcCount] = fnceval(Task,rnvec,p_il,options)
%FNCEVAL function: evaluate function in the unified search space
d = Task.dims;
nvars = rnvec(1:d);
minrange = Task.Lb(1:d);
maxrange = Task.Ub(1:d);
y=maxrange-minrange;
vars = y.*nvars + minrange; % decoding
if rand(1)<=p_il
[x,objective,exitflag,output] = fminunc(Task.fnc,vars,options);
nvars= (x-minrange)./y;
m_nvars=nvars;
m_nvars(nvars<0)=0;
m_nvars(nvars>1)=1;
if ~isempty(m_nvars~=nvars)
nvars=m_nvars;
x=y.*nvars + minrange;
objective=Task.fnc(x);
end
rnvec(1:d)=nvars;
funcCount=output.funcCount;
else
x=vars;
objective=Task.fnc(x);
funcCount=1;
end
end