What variable type is "Population" in a Genetic Algorthim and how to store individuals with long genomes?

2 ビュー (過去 30 日間)
I am coding a genetic algorithm where each individual will be made up of several points, ie
Individual1 = [1 2 3 4 5];
Individual2 = [6 7 8 9 10];
on through all the indviduals. I have a custom creation function for the initial population, but I am unsure if I can store each individual in a seperate cell or row, or what to do. The documentation also seemed to say to call the fitness function in my creation function which I don't fully understand, which leads to another question, does my fitness function just output the fitness, or does it need to output the population and fitness in a matrix? Feel free to ask more questions to clarify, this is my first time asking one.
Here is the Documentation on creation functions
function Population = myfun(GenomeLength, FitnessFcn, options)
I am interpreting GenomeLength to be the number of points in each individual and assume that my output Population will look something like follows-
%for k number of individuals
k = 10;
for i = 1:k
Population{i} = IndividualGeneration(GenomeLength); %calls the function for generating the individual and stores that individual in a cell in Population
end
In my mind this ouputs something like this- Population = {1 2 3 4 5}, {6 7 8 9 10}, with each individual in a cell. can the GA work with this format?

採用された回答

Alan Weiss
Alan Weiss 2022 年 5 月 16 日
Yes, it is possible to use ga with a custom population. For an example see Custom Data Type Optimization Using the Genetic Algorithm.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 件のコメント
Jacob Child
Jacob Child 2022 年 5 月 16 日
編集済み: Jacob Child 2022 年 5 月 16 日
Thank you for that link! Just to make sure I understand what I am reading here is a summary-
ga is made to work (as a default) with the population being a matrix of numbers ie Population = [1 2 3] and each individual has just 1 number.
If I want an individual to contain more than just one number (as is my case), I must provide custom creation, crossover, and mutation functions.
I am trying to avoid that as it is a decent amount of extra work, so can I put each individual in a column ie
3 individuals of 2 points (GenomeLength) would be
Population =
1 2 3
4 5 6
With individual1 = [1; 4]
Alan Weiss
Alan Weiss 2022 年 5 月 17 日
You can put each individual into a ROW and use Mixed Integer ga Optimization for an integer-valued population.
Alan Weiss
MATLAB mathematical toolbox documentation

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by