Genetic Algorithm Plotter does not display

11 Ansichten (letzte 30 Tage)
Khaled Mohamed
Khaled Mohamed am 22 Okt. 2021
Kommentiert: Walter Roberson am 23 Okt. 2021
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)

Antworten (1)

Walter Roberson
Walter Roberson am 22 Okt. 2021
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 Kommentare
Khaled Mohamed
Khaled Mohamed am 22 Okt. 2021
Bearbeitet: Khaled Mohamed am 22 Okt. 2021
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 am 23 Okt. 2021
We will probably need all your code and whatever data to test with

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by