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!