Unrecognized field name "ProblemdefOptions".
2 ビュー (過去 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
0 件のコメント
回答 (1 件)
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
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
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 Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!