Cohort Intelligence MATLAB Code for Optimization of Micro Drilling Process

Choudhary, H. (2007). Workshop Technology. Media promoters and publishers, 10, 608-620.

MATLAB Code of Cohort Intelligence Algorithm with Alienation variation for Optimization of Burr height (Bh) and Burr Thickness (Bt) of Micro Drilling Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear allclcticc = 5;  % number of candidatesn = 2;   % number of dimensionsupper_bound = [2500 4];     lower_bound = [1000 1];
max_iterations = 1500;for cnt_runs = 1:1x = (upper_bound - lower_bound).*rand(c,n) + lower_bound; % random value generationrange = upper_bound - lower_bound;                       % original range calculationcnt_iterations =1;        while (cnt_iterations <= max_iterations) % loop for max iterations%            if cnt_iterations < 200               r = 0.99;%            else%                r = 0.8;%            end                       for cnt_candi = 1:c            Fun(cnt_candi,:)= Ra_turn(x(cnt_candi,1:n)); % call objective function here          end                 inverse_F = Fun.^-1;                     % 1/fxn         denominator_pc = sum(inverse_F,1);     %denominator calucated((1/fx(c1)+...+1/fx(cn)) for probability calculation                 for cnt_pc = 1:c            prob1(cnt_pc,1) = inverse_F(cnt_pc,1)/denominator_pc; % probability pc1,...,pcm         end                 pcsum = sum(prob1);  % checking cummulative sum = 1?                         [prob , c_follow1] = sort(prob1,'descend');         for cnt_candi = 1:c            c_unfollow(cnt_candi) = RouletteWheelSelection(prob1); %  Roulette Wheel            c_unfollow1(cnt_candi) = c_unfollow(cnt_candi);        end         for cnt_candi = 1:c                          c_unfollow1(cnt_candi)=[];             msize = numel(c_unfollow1);             idx = randperm(msize);             c_follow(cnt_candi)= c_unfollow1(idx(1:1));             c_unfollow1= c_unfollow;%             ww(cnt_candi,:) =  find(cnt_candi~=c_unfollow(cnt_candi));          end                 [M,I] = min(Fun);            Fbest(1,:) = M(1, :);            xvect_best(:,:) = x(I(1),:);                   % x vector for all best         new_matrix = x(c_follow,:); % new matrix generation          range = r*range;                for cnt_column = 1:n            if abs(range(cnt_column))> 1e-8               new_range =  range/2;              else              new_range =  1e-8;              end            end              for cnt_row = 1:c            for cnt_column = 1:n                 new_lower_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)- new_range(cnt_column);                 new_upper_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)+ new_range(cnt_column);            end               end              for cnt_row = 1:c            for cnt_column = 1:n                 if new_lower_bound(cnt_row,cnt_column) < lower_bound(1,cnt_column)                      new_lower_bound(cnt_row,cnt_column) = lower_bound(1,cnt_column);                 end                     if new_upper_bound(cnt_row,cnt_column) > upper_bound(1,cnt_column)                     new_upper_bound(cnt_row,cnt_column) = upper_bound(1,cnt_column) ;                 end              end                end                  x = (new_upper_bound -new_lower_bound).*rand(c,n) + new_lower_bound;        x(c,:) = xvect_best;        if (cnt_iterations <= max_iterations)               function_all(:,cnt_iterations) = abs(Fbest);               cnt_all (cnt_iterations) = cnt_iterations;               x_all(:,:,cnt_iterations) =  x;               end               hold on;               cnt_iterations = cnt_iterations + 1;    end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     figure(1)%                  xlabel('Learning attempts','FontSize',12)%                  ylabel('Behavior','FontSize',12)%                plot(cnt_all,function_all(1,:),'k*');%                plot(cnt_all,function_all(2,:),'ko');%                plot(cnt_all,function_all(3,:),'k+');%                plot(cnt_all,function_all(4,:),'k.');%                plot(cnt_all,function_all(5,:),'ks');%                   legend ('candi1','candi2','candi3','candi4','candi5');% %                %pause(2);% %                hold on;%            %  % %     end

toc;
time_elapsed = toc;
 end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%MATLAB Code of Cohort Intelligence Algorithm with FOllow Best variation for Optimization of Burr height (Bh) and Burr Thickness (Bt) of Micro Drilling Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear allclcticc = 5;  % number of candidatesn = 2;   % number of dimensionsupper_bound = [2500 4];     lower_bound = [1000 1];
max_iterations = 700;for cnt_runs = 1:1x = (upper_bound - lower_bound).*rand(c,n) + lower_bound; % random value generationrange = upper_bound - lower_bound;                       % original range calculationcnt_iterations = 1;        while (cnt_iterations <= max_iterations) % loop for max iterations%            if cnt_iterations < 20%               r = 0.99;% %            else              r = 0.95;%            end                       for cnt_candi = 1:c            Fun(cnt_candi,:)= Ra_turn(x(cnt_candi,1:n)); % call objective function here          end                 inverse_F = Fun.^-1;                     % 1/fxn         denominator_pc = sum(inverse_F,1);     %denominator calucated((1/fx(c1)+...+1/fx(cn)) for probability calculation                 for cnt_pc = 1:c            prob1(cnt_pc,1) = inverse_F(cnt_pc,1)/denominator_pc; % probability pc1,...,pcm         end                 pcsum = sum(prob1);  % checking cummulative sum = 1?         for cnt_candi = 1:c            c_follow(cnt_candi) = RouletteWheelSelection(prob1); %  Roulette Wheel         end                 [prob , c_follow1] = sort(prob1,'ascend');        for i = 1:c            c_follow(i)= c_follow1(c);        end                    [M,I] = min(Fun);            Fbest(1,:) = M(1, :);            xvect_best(:,:) = x(I(1),:);                     new_matrix = x(c_follow,:); % new matrix generation          range = r*range;                for cnt_column = 1:n            if abs(range(cnt_column))> 1e-16               new_range =  range/2;              else              new_range =  1e-16;              end            end              for cnt_row = 1:c            for cnt_column = 1:n                 new_lower_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)- new_range(cnt_column);                 new_upper_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)+ new_range(cnt_column);            end               end              for cnt_row = 1:c            for cnt_column = 1:n                 if new_lower_bound(cnt_row,cnt_column) < lower_bound(1,cnt_column)                      new_lower_bound(cnt_row,cnt_column) = lower_bound(1,cnt_column);                 end                     if new_upper_bound(cnt_row,cnt_column) > upper_bound(1,cnt_column)                     new_upper_bound(cnt_row,cnt_column) = upper_bound(1,cnt_column) ;                 end              end                end                  x = (new_upper_bound -new_lower_bound).*rand(c,n) + new_lower_bound;                        if (cnt_iterations <= max_iterations)               function_all(:,cnt_iterations) = abs(Fbest);               cnt_all (cnt_iterations) = cnt_iterations;               x_all(:,:,cnt_iterations) =  x;               end               hold on;               cnt_iterations = cnt_iterations + 1;    end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     figure(1)%                  xlabel('Learning attempts','FontSize',12)%                  ylabel('Behavior','FontSize',12)%                plot(cnt_all,function_all(1,:),'k*');%                plot(cnt_all,function_all(2,:),'ko');%                plot(cnt_all,function_all(3,:),'k+');%                plot(cnt_all,function_all(4,:),'k.');%                plot(cnt_all,function_all(5,:),'ks');%                   legend ('candi1','candi2','candi3','candi4','candi5');% %                %pause(2);% %                hold on;%            %  % %     end

toc;
time_elapsed = toc;
 end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MATLAB Code of Cohort Intelligence Algorithm with FOllow better for Optimization of Burr height (Bh) and Burr Thickness (Bt) of Micro Drilling Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear allclcticc = 5;  % number of candidatesn = 2;   % number of dimensionsupper_bound = [2500 4];     lower_bound = [1000 1];
max_iterations = 1100;for cnt_runs = 1:1x = (upper_bound - lower_bound).*rand(c,n) + lower_bound; % random value generationrange = upper_bound - lower_bound;                       % original range calculationcnt_iterations =1;        while (cnt_iterations <= max_iterations) % loop for max iterations%            if cnt_iterations < 20%               r = 0.99;% %            else              r = 0.99;%            end                       for cnt_candi = 1:c            Fun(cnt_candi,:)= Ra_turn(x(cnt_candi,1:n)); % call objective function here          end                 inverse_F = Fun.^-1;                     % 1/fxn         denominator_pc = sum(inverse_F,1);     %denominator calucated((1/fx(c1)+...+1/fx(cn)) for probability calculation                 for cnt_pc = 1:c            prob1(cnt_pc,1) = inverse_F(cnt_pc,1)/denominator_pc; % probability pc1,...,pcm         end                 pcsum = sum(prob1);  % checking cummulative sum = 1?         for cnt_candi = 1:c            c_follow(cnt_candi) = RouletteWheelSelection(prob1); %  Roulette Wheel         end                 [prob , c_follow1] = sort(prob1,'ascend');        for i = 1:c-1            c_follow(i)= c_follow1(i+1);        end            for i = c             c_follow(i)= c_follow1(i);          end         [M,I] = min(Fun);            Fbest(1,:) = M(1, :);            xvect_best(:,:) = x(I(1),:);                   % x vector for all best         new_matrix = x(c_follow,:); % new matrix generation          range = r*range;                for cnt_column = 1:n            if abs(range(cnt_column))> 1e-16               new_range =  range/2;              else              new_range =  1e-16;              end            end              for cnt_row = 1:c            for cnt_column = 1:n                 new_lower_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)- new_range(cnt_column);                 new_upper_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)+ new_range(cnt_column);            end               end              for cnt_row = 1:c            for cnt_column = 1:n                 if new_lower_bound(cnt_row,cnt_column) < lower_bound(1,cnt_column)                      new_lower_bound(cnt_row,cnt_column) = lower_bound(1,cnt_column);                 end                     if new_upper_bound(cnt_row,cnt_column) > upper_bound(1,cnt_column)                     new_upper_bound(cnt_row,cnt_column) = upper_bound(1,cnt_column) ;                 end              end                end                  x = (new_upper_bound -new_lower_bound).*rand(c,n) + new_lower_bound;                      if (cnt_iterations <= max_iterations)               function_all(:,cnt_iterations) =  abs(Fbest);               cnt_all (cnt_iterations) = cnt_iterations;               x_all(:,:,cnt_iterations) =  x;               end               hold on;               cnt_iterations = cnt_iterations + 1;    end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     figure(1)%                  xlabel('Learning attempts','FontSize',12)%                  ylabel('Behavior','FontSize',12)%                plot(cnt_all,function_all(1,:),'k*');%                plot(cnt_all,function_all(2,:),'ko');%                plot(cnt_all,function_all(3,:),'k+');%                plot(cnt_all,function_all(4,:),'k.');%                plot(cnt_all,function_all(5,:),'ks');%                   legend ('candi1','candi2','candi3','candi4','candi5');% %                %pause(2);% %                hold on;%            %  % %     end

toc;
time_elapsed = toc;
 end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MATLAB Code of Cohort Intelligence Algorithm with Roulette Wheel for Optimization of Burr height (Bh) and Burr Thickness (Bt) of Micro Drilling Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear allclcticc = 5;  % number of candidatesn = 2;   % number of dimensionsupper_bound = [2500 4];     lower_bound = [1000 1];r = 0.99;max_iterations = 500;for cnt_runs = 1:1x = (upper_bound - lower_bound).*rand(c,n) + lower_bound; % random value generationrange = upper_bound - lower_bound;                       % original range calculationcnt_iterations = 1;        while (cnt_iterations <= max_iterations) % loop for max iterations                     for cnt_candi = 1:c            Fun(cnt_candi,:)= Ra_turn(x(cnt_candi,1:n)); % call objective function here          end                 inverse_F = Fun.^-1;                     % 1/fxn         denominator_pc = sum(inverse_F,1);     %denominator calucated((1/fx(c1)+...+1/fx(cn)) for probability calculation                 for cnt_pc = 1:c            prob(cnt_pc,1) = inverse_F(cnt_pc,1)/denominator_pc; % probability pc1,...,pcm         end                 pcsum = sum(prob);  % checking cummulative sum = 1?                            for cnt_candi = 1:c            c_follow(cnt_candi) = RouletteWheelSelection(prob);          end                 [M,I] = min(Fun);            Fbest(1,:) = M(1, :);            xvect_best(:,:) = x(I(1),:);                   % x vector for all best         new_matrix = x(c_follow,:); % new matrix generation          range = r*range;                for cnt_column = 1:n            if abs(range(cnt_column))> 1e-16               new_range =  range/2;              else              new_range =  1e-16;              end            end              for cnt_row = 1:c            for cnt_column = 1:n                 new_lower_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)- new_range(cnt_column);                 new_upper_bound(cnt_row,cnt_column) = new_matrix(cnt_row,cnt_column)+ new_range(cnt_column);            end               end              for cnt_row = 1:c            for cnt_column = 1:n                 if new_lower_bound(cnt_row,cnt_column) < lower_bound(1,cnt_column)                      new_lower_bound(cnt_row,cnt_column) = lower_bound(1,cnt_column);                 end                     if new_upper_bound(cnt_row,cnt_column) > upper_bound(1,cnt_column)                     new_upper_bound(cnt_row,cnt_column) = upper_bound(1,cnt_column) ;                 end              end                end                  x = (new_upper_bound -new_lower_bound).*rand(c,n) + new_lower_bound;        x(c,:) = xvect_best;                                    if (cnt_iterations <= max_iterations)               function_all(:,cnt_iterations) = abs(Fbest);               cnt_all (cnt_iterations) = cnt_iterations;               x_all(:,:,cnt_iterations) =  x;               end               hold on;               cnt_iterations = cnt_iterations + 1;    end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     if (rem(cnt_iterations,1)==0)%         stop_1=1;%     end%     figure(1)%                  xlabel('Learning attempts','FontSize',12)%                  ylabel('Behavior','FontSize',12)%                plot(cnt_all,function_all(1,:),'k*');%                plot(cnt_all,function_all(2,:),'ko');%                plot(cnt_all,function_all(3,:),'k+');%                plot(cnt_all,function_all(4,:),'k.');%                plot(cnt_all,function_all(5,:),'ks');%                   legend ('candi1','candi2','candi3','candi4','candi5');% %                %pause(2);% %                hold on;%            %  % %     end

toc;
time_elapsed = toc;
 end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MATLAB Code of Multi-Cohort Intelligence Algorithm  for Optimization of Burr height (Bh) and Burr Thickness (Bt) of Micro Drilling Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Multi-Cohort Intelligence: An Intra- and Inter-group Learning and Competing Behavior %%%% Apoorva Shastri and Anand J Kulkarni %%
% -------------------------------------------------------------------------% INITIALIZATION% -------------------------------------------------------------------------



close allclear allclcc = 5; % number of candidates     n = 2; % number of variablesk = 3; % number of cohortsupper_bound1 = 2500;  upper bound of variable 1    lower_bound1 = 1000;  lower bound of variable 1 upper_bound2 = 4;     upper bound of variable 2 lower_bound2 = 1;     lower bound of variable 2 
r = 0.99;      % interval reduction factormax_iterations = 200; tk = 10; %quality variations for nonpool tpool = 5; %quality variations for poolZtkpool = 15;
for cnt_runs = 1:1    x1 = (upper_bound1 -lower_bound1).*rand(c,1,k) + lower_bound1; % random value generationx2 = (upper_bound2 -lower_bound2).*rand(c,1,k) + lower_bound2; % random value generationx = cat(2,x1,x2);
range1 = upper_bound1 -lower_bound1; % original range calculationrange2 = upper_bound2 -lower_bound2;  % original range calculation
upper_bound = cat(2,upper_bound1,upper_bound2);lower_bound = cat(2,lower_bound1,lower_bound2);tic; for cnt_iterations=1:max_iterations % creating a pool of best candidates      for cnt_cohort = 1:k            for cnt_candi = 1:c              Fun(cnt_candi,:,cnt_cohort) = BH_05mm(x(cnt_candi,:,cnt_cohort));% call objective function here            end%             z(cnt_cohort)= min(Fun(cnt_candi,:,cnt_cohort));      end     
            [M,I] = min(Fun);            Fbest = M;                        pool(1,:) = M(1, :);                      poolZ = pool';            In(1,:) = I(1, :);             for cnt_cohort = 1:k                xvect_best1(:,:,cnt_cohort) = x(In(1,cnt_cohort),:,cnt_cohort);                   % x vector for all best                                          [x_nonpool(:,:,cnt_cohort),PS]= removerows(x(:,:,cnt_cohort),[I(cnt_cohort)]);                                                     [fun_non_pool_X(:,:,cnt_cohort),PS]= removerows(Fun(:,:,cnt_cohort),[I(cnt_cohort)]);             end                                                               A(:,:) =  xvect_best1(1, :);               xvect_best = vec2mat(A,n);%  xvect_best_final cell generated for concatenation
 % -------------------------------------------------------------------------% -------------------------------------------------------------------------% procedure for tk% ------------------------------------------------------------------------- for cnt_cohort = 1:k      inverse_F(:,:,cnt_cohort) = fun_non_pool_X(:,:,cnt_cohort).^-1;                     % 1/fxn       denominator_pc(:,1,cnt_cohort) = sum(inverse_F(:,:,cnt_cohort),1);     %denominator calucated((1/fx(c1)+...+1/fx(cn)) for probability calculation              prob(:,1,cnt_cohort) = inverse_F(:,1,cnt_cohort)/denominator_pc(:,1,cnt_cohort); % probability pc1,...,pcm      %      pcsum = cumsum(prob(cnt_cohort));  % checking cummulative sum = 1?     
     for cnt_candi = 1:c-1        c_follow(cnt_candi) = RouletteWheelSelection(prob(:,1,cnt_cohort)); %  Roulette Wheel     end             nmatrix = x_nonpool(c_follow,:,cnt_cohort); % new matrix generation    new_matrix{1,cnt_cohort} = nmatrix; end %    display(new_matrix(cnt_cohort))         range1 = r * range1; % range reduced by reduction factor r       range2 = r * range2;             new_range1 =  range1/2;       new_range2 =  range2/2;                     new_range = cat(2,new_range1,new_range2);     new_range(new_range <= 10^-22)= 10^-10;
for cnt_cohort = 1: k    for cnt_candi = 1:c-1        for cnt_variables = 1:n            new_upper_bound_tk = new_matrix{cnt_cohort}(:,cnt_variables)+ new_range(:,cnt_variables);                                                                                      new_lower_bound_tk = new_matrix{cnt_cohort}(:,cnt_variables)- new_range(:,cnt_variables);                              new_upper_bound_tk(new_upper_bound_tk > new_range(:,cnt_variables)) = upper_bound(:,cnt_variables);                  new_lower_bound_tk(new_lower_bound_tk < new_range(:,cnt_variables)) = lower_bound(:,cnt_variables);
                                  for cnt_tk = 1:tk                   n_x(cnt_tk,cnt_variables)= (new_upper_bound_tk(cnt_candi,1)- new_lower_bound_tk(cnt_candi,1)) * rand(1,1) +  new_lower_bound_tk(cnt_candi,1);                 end        end
            x_tk{cnt_cohort} = n_x;

    end  end     % -------------------------------------------------------------------------% -------------------------------------------------------------------------% procedure for tpool% -------------------------------------------------------------------------for cnt_cohort = 1:k      inverse_F_poolZ = poolZ.^-1;                     % 1/fxn       denominator_pc_tpoolZ = sum(inverse_F_poolZ,1);     %denominator calucated((1/fx(c1)+...+1/fx(cn)) for probability calculation              prob_tpoolZ= inverse_F_poolZ/denominator_pc_tpoolZ; % probability pc1,...,pcm          for cnt_candi = 1:c-1        c_follow_tpoolZ(cnt_candi) = RouletteWheelSelection(prob_tpoolZ); %  Roulette Wheel    end%         nmatrix_tpool = xvect_best(:,:,c_follow_tpoolZ);        nmatrix_tpool = xvect_best(c_follow_tpoolZ,:);% new matrix generation                new_matrix_tpool{1,cnt_cohort} = nmatrix_tpool;     end     %    display(new_matrix(cnt_cohort))
      for cnt_cohort = 1: k    for cnt_candi = 1:c-1        for cnt_variables = 1:n            new_upper_bound_tpool = new_matrix_tpool{cnt_cohort}(:,cnt_variables)+ new_range(:,cnt_variables);                                                                                   new_lower_bound_tpool = new_matrix_tpool{cnt_cohort}(:,cnt_variables)- new_range(:,cnt_variables);                               new_upper_bound_tpool(new_upper_bound_tpool  > new_range(:,cnt_variables)) = upper_bound(:,cnt_variables);                   new_lower_bound_tpool( new_lower_bound_tpool < new_range(:,cnt_variables)) = lower_bound(:,cnt_variables);                                                   for cnt_tpool = 1:tpool                   x_tp(cnt_tpool,cnt_variables)= (new_upper_bound_tpool(cnt_candi,1)- new_lower_bound_tpool(cnt_candi,1)) * rand(1,1) +  new_lower_bound_tpool(cnt_candi,1);                 end                        end                      x_tpool{cnt_cohort} = x_tp;    end  end

           for cnt_cohort = 1:k               for cnt_candi = 1:c-1                 x_tpool_tk{cnt_candi,cnt_cohort} = cat(1,x_tk{1,cnt_cohort}, x_tpool{1,cnt_cohort});               end           end
               for cnt_cohort = 1:k               for cnt_candi = 1:c-1                          y(:,:,cnt_cohort)= x_tpool_tk{cnt_candi,cnt_cohort};      for cnt_tkpool = 1:tkpool       Fun1(cnt_tkpool,:) = BH_05mm(y(cnt_tkpool,:));                    end                                               [Mf,If] = min(Fun1);             Fmin(cnt_candi,:,cnt_cohort) = Mf;              xbest = (y(If,:,cnt_cohort));             xi(cnt_candi,:,cnt_cohort) = xbest;                end      end           for cnt_cohort = 1:k          F_x(:,:,cnt_cohort) = cat(1, Fmin(:,:,cnt_cohort), Fbest(:,:,cnt_cohort));     end                     A1(:,:) =  F_x(:, :);            Fun1_all = reshape(A1,tkpool,1);             [f,I] = min(F_x);
                        f_final(1,:) = f(1, :);                       f_final_out =  f_final'
             minima = min(f_final_out)                          for cnt_cohort = 1:k          x(:,:,cnt_cohort) = cat(1, xi(:,:,cnt_cohort), xvect_best1(:,:,cnt_cohort));             end                           function_all(:,cnt_iterations) =  f_final_out;           function_all_plot(:,cnt_iterations) =  Fun1_all;                                   hold on;          cnt_itera_p(cnt_iterations)= cnt_iterations;                   end                  %% Multi-CI convergence plot          for cnt_1 = 1:5   fun_cohort1(cnt_1,:)= function_all_plot(cnt_1,:) end  for cnt_2 = 6:10   fun_cohort2(cnt_2,:)= function_all_plot(cnt_2,:) end  for cnt_3 = 11:15    fun_cohort3(cnt_3,:)= function_all_plot(cnt_3,:)  end   if (rem(cnt_iterations,1) == 0)               stop_1 = 1;            end
         if (rem(cnt_iterations,1) == 0)            stop_1 = 1;        end
           figure(1)           xlabel('Learning attempts','FontSize',12)           ylabel('Function values','FontSize',12)
 plot(cnt_itera_p,function_all(1,:),'k'); legend('cohort1'); plot(cnt_itera_p,function_all(2,:),'k--'); legend('cohort2'); plot(cnt_itera_p,function_all(3,:),'k:'); legend('cohort3'); toc; time_elapsed = toc;
endend
%%%%%%%%%%%%%%%%%%%%%%%% Roulette Wheel Selection Code %%%%%%%%%%%%%%%%%%%%%%%%
function choice = RouletteWheelSelection(prob) total = cumsum(prob); p = rand() * total(end); leader = -1; for index = 1:length(total)   if (total(index) > p)     leader = index;     break;   end end choice = leader;
%%%%%%%%%%%%%%%%%%% Objective Functions %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% Burr Thickness %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.5mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BT05mm(x)y1 = 90.57-0.049*x(1)-27.12*x(2)+(1.32*10^-5)*x(1)*x(1)+5.54*x(2)*x(2);end
%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.6mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BT06mm(x)y1 = 35.34-0.019*x(1)-0.59*x(2)+(6.44*10^-6)*x(1)*x(1)+0.51*x(2)*x(2);end
%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.8mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BT08mm(x)y1 = 59.79-0.024*x(1)-11.3*x(2)+(7.78*10^-6)*x(1)*x(1)+2.18*x(2)*x(2);end
%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.9mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BT09mm(x)y1 = 80.07-0.040*x(1)-14.81*x(2)+(1.516*10^-5)*x(1)*x(1)+4.65*x(2)*x(2);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% Burr Height %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.5mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BH05mm(x)y1 = 420.94-0.234*x(1)-99.91*x(2)+(6.55*10^-5)*x(1)*x(1)+22.152*x(2)*x(2);end
%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.6mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BH06mm(x)y1 = 369.67-0.028*x(1)-156.79*x(2)+(6.64*10^-6)*x(1)*x(1)+23.162*x(2)*x(2);end
%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.8mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BH08mm(x)y1 = 106.116+0.13*x(1)-6.62*x(2)+(1.49*10^-6)*x(1)*x(1)+4.75*x(2)*x(2);end
%%%%%%%%%%%%%%%%%%%%% Tool Dia 0.9mm %%%%%%%%%%%%%%%%%%%%%%%function y1 = BH09mm(x)y1 = 450.7-0.09*x(1)-34.48*x(2)+(2.34*10^-5)*x(1)*x(1)+5.03*x(2)*x(2);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%