Genetic Algorithm Plotter does not display
11 ビュー (過去 30 日間)
古いコメントを表示
Hi
I'm using the ga optimizer to find some parameters. However, the bestfit plot does not show up at all.
I used this code from the help section
%% Fit options
opts=optimoptions('ga','FunctionTolerance', 1E-9,'MaxGenerations',5000000,'MaxStallGenerations',500000,'HybridFcn','patternsearch', ...
'PlotFcn',{@gaplotbestf,@gaplotchange},'PopulationSize',500,'FitnessLimit',-inf,'MigrationDirection','both');
%% Optimizer
% Do a ro
lb = [ 0 ; 0 ; 0 ];
ub = [ Inf ; 3.0 ; 5.0 ];
f=@(param_vec) e_and_r_vals(param_vec)
[best_fit_param,fval,exitflag,output,population,scores] = ga(f,3,[],[],[],[],lb,ub,[],opts)
Also the below does not show the plot
%% Fit options
opts=optimoptions('ga','FunctionTolerance', 1E-9,'MaxGenerations',5000000,'MaxStallGenerations',500000,'HybridFcn','patternsearch', ...
'PlotFcn','@gaplotbestf','PopulationSize',500,'FitnessLimit',-inf,'MigrationDirection','both');
%% Optimizer
% Do a ro
lb = [ 0 ; 0 ; 0 ];
ub = [ Inf ; 3.0 ; 5.0 ];
f=@(param_vec) e_and_r_vals(param_vec)
[best_fit_param,fval,exitflag,output,population,scores] = ga(f,3,[],[],[],[],lb,ub,[],opts)
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 10 月 22 日
opts=optimoptions('ga', 'FunctionTolerance', 1E-9, 'MaxGenerations', 5000000, 'MaxStallGenerations', 500000, 'HybridFcn', 'patternsearch', ...
'PlotFcn', @gaplotbestf, 'PopulationSize', 500, 'FitnessLimit', -inf, 'MigrationDirection', 'both');
You can specify the plot function by name (character vector or string scalar) or by handle. You cannot specify the plot function by character vector that looks sort of like a handle. @gaplotbestf or 'gaplotbestf' not '@gaplotbestf'
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!