Unrecognized field name "ProblemdefOptions".

조회 수: 10 (최근 30일)
Tal Levy
Tal Levy 2023년 3월 8일
댓글: Dmitry Zhilyaev 2023년 10월 4일
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