Genetic algorithm giving errors - reg

조회 수: 2 (최근 30일)
Kallam Haranadha Reddy
Kallam Haranadha Reddy 2017년 1월 29일
답변: Geoff Hayes 2017년 1월 31일
I implemented a flow shop scheduling problem in MATLAB R 2009b. But the same m-file and same data when i want to run in MATLAB R 2013a. It is giving error messages.
I tried to run genetic algorithm with the following line:
[x,fval,reason,output] = ga(fitnessfcn1,numberOfVariables,options)
Error messages are given below:
Error using feval
Undefined function 'gaoutputgen' for input
arguments of type 'struct'.
Error in gaoutput (line 29)
[state,optnew,changed] =
feval(functions{i},options,state,flag,args{i}{:});
Error in gaunc (line 55)
[state,options] =
gaoutput(FitnessFcn,options,state,currentState);
Error in ga (line 348)
[x,fval,exitFlag,output,population,scores]
= gaunc(FitnessFcn,nvars, ...
Error in mainHGA (line 58)
[x,fval,reason,output] =
ga(fitnessfcn1,numberOfVariables,options)
But the same program worked well in MATLAB R 2009b.
How can i run it in MATLAB R 2013a.
Thanks
  댓글 수: 2
Walter Roberson
Walter Roberson 2017년 1월 29일
What options did you pass in?
Kallam Haranadha Reddy
Kallam Haranadha Reddy 2017년 1월 31일
편집: Geoff Hayes 2017년 1월 31일
I used the following options for running the Genetic Algorithm
options = gaoptimset('PopulationType', 'custom');
options = gaoptimset(options,'CreationFcn',inpop, ...
'CrossoverFcn',@mycrossoverOrder, ...
'MutationFcn',@mymutate_RX, ...
'PlotFcns',@gaplotbestf, ...
'Generations',2000,'PopulationSize',200, ...
'OutputFcn',@gaoutputgen,...
'StallGenLimit',2000,'TimeLimit',100,...
'StallTimeLimit',1000,'Vectorized','on');
This program run well in MATLAB R 2009b. But it is showing error messages in MATLAB R 2013a.

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

채택된 답변

Geoff Hayes
Geoff Hayes 2017년 1월 31일
According to the 2013a documentation found here, the signature for the output function is
[state,options,optchanged] = myfun(options,state,flag)
with the input arguments are defined as
  • options — Options structure
  • state — Structure containing information about the current generation. The State Structure describes the fields of state.
  • flag — String indicating the current status of the algorithm
Given the error message, Undefined function 'gaoutputgen' for input arguments of type 'struct', I suspect that this function signature changed from R2009b to R2013a to include a struct input (this would be the options). You will need to modify your gaoutputgen to conform to the (new) expected signature.

추가 답변 (0개)

카테고리

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