Problem in using Genetic algorithm tool - Not enough input arguments
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I want to use GA to find the minimum of the function z=x^2+y^2.
I define the function:
function z=my_fun(x,y)
z=x.^2+y^2;
then I call the ga function:
ga(@my_fun,2)
but error occurs.
the error message is:
Error using my_fun (line 2) Not enough input arguments.
Error in validate>@(x)fitness(x,FitnessFcnArgs{:}) (line 136) fitness = @(x) fitness(x,FitnessFcnArgs{:});
Error in fcnvectorizer (line 14) y(i,:) = feval(fun,(pop(i,:)));
Error in makeState (line 47) Score = fcnvectorizer(state.Population(initScoreProvided+1:end,:),FitnessFcn,1,options.SerialUserFcn);
Error in gaunc (line 41) state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 351) [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Caused by: Failure in user-supplied fitness function evaluation. GA cannot continue.
Could someone help me?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!