Patternsearchw with genetic algorithm

2 Ansichten (letzte 30 Tage)
Grzegorz Knor
Grzegorz Knor am 14 Feb. 2014
Beantwortet: Rakesh Kumar am 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?

Akzeptierte Antwort

Rakesh Kumar
Rakesh Kumar am 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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by