Genetic algorithm error in 'fitness function evaluation'

hello,
I wrote a code about the genetic-neural network. every time I run it, face this error in the function of fitness evaluation. my cod is:
function EE=FitFcn2(particle)
global sigma rule Train_data Target_train
M=size(rule,1);
w(:,1)=particle(1:M);
c=reshape(particle(M+1:end),size(sigma,1),size(sigma,2));
EE=0;
for ii=1:size(Train_data,1)
x=Train_data(ii,:)';
o=FS_type_1(x,c,sigma,w,rule);
e=Target_train(ii)-o;
EE=EE+sum(e.^2);
end
EE=EE/size(Train_data,1);
the error is:
Error in main2 (line 13)
[w,Fval,exitFlag,Output]=ga(@(w) FitFcn2(w),num_v,...
Caused by:
Failure in initial user-supplied fitness function evaluation. GA cannot continue.
how can I solve it? what does this error exactly related to?

回答(0 个)

类别

提问:

2019-11-13

编辑:

2019-11-13

Community Treasure Hunt

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

Start Hunting!

Translated by