Patternsearchw with genetic algorithm
2 views (last 30 days)
Show older comments
Grzegorz Knor
on 14 Feb 2014
Answered: Rakesh Kumar
on 14 Feb 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 Comments
Accepted Answer
Rakesh Kumar
on 14 Feb 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 Comments
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!