필터 지우기
필터 지우기

How do you fix error when run genetic algorithm in matlab?

조회 수: 5 (최근 30일)
KHANH NGUYEN
KHANH NGUYEN 2015년 5월 14일
댓글: KHANH NGUYEN 2015년 5월 21일
Hi everyone, I have used GA in matlab to solve my problem. I created a constraint function and fitness function for this problem.
When I ran the algorithm, It was error and didn't run.
Can you help me fix it?
I show you in below.
Undefined function 'fameanalysis' for input arguments of type 'double'.
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in constrValidate (line 23)
[cineq,ceq] = nonlcon(Iterate.x');
Error in gacommon (line 136)
[LinearConstr, Iterate,nineqcstr,neqcstr,ncstr] = constrValidate(NonconFcn, ...
Error in ga (line 327)
[x,fval,exitFlag,output,population,scores,FitnessFcn,nvars,Aineq,bineq,Aeq,beq,lb,ub, ...
Error in threebayfifteenthstoryframeoptimization (line 58)
[xbest, fbest, exitflag] = ga(@framecost, 34, [], [], [], [], ...
Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 5월 14일
We need to see the complete line of your call to ga()
It appears that in the 9th parameter, you passed in the string 'fameanalysis', and MATLAB is then trying to find a function named 'fameanalysis' to act as a constraint function.
Might I suggest that what you wanted was 'frameanalysis', that you were missing the 'r' ?

KHANH NGUYEN
KHANH NGUYEN 2015년 5월 15일
편집: Walter Roberson 2015년 5월 15일
Hi,
Thanks for your support.
I can talk with you that It's not error!
I show you how I call to ga:
opts = gaoptimset(...
'PopulationSize', 300, ...
'Generations', 300, ...
'EliteCount', [], ...
'TolFun', 1e-8, ...
'PlotFcns', @gaplotbestf);
%-----Call |ga| to Solve the Problem-------------------------------------
rng(0, 'twister');
[xbest, fbest, exitflag] = ga(@framecost, 34, [], [], [], [], ...
lb, ub, @fameanalysis,[], opts);
display(xbest);
fprintf('\nCost function returned by ga = %g\n', fbest);*
Could you explain me about something?
% InitialPenalty - Initial value of penalty parameter
% [ positive scalar | {10} ]
% PenaltyFactor - Penalty update parameter
% [ positive scalar | {100} ]
% Vectorized - Objective function is vectorized and it can evaluate
% more than one point in one call
% [ 'on' | {'off'} ]
% UseParallel - Use PARFOR to evaluate objective and nonlinear
% constraint functions.
% [ logical scalar | true | {false} ]
Thank you so much
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 5월 15일
What is it you would like to know about those options?
KHANH NGUYEN
KHANH NGUYEN 2015년 5월 21일
Hi Walter,
Something's my confuse. It's another approach that I'm trying.
I still use the genetic algorithm not constraint. I have a bit problem with it. If you can help, I'll send that problem to you.
Thank for your supporting.
Thank you so much

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by