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.
Problem About Genetic Algorithm
11 次查看(过去 30 天)
显示 更早的评论
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];
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!