Patternsearchw with genetic algorithm

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by