custom selection functions for genetic algorithm

3 ビュー (過去 30 日間)
Justin
Justin 2020 年 4 月 10 日
コメント済み: Ameer Hamza 2020 年 4 月 10 日
I am brand new to genetic algorithms. I am trying to learn by reproducing the results I found in a paper. I am getting hung up on the selection method. The paper uses normalized geometric selection. It looks like this in not one of the canned methods available and that I need to write a custom function. I have an equation and most of the parameters that I need. The onlything I think I need is the rank of the individual. My big issue is that I am not clear on how to pass this to my function. I took a stab at it with the below function but this failed. I dont know the syntax for passing parameters to and from my function for this instance. I appreciate any help. I suspect the solution is very simple but I am really confused.
function [S] = Selection(r)
p = 60; % population size
q = 0.05; % probablity of selection
R = r; % rank of individual
q = p/(1-(1-q)^p);
S = q*(1-q)^(R-1); % normalized geometric equation
  2 件のコメント
darova
darova 2020 年 4 月 10 日
Too much text. Im not that good at english. Do you have a question?
Justin
Justin 2020 年 4 月 10 日
Need help with syntax for custon selection function in genatic algorithm. I need to get parameter for rank into the function. I also need to output information in correct form.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 10 日
The selection function for ga must have the following signature
function parents = myfun(expectation, nParents, options)
The explanation of the input and output variables are given here: https://www.mathworks.com/help/gads/genetic-algorithm-options.html#f6593. Note that the output variables 'parents' must have the dimension of 1xnParents. To see an example of selection function, check the code of one of the MATLAB's built-in selection function
edit selectionremainder
  8 件のコメント
Justin
Justin 2020 年 4 月 10 日
This is exactly what I want. And your suggestion seems to be working. The ga came up with values very close to what I was trying reproduce in the paper. Thank you so much for your help.
Ameer Hamza
Ameer Hamza 2020 年 4 月 10 日
I am glad to be of help.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by