Unrecognized field name "ProblemdefOptions".

8 visualizaciones (últimos 30 días)
Tal Levy
Tal Levy el 8 de Mzo. de 2023
Comentada: Dmitry Zhilyaev el 4 de Oct. de 2023
Hi, I'm trying to run ga with:
options = optimoptions('ga','Display','iter','MaxGenerations',3,'PopulationSize',10,'OutputFcn',@SaveOut);
But get an error:
"Unrecognized field name "ProblemdefOptions".
Error in gaoutput (line 30)
ProblemdefOptions = options.ProblemdefOptions;"
Does anyone have a solution?
Thank you

Respuestas (1)

Alan Weiss
Alan Weiss el 8 de Mzo. de 2023
It sounds as if you are using the problem-based approach. To do so, you might need to specify some options when you call solve, such as Solver="ga" and maybe other options.
For more help, please show your code where you call solve (or ga ) and all of your associated setup code.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 comentarios
Manjur Basnet
Manjur Basnet el 19 de Sept. de 2023
nvars = 7;
fun = @syscostmodified;
lb = [0, 0, 0, 0, 0, 0, 0];
ub = [Inf, Inf, Inf, 10, 20, Inf, Inf];
intcon = [1, 2, 4, 5, 6, 7];
nonlcon = @LPSPmodified;
opts=optimoptions('ga', 'PlotFcn', {@gaplotbestf, @gaplotbestindiv}, 'PopulationSize', 1000, 'OutputFcn', @SaveOut, 'Display', 'iter');
rng default
[x,fval,exitflag,output,population,scores] = ga(fun,nvars,[],[],[],[],lb,ub,nonlcon,intcon,opts);
I have the same issue when running my optimization problem. It looks something like this. I do not think it is a problem-based optimization. Can you please help me with this?
Dmitry Zhilyaev
Dmitry Zhilyaev el 4 de Oct. de 2023
I've had the same issue just now. The root of problem is your custom output function @SaveOut. I think you might even be using Alan's example for saving the intermediate populations from GA (How to save data from Genetic Algorithm in case MATLAB crashes? - MATLAB Answers - MATLAB Central (mathworks.com)). Or maybe something similar. But in any case, when you define your custom output function, it looks something like this:
function [state,options,changed] = SaveOut(options,state,flag)
or
function [state,options,optchanged] = SaveOut(options,state,flag)
And, I believe, within the @SaveOut function you have a line like this:
changed = true;
or
optchanged = true;
All you need to do is to change "true" to "false".
In the documentation, it is written that "ga does not accept changes in options, and ignores optchanged" (Genetic Algorithm Options - MATLAB & Simulink - MathWorks Benelux). However, it seems in this case it is not ignoring it but throws an error instead.

Iniciar sesión para comentar.

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by