Hello! I have a fitness functiion:
function z = my_fun(x) Skorost8.input(1,1).mf(1,1).params=[x(1),x(2),x(3)]; Skorost8.input(1,1).mf(1,2).params=[x(4),x(5),x(6)]; Skorost8.input(1,1).mf(1,3).params=[x(7),x(8),x(9)]; Skorost8.input(1,1).mf(1,4).params=[x(10),x(11),x(12)]; Skorost8.input(1,2).mf(1,1).params=[x(13),x(14),x(15)]; Skorost8.input(1,2).mf(1,2).params=[x(16),x(17),x(18)]; Skorost8.input(1,2).mf(1,3).params=[x(19),x(20),x(21)]; load_system('petina.mdl'); sim('petina.mdl'); close_system('petina.mdl'); z=simout.signals.values;
And petina.mdl file, which it use. The mdl-file write to workspace a massive of values, which must be a minimal (z=simout.signals.values;)
When I try to use it with gatool I get:
>> x=ga(@my_fun,21); ??? Subscripted assignment dimension mismatch.Error in ==> fcnvectorizer at 14 y(i,:) = feval(fun,(pop(i,:)));Error in ==> makeState at 47 Score = fcnvectorizer(state.Population(initScoreProvided+1:end,:),FitnessFcn,1,options.SerialUserFcn);Error in ==> gaunc at 41state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);Error in ==> ga at 279 [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...Caused by: Failure in user-supplied fitness function evaluation. GA cannot continue.
How to use correctly gatool in this case? thank you very much!
Best Answer