Problem About Genetic Algorithm

11 vues (au cours des 30 derniers jours)
Julio
Julio le 17 Avr 2023
Commenté : Walter Roberson le 17 Avr 2023
Hello !
I have one RL circuit in SImulink, from this RL circuit I extracted the current and voltage signals ( as vectors) for 1 cycle, then I would like to implement a Genetic Algorithm that find the value of R and L .
So far my code simulate the reference case, then the GA set two random values of RL, then I simulate a test case with the R and L given by the GA, and extract the Vector of Voltage and current.
I'm having problems as I would like that my fitness function be the difference between The refence current and the Test current
When I use 'UseVectorized',true from the GA options, it says that the fitnes function should be the same size of the Pupulation.
What I want is that the fitness function be the difference of the two currents but so far this is my result
dt=0.02;
simulation(dt)
opt = optimoptions("ga",'PlotFcn',{@gaplotbestf},...
'PopulationSize',25,...
'Display','final',...
'CreationFcn',@gacreationuniform,...
'SelectionFcn',@selectionstochunif,...
'EliteCount',3,...
'CrossoverFraction',0.8,...
'CrossoverFcn',@crossoverscattered,...
'MutationFcn',@mutationadaptfeasible,...
'FunctionTolerance',1e-12,...
'MaxGeneration',200,...
'UseVectorized',true); %%%%%
lb = [0.8,0.8];
hb = [1.2,1.2];
  1 commentaire
Walter Roberson
Walter Roberson le 17 Avr 2023
When you have 'UseVectorized', true then when your objective function is passed a 2D array, it must return a vector that has the same number of rows as the input had rows.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by