# Why ga() function is only finding minimum of the fitness function??...

16 views (last 30 days)
sani ars on 20 Dec 2012
I want to know about the ga() function given in Global Optimization Toolbox in MATLAB 2012a....
It is finding the minimum of the fitness function..... What should I do If one need to find the maximum of the fitness function??.... I have to find the maximum fitness value of my fitness function...
One more thing..
There is an option of "Elite Count" in the option structure along with crossover and mutation.... When I am using it, this "Elite Count" is moving only those individuals to the next generation which are of low fitness value...... While in documentation it is written that "individuals with best fitness value automatically survive to the next generation"..... whats going on???...
Is this ga() is working only for finding minimum of the function only???...

Matt J on 20 Dec 2012
Edited: Matt J on 20 Dec 2012
Maximizing f(x) is the same as minimizing -f(x), so you can reformulate any maximization problem as a minimization problem.
As for "Elite Count", the documentation sounds consistent with what you are seeing as long as best=lowest, and that would make sense considering that the goal is to make the fitness function as low as possible.

Walter Roberson on 20 Dec 2012
If you need to maximize, then have your function return the negative of what it would normally return, and at the end, take the negative of the ultimate value.
sani ars on 20 Dec 2012
you mean to say... I should take the negative of scores of each individual of population that it returns??....
But in this way I'll lose that individual of population which is giving me highest score i.e 86%.. if I make it negative my highest score will become lowest as -86% and lowest will become highest as 32%.... I am concerned with that individual giving best score....
Suppose if I do the same as you mentioned.... how I'll be able to get the best individuals???.... I am not getting your point...... plzz elaborate it kindly

Jonathan Epperl on 20 Dec 2012
Of course you can also use 1/f(x) or exp(-f(x)) or ..., since the Genetic Algorithm's success is basically luck anyway those variants might work much better or much worse than -f(x).
As for the Elite Count parameter, that tells you that the n best individua move to the next generation, unaltered. Whether you write the ga so that that corresponds to a low or high fitness value is probably a matter of taste, but I agree with you, I'd have it so that high fitness means good individuum.