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];
1 件のコメント
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 Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!