Patternsearchw with genetic algorithm

1 回表示 (過去 30 日間)
Grzegorz Knor
Grzegorz Knor 2014 年 2 月 14 日
回答済み: Rakesh Kumar 2014 年 2 月 14 日
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?

採用された回答

Rakesh Kumar
Rakesh Kumar 2014 年 2 月 14 日
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 件)

カテゴリ

Help Center および File ExchangeDirect Search についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by