Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Firas Al-Kharabsheh
Firas Al-Kharabsheh le 8 Mai 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by