Unrecognized field name "ProblemdefOptions".

8 次查看(过去 30 天)
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

回答(1 个)

Alan Weiss
Alan Weiss 2023-3-8
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 个评论
Manjur Basnet
Manjur Basnet 2023-9-19
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 2023-10-4
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by