Cohort Intelligence MATLAB Code for Optimization of Micro-Turning Process

MATLAB Code of Cohort Intelligence Algorithm with Alienation variation for Optimization of Surface Roughness (Ra) and Tool Wear (fb) of Micro Turning Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear allclcticc = 5;  % number of candidatesn = 3;   % number of dimensionsupper_bound = [37 15 70];     lower_bound = [25 5 30];
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 Surface Roughness (Ra) and Tool Wear (fb) of Micro Turning Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear allclcticc = 5;  % number of candidatesn = 3;   % number of dimensionsupper_bound = [37 15 70];     lower_bound = [25 5 30];
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 variation for Optimization of Surface Roughness (Ra) and Tool Wear (fb) of Micro Turning Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear allclcticc = 5;  % number of candidatesn = 3;   % number of dimensionsupper_bound = [37 15 70];     lower_bound = [25 5 30];
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 variation for Optimization of Surface Roughness (Ra) and Tool Wear (fb) of Micro Turning Process
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear allclcticc = 5;  % number of candidatesn = 3;   % number of dimensionsupper_bound = [37 15 70];     lower_bound = [25 5 30];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 Surface Roughness (Ra) and Tool Wear (fb) of Micro Turning 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 = 3; % number of variablesk = 3; % number of cohortsupper_bound1 = 37; % upper bound of variable 1     lower_bound1 = 25;  % lower bound of variable 1upper_bound2 = 15;  % upper bound of variable 2    lower_bound2 = 5; % lower bound of variable 2upper_bound3 = 70;   % upper bound of variable 3    lower_bound3 = 30;   % lower bound of variable 3r = 0.99;            % interval reduction factormax_iterations = 700;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;% variable value generationx2 = (upper_bound2 -lower_bound2).*rand(c,1,k) + lower_bound2;% variable value generationx3 = (upper_bound3 -lower_bound3).*rand(c,1,k) + lower_bound3;% variable value generationx = cat(2,x1,x2,x3);range1 = upper_bound1 -lower_bound1; % original range calculation for variable 1range2 = upper_bound2 -lower_bound2; % original range calculation for variable 2range3 = upper_bound3 -lower_bound3; % original range calculation for variable 3
upper_bound = cat(2,upper_bound1,upper_bound2,upper_bound3);lower_bound = cat(2,lower_bound1,lower_bound2,lower_bound3);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) = Ra_turn(x(cnt_candi,:,cnt_cohort))% call objective function here            end      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 candidates                        [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           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  %% range reduced by reduction factor r        range1 = r * range1;        range2 = r * range2;       range3 = r * range3;              new_range1 =  range1/2;       new_range2 =  range2/2;       new_range3 =  range3/2;                new_range = cat(2,new_range1,new_range2,new_range3);     new_range(new_range <= 10^-22)= 10^-30;
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 upper bound generation                                                                                   new_lower_bound_tk = new_matrix{cnt_cohort}(:,cnt_variables)- new_range(:,cnt_variables); %new lower bound generation                              new_upper_bound_tk(new_upper_bound_tk > upper_bound(:,cnt_variables)) = upper_bound(:,cnt_variables); %checking for original upper limit                  new_lower_bound_tk(new_lower_bound_tk < lower_bound(:,cnt_variables)) = lower_bound(:,cnt_variables); %checking for original lower limit                                  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,:);% new matrix generation                new_matrix_tpool{1,cnt_cohort} = nmatrix_tpool;     end           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 upper bound generation                                                                            new_lower_bound_tpool = new_matrix_tpool{cnt_cohort}(:,cnt_variables)- new_range(:,cnt_variables);%new lower bound generation                              new_upper_bound_tpool(new_upper_bound_tpool  > upper_bound(:,cnt_variables)) = upper_bound(:,cnt_variables);%checking for original upper limit                  new_lower_bound_tpool( new_lower_bound_tpool < lower_bound(:,cnt_variables)) = lower_bound(:,cnt_variables);%checking for original lower limit                            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;    endend
           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,:) = Ra_turn(y(cnt_tkpool,:)); %call objective function here      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 %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Ra  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function y1 = ra_turn(x)  y1 = 0.048 * (x(1)^(-0.062))*(x(2)^0.445)*(x(3)^0.516);end
%%%%%%%%%%%%%%%%%%%%%%%%%%% fb %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function y1 = fb(x)  y1 = 0.004 * (x(1)^(0.495))*(x(2)^0.545)*(x(3)^0.763);end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%