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 Comments

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?
Hi Geoff, Sorry for the lack of detail, i am trying to have my system cause an intersection between a point in space and a different point by having the ga chose whether to move closer or further away to this point. Unfortunatley as the system is solving for a minimum the point it is intersecting with is [0,0,0] before moving through this point into the negatives. i have stopped the system going into the negatives by doing abs( Xfval + X_Correction) however is it possible to set a value for the system to solve to rather than just minimising? (this would mean i could intersect with a different point in space)
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

Sign in to comment.

Answers (0)

Products

Release

R2016b

Asked:

on 9 Apr 2020

Commented:

on 9 Apr 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!