Unrecognized field name "ProblemdefOptions".
7 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Alan Weiss
on 8 Mar 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 Comments
Manjur Basnet
on 19 Sep 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
on 4 Oct 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.
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!