Parameter tunning using GA

2 views (last 30 days)
Dawit Kefale
Dawit Kefale on 28 May 2023
Commented: Dawit Kefale on 29 May 2023
Hello dears,
I need urgent help
I developed a simulink model on matlan 2023 and i tried to obtain the gain parameters using GA algorithm. A code is written by calling the simulink model , but the algorithm can not be excuted.
here is my code that calls the simulink model
function [cost]= optimization_SMC(z)
assignin('base','kp' ,z(4));
cost(1)= ITAEZ(length(ITAEZ));
cost(2) = ASEP(length(ASEP));
cost(3) = ITAET(length(ITAET));
cost(4) = ASES(length(ASES));
.......and Here is the GA command
% GA parameter
lb=[1 1 1 0.4 1.3 1 1 0.3];
ub=[700 700 700 700 700 700 700 700];
%% Set solver options
options = optimoptions('ga','PopulationSize',200,...
%% Solve
obj_fn = @(z)optimization_SMC(z);
z= ga(obj_fn,var,[],[],[],[],lb,ub,[],options);
Here is the error after simulation
>> GA_Tunning
Error using makeState (line 61)
Your fitness function must return a scalar value.
Error in galincon (line 22)
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ga (line 402)
[x,fval,exitFlag,output,population,scores] = galincon(FitnessFcn,nvars, ...
Error in GA_Tunning (line 28)
z= ga(obj_fn,var,[],[],[],[],lb,ub,[],options);
How can I solve???

Accepted Answer

Walter Roberson
Walter Roberson on 28 May 2023
You cannot fix that. You are calculating four costs each time, but ga() can only handle one cost at a time. ga() will never be able to handle this.
There is a related function, gamultiobj which uses genetic algorithm search to explore the pareto front -- looking for places where the curl of the function is positive in all directions (and so changing any of the parameters by a small value results in a worse outcome.) gamultiobj() does not optimize each function individually: it looks for places that are local minima in all of the functions.
Dawit Kefale
Dawit Kefale on 29 May 2023
Thank you ,.
yes there is a coupling among the parameters , that is the case that makes the system somewhat difficult to be excuteud with the algorithm.
May I get your genuine cooperation Mr. Walter Roberson, if I inbox my compllet work with email.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!