How do i insert my own initial population in genetic algorithm toolbox?
10 views (last 30 days)
Show older comments
ive created a matrix (MAT) where the number of rows (N) is the number of posible solutions and the columns are the variables, which in this case is 16.
ive already developed a fitness function where evaluates each row, and the results (N) are displayed in a new matrix Nx1. Therefore, I want the program to take a random number of rows of MAT, put them in my fitnes function, and do its own genetic operations (selection,crossover, etc) to give me the best solution (minimized).
So, how do i program ga optimizacion toolbox or the ga function ( ga(@fitnessfun, nvars, options) ) in order to do this?
Thank you in advance.
0 Comments
Answers (1)
Walter Roberson
on 10 Feb 2018
7 Comments
Gustavo Lunardon
on 13 Sep 2022
Edited: Gustavo Lunardon
on 13 Sep 2022
I was having a similar problem earlier today actually. I pass an initial population to GA by the options via optimoptions (gaoptimset was phased out meanwhile, old question) and some of of the population members are the outcome of fmincon, globalsearch, etc. This means I have some good (and feasible) members in the population already, but I wanted to use GA for refinement and perhaps find an optimum somewhere else. Like the original post, however, GA gives me a worse objective function value than what I can get from the initial population, maybe by the creation of the subpopulation mentioned by Hamidreza. I tried to pass [] to 'creationfunction' but also did not solve the problem.
Walter Roberson
on 13 Sep 2022
ga can return a worse value than the original if the original population elements turn out to be outside the constraints.
Also, sometimes when people construct arrays of numbers that have been computed, they copy some display form of the number instead of transfering the number in binary form from its computed source. If you build your arrays by text then unless you are careful to have asked MATLAB to display more digits than it normally would, you might not end up reproducing the exact locations, and if the function is steep then that can make a considerable difference as to what the scores are.
For example, if we
format long g
pi
pi - 3.14159265358979
pi - 3.141592653589793
we copied the exact text that MATLAB displays for pi, but that turns out to be a value slightly smaller than the actual value of pi. We had to go one more digit than is displayed by MATLAB in order to match the actual value.
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!