Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

if i have a code for genetic algorithm but its need some alter how to do them?

1 view (last 30 days)
i have this code for genetic algorithm
% i need a minimum value for the fitness function
%nPop = 10 , MaxIt = 100
% pc = 0.6; % Crossover Percentage
% nc = 2*round(pc*nPop/2); % Number Of offsprings (also Parents)
%%generate populations
Matrix_pop = [];
val = [];
for k=1 : nPop % 10 is the population size
Matrix_pop{k} = randi ([0 1] , 10,10) % create a binary (10,10) matrix
fit = sum(sum(Matrix_pop{k})); % fitness function is compute the total number of ones in Matrix.
val(k) = fit ;
end
value = sort(val , 'ascend');
%%Main algorithm
for it=1:MaxIt %maximum number of iteration
for i=1: nc/2 % number of parent
for k=1 : value.length
i1 = ([1 k]);
i2 = ([1 k+1]);
p1=Matrix_pop{i1};
p2=Matrix_pop{i2};
after this how can i perform the crossover and mutation and create a new population to get the minimum value for the fitness function and after that the solution will display as the matrix which have the minimum value ????
can any one give me help , thank you

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!