Genetic Algorithm Plotter does not display

11 ビュー (過去 30 日間)
Khaled Mohamed
Khaled Mohamed 2021 年 10 月 22 日
コメント済み: Walter Roberson 2021 年 10 月 23 日
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)

回答 (1 件)

Walter Roberson
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 件のコメント
Khaled Mohamed
Khaled Mohamed 2021 年 10 月 22 日
編集済み: Khaled Mohamed 2021 年 10 月 22 日
Hi.
I tried that as well but It did not show. The strange thing is that simulated annealing plots show. However, ga and particle swarm plots do not.
Walter Roberson
Walter Roberson 2021 年 10 月 23 日
We will probably need all your code and whatever data to test with

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by