Genetic algorithm for tracking
古いコメントを表示
Hi all,
I am trying to produce a tracking algorithm using a genetic algorithm.
I am having an issue where the values created just decrease forever, i believe i need to create a better fitness function to achieve my desired goal as my current one is just minimising the value. Below is my current fitness function.
function [X_New] = Fitness_Function_X( X_Correction)
%% Fitness function
global Xfval %Car_Position_Current_X
X_New = ( Xfval + X_Correction) ;
end
Is there a way to change the value the system is matching the result to to calculate the cost function or is there a better way to word my fitness function?
3 件のコメント
Geoff Hayes
2020 年 4 月 9 日
Cameron - you may need to provide some details on your fitness function. Are you trying to maximize or minimize? What do you mean by having an issue where the values created just decrease forevers? Which values?
Cameron Barber
2020 年 4 月 9 日
Geoff Hayes
2020 年 4 月 9 日
Cameron - if you want to minimize the distance between any point, then why not calculate the distance between the updated point and the desired point and then have your fitness function return that value? Let's assume you have a desired/target position given by
function [dist] = Fitness_Function_X( X_Correction)
global Xfval %Car_Position_Current_X
global XTargetVal % target position
X_New = ( Xfval + X_Correction);
dist = sqrt((XTargetVal - X_New)^2);
end
If you have coordinates for y (and perhaps z) then you could include them in the distance calculation too. As an aside, I don't like using global variables but have only done it here for illustration. I prefer to use nested functions
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!