How do i insert my own initial population in genetic algorithm toolbox?
조회 수: 12 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2018년 2월 10일
댓글 수: 7
Gustavo Lunardon
2022년 9월 13일
편집: Gustavo Lunardon
2022년 9월 13일
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
2022년 9월 13일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!