The genetic algorithm is not returning the minimum of my function?
Ältere Kommentare anzeigen
I am attempting to optimize the locations of transducers in a set-up by maximizing the sensitivity within the imaging volume. The function I am feeding to the GA takes the x and y coordinates of the transducer and returns 1/(sensitivity+1) to maximize the sensitivity and avoid dividing by zero. The sensitivity is always a positive number and I have restricted the variables to integers.
In an imaging volume of 5x5x5, optimizing the 5th (top) z plane, we would assume that the best place to put the transducer is the middle [3,3,0] (I have restricted the z position of the transducer to 0 for now), however, the GA returns [0,3,0]. I have run this several times with different population sizes and initial populations and it consistently returns [0,3,0]. When I manually calculate the result of the function that the GA is working with, I get a higher value for [0,3,0] than [3,3,0]. My understanding is that the GA should be finding the minimum of my function and there are many more positions that return a lower value than [0,3,0] because they are closer to the centre of the imaging space (such as [1,3,0] [2,3,0]).
Is there any reason that the GA would be unable to return the minimum of my function?
9 Kommentare
What happens when you choose an initial population concentrated near the center of the imaging space? If you know this is where the solution is likely to lie, that's what you would do. What happens when [3,3,0] is included in the initial population?
Jonathan Epperl
am 31 Okt. 2012
Is there a particular reason you chose the cost function like that? What would happen if you used -sensitivity instead, or -log(sensitivity) or so? I'm asking, because the selection stage in a GA can be somewhat sensitive to how you chose your cost function, and it interacts with the way you assign fitness to individuals etc.
But first do what Matt suggested, add the optimum to your initial population, and if that is available to you, enable Elitism in your GA. If it again comes up with the wrong solution, then there is a deeper issue.
Avery
am 1 Nov. 2012
Jonathan Epperl
am 1 Nov. 2012
If [3,3,0] is in your initial population, [3,3,0] is the optimum, and you have elitism enabled, then it is impossible that your GA would return anything but [3,3,0], no matter which form of the cost function you are using. So there must be something wrong with the cost function evaluation.
I assume you pass the cost function to your GA as a function handle, like
cost = @(individual) code...
What happens if you call that exact function with [3,3,0] and [0,3,0]?
cost([3,3,0])
Another thought: For the GA, you probably have to represent [3,3,0] etc as a bit string. How do you do that? Maybe there's a mix-up in how you go from the vector to a binary representation?
Matt J
am 1 Nov. 2012
What is the difference between the two cost levels
cost([0 3 0]) - cost([3,3,0])
Avery
am 2 Nov. 2012
Jonathan Epperl
am 2 Nov. 2012
That is a very odd coincidence... Are you sure you are comparing cost and not fitness? (fitness is a transformed version of cost, in the right column of the optimtool you can select what kind of scaling is applied)
Elitism can also be enabled in the middle column, "Elite Count" under "Selection." However, it is at 2 by default, at least in my version, so it should have been on all along and I am at a loss.
Avery
am 2 Nov. 2012
Jonathan Epperl
am 3 Nov. 2012
Yeah, try and set the EliteCount manually. I don't expect it to change anything, but might as well try. Apart from that I don't think we have enough info to find what's wrong. All I know is this: Elitism means that the best individuals in Population i are going to be in Population i+1, too, so that if the minimizer is in your initial population already, there should be no way that you get any other result.
So the error must happen somewhere else, the objective as the GA evaluates it must be different from the objective if you manually call it from Matlab.
Antworten (0)
Kategorien
Mehr zu Genetic Algorithm finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!