I am trying to write a genetic algorithm code for my optimization problem, but when I run the code for loops are not executed! I don't get the reason. Any help would be appreciated.
part of my code from beginning to the end of second for loop is:
clc
clear all
% rand('state',0);
starttime=datestr(now);
total_t=180;
%----------------------------------GA Setup--------------------------------
% Setup the GA
%ff=fitnessV; % objective function
npar=3; % number of optimization variables
%
%-----------------------------Stopping criteria----------------------------
maxit=50; % max number of iterations
mincost=.01; % minimum cost
%
%--------------------Specifying the parameters of GA-----------------------
selection=0.5; % fraction of population kept
popsize=100;%size of the population
keep=selection*popsize;
M=ceil((popsize-keep)/2); % number of matings
odds=1;
for ii=2:keep
odds=[odds ii*ones(1,ii)];
end
odds=keep+1-odds;
Nodds=length(odds);
mutrate=0.1; % mutation rate
%
%------------------------Creat the initial population----------------------
iga=0; % generation counter initialized
pop=rand(popsize,npar); % random population of continuous values
for ii=1:pop
for j=1:popsize
if pop(ii,j)>n || pop(ii,j)