How do i minimze my fuzzy logic controller using genetic algorithm?

I am trying to minimize the function of my fuzzy logic controller using the genetic algorithm. Please find attached the code for the fuzzy logic controller. The error I keep getting is shown below when I use my call function ;
M=[14000,15555,16000,17000,18000,19000; 14555,15555,16000,17555,18530,19000] options = gaoptimset('InitialPopulation',M) [x fval] = ga(@FuzzyForecast,6, options)
Error using FuzzyForecast (line 9) Not enough input arguments.
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11) fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in makeState (line 47) firstMemberScore = FitnessFcn(state.Population(initScoreProvided+1,:));
Error in gaunc (line 40) state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 356) [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Caused by: Failure in initial user-supplied fitness function evaluation. GA cannot continue.

回答 (1 件)

Stephan
Stephan 2018 年 9 月 22 日
編集済み: Stephan 2018 年 9 月 22 日

0 投票

Hi,
ga passes only one x with 6 entries to the objective function. Try the attached version. I could not test, since i do not have Fuzzy Logic Toolbox. The change are these lines at the beginning:
function z=FuzzyForecast(x)
x1 = x(1);
x2 = x(2);
x3 = x(3);
x4 = x(4);
x5 = x(5);
x6 = x(6);
The other lines are kept as they were.
Best regards
Stephan

3 件のコメント

Honey Adams
Honey Adams 2018 年 9 月 22 日
Thank you for your reply.It run twice and gave me the error below .
Error using evalfismex Illegal parameters in fisTriangleMf() --> a > b
Error in evalfis (line 83) [output,IRR,ORR,ARR] = evalfismex(input, fis, numofpoints);
Error in FuzzyForecast (line 52) u=evalfis(FLC_input,a);%evaluating output a.fis
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11) fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in fcnvectorizer (line 13) y(i,:) = feval(fun,(pop(i,:)));
Error in makeState (line 58) Score = fcnvectorizer(state.Population(initScoreProvided+2:end,:),FitnessFcn,1,options.SerialUserFcn);
Error in gaunc (line 40) state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 356) [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
Caused by: Failure in user-supplied fitness function evaluation. GA cannot continue.
Stephan
Stephan 2018 年 9 月 22 日
編集済み: Stephan 2018 年 9 月 22 日
As i said i can not help solving this new error, due to missing toolbox for fuzzy.
Perhaps it is a good idea to ask this in a new question. Maybe someone other reads it here and can help.
The problem regarding ga seems to be solved.
Honey Adams
Honey Adams 2018 年 9 月 22 日
Thanks for your effort.I will ask.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFuzzy Logic Toolbox についてさらに検索

質問済み:

2018 年 9 月 22 日

編集済み:

2018 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by