Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016년 5월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by