Patternsearchw with genetic algorithm
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Grzegorz Knor
le 14 Fév 2014
Réponse apportée : Rakesh Kumar
le 14 Fév 2014
Hi,
I would like to run patternsearch function with SearchMethod option set to searchga. But it seems that patternsearch does not honour additional options for searchga. For example:
fun = @(x)sum(x.^2);
gaopt = gaoptimset('Display','iter');
psopt = psoptimset('Display','iter','SearchMethod',{@searchga,1,gaopt});
patternsearch(fun,[-10 10],[],[],[],[],[],[],[],psopt)
In this case I want to print information from GA at each iteration. But when you run this code no information from GA is displayed.
Moreover there is a line in function searchga:
if nargin < 16 || isempty(optionsGA)
But maximum number of input arguments is 12, so always this condition is true and in effect some fields in GA option structure are replaced by default values.
Is it correct? Or I don't understand something?
0 commentaires
Réponse acceptée
Rakesh Kumar
le 14 Fév 2014
Hi Grzegorz, Thanks for posting this issue; it is a bug. The only workaround I can see is to change the code and compare nargin with the right number of input arguments. Please change these two lines.
if nargin < 12 isempty(optionsGA)
if nargin < 11 isempty(iterLimit)
if you cannot modify the original file (maybe due to permission issues), create a copy of this file and make the modifications.
Thanks, Rakesh ps: Previous version of the API for search functions used to have 16 input args. Later it was changed but this code was not updated (and tested). Sorry about this.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Direct Search dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!