How to write selection function in genetic algorithm(Global Optimization Toolbox: ga)
2 views (last 30 days)
I have some problem to use the genetic algorithm.
I want to use customized selection function, but I can only see error message: Index exceeds matrix dimensions
Here is my code below:
function parents=AGAselection(expectation, nParents, options)
% nParents= the number of parents
% A= sorted expectation
% B= expectation of nParents top parents
% GBparents= global best parents
%% Sorting accordance with fitness value
%% Select Global Best
%% Select Parents Randomly
Please check my code and tell me what is the problem.
Alan Weiss on 19 Feb 2019
I am not sure, but I am suspicious of the line
What makes you think that expectation==B(1,1) has just one element?
MATLAB mathematical toolbox documentation