Problem About Genetic Algorithm

조회 수: 11 (최근 30일)
Julio
Julio 2023년 4월 17일
댓글: Walter Roberson 2023년 4월 17일
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
Walter Roberson
Walter Roberson 2023년 4월 17일
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.

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

답변 (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