function [TV,fitness]=newoffspring_TLBO1(population,popsize,ind,fitness,k,maxv,minv,h)
%f=1.8;
% [m n]=size(Data);
% sortdata=sort(Data);
% maxv=sortdata(m,:);
% minv=sortdata(1,:);
meanpop=mean(population);
[np,pp]=size(population);
popnew=zeros(np,k);
TV=zeros(np,k);

for i=1:popsize
    f=round(2+rand(1));
    popnew(i,:)=population(i,:)+rand(1)*(population(ind,:)-f*meanpop);
    
   % for cc=0:k-1
            for j=1:k
                if popnew(i,j)< minv
                    popnew(i,j)=minv;
                end
                  if popnew(i,j)> maxv
                    popnew(i,j)=maxv;
                end  
            end
   % end
%     for j=:n
%         if popnew(i,j)<minv(j)
%             popnew(i,j)=minv(j);
%         end
%         if popnew(i,j)>maxv(j)
%             popnew(i,j)=maxv(j);
%         end
%     end
   % popnew(i,:)=round(popnew(i,:));
end
%popnew=step2(popnew,np,k);
popnewfitness=[];
for i=1:popsize
%     [cluster,cid]=cluster_create(Data,popnew,k,i);    
%     vv1=cs(Data,cluster,k);%csmeasure(Data,popnew(i,:),m,n,k);
%     popnewfitness=[popnewfitness vv1];
[hcTV,cid]=histc_tlbo(ind,popnew(j,:),maxv,h,k);
         popnewfitness(i)=valid_cs_tlbo(ind,popnew,hcTV,h,maxv,1,k,j);
  %popnewfitness(i)=fuzzymeasure(Data,popnew,m,n,k,i,origclust);
        if fitness(i)<popnewfitness(i)
            population(i,:)=popnew(i,:);
            fitness(i)=popnewfitness(i);
        end
end
for i=1:popsize
    randvec=zeros(1,2);
    v=randperm(popsize);
    kk=1;
    while kk<=2
      if v(1)~=i
          randvec(kk)=v(1);
          kk=kk+1;
      end
      v=v(1,2:length(v));
    end
    if fitness(1,randvec(1))< fitness(1,randvec(2))
        TV(i,:)=population(i,:)+rand(1)*(population(randvec(1),:)-population(randvec(2),:));
    else
        TV(i,:)=population(i,:)+rand(1)*(population(randvec(2),:)-population(randvec(1),:));
    end
   
   % for cc=0:k-1
            for j=1:k
                if TV(i,j)< minv
                    TV(i,j)=minv;
                end
                  if TV(i,j)> maxv
                    TV(i,j)=maxv;
                  end  
            end
   % end
%     for j=1:n
%         if TV(i,j)<minv(j)
%             TV(i,j)=minv(j);
%         end
%         if TV(i,j)>maxv(j)
%             TV(i,j)=maxv(j);
%         end
%     end
      %TV(i,:)=round(TV(i,:));         
end
