
function NewChrom = mute(OldChrom,Pro, Cc)

% get population size (Nind) and chromosome length (Lind)
[Nc, Lc] = size(OldChrom) ;

% obtain the mutation position matrix. In this matrix, entry value '1' means mutation cocurring at 
% this position.
% mutate one chromosome each time
for i = 1: Nc

muvector = rand(1,Lc)<Pro;

% perform mutation 
NewChrom(i, :) = OldChrom(i, :) + muvector;

for j = 1:Lc
   if NewChrom(i,j) == 2
       NewChrom(i,j) = 0;
   end
end

if sum(NewChrom(i,1:Cc(1))) == 0 && Cc(1) ~= 0
    
    NewChrom(i, randint(1,1,[1,Cc(1)])) = 1;
    
end

   
end