New Post

Markov Chains || Step-By-Step || ~xRay Pixy

Image
Learn Markov Chains step-by-step using real-life examples. Video Chapters: Markov Chains 00:00 Introduction 00:19 Topics Covered 01:49 Markov Chains Applications 02:04 Markov Property 03:18 Example 1 03:54 States, State Space, Transition Probabilities 06:17 Transition Matrix 08:17 Example 02 09:17 Example 03 10:26 Example 04 12:25 Example 05 14:16 Example 06 16:49 Example 07 18:11 Example 08 24:56 Conclusion

POA - CODE || Pelican Optimization Algorithm Code Implementation ||

Learn Pelican Optimization Algorithm Code Implementation Step-By-Step POA-CODE Video Chapters: 00:00 Introduction 01:22 Test Function Information Program File 02:37 Pelican Optimization Algorithm Program File 11:23 Main Program File 12:30 Conclusion

1.) Test Function Information File
function [LB,UB,D,FitF] = test_fun_info(C) switch C case 'F1' FitF = @F1; LB=-100; UB =100; D =30; case 'F2' FitF = @F2; LB=-10; UB =10; D =30; case 'F3' FitF = @F3; LB=0; UB=1; D=3; end end % F1 function R = F1(x) R=sum(x.^2); end % F2 function R = F2(x) R=sum(abs(x))+prod(abs(x)); end

2.) POA File
function[Best_Solution,Best_Location,Sol_con_Curve]=POA(PopSize,MaxT,LB,UB,D,FitF) LB=ones(1,D).*(LB); % Lower limit UB=ones(1,D).*(UB); % Upper limit % POPULATION INITIALIZATION PHASE for i=1:D X(:,i) = LB(i)+rand(PopSize,1).*(UB(i) - LB(i)); % Initial population end % FITNESS VALUES CALCULATION for i =1:PopSize L=X(i,:); FitnessVal(i)=FitF(L); end %% for t=1:MaxT %% update the best condidate solution [Best_Agent_Val , Best_Agent_Loc]=min(FitnessVal); if t==1 Best_Pos=X(Best_Agent_Loc,:); % Optimal location Best_Val=Best_Agent_Val; % The optimization objective function elseif Best_Agent_Val<Best_Val Best_Val=Best_Agent_Val; Best_Pos=X(Best_Agent_Loc,:); end %% UPDATE location of food Agents_Target=[]; g=randperm(PopSize,1); Agents_Target=X(g,:); Agents_Target=FitnessVal(g); %% for i=1:PopSize %% PHASE 1: Moving towards prey (exploration phase) I=round(1+rand(1,1)); if FitnessVal(i)> Agents_Target New_Pos=X(i,:)+ rand(1,1).*(Agents_Target-I.* X(i,:)); %Eq(4) else New_Pos=X(i,:)+ rand(1,1).*(X(i,:)-1.*Agents_Target); %Eq(4) end New_Pos= max(New_Pos,LB); New_Pos = min(New_Pos,UB); % Updating X_i using (5) New_Fit = FitF(New_Pos); if New_Fit <= FitnessVal(i) X(i,:) = New_Pos; FitnessVal(i)=New_Fit; end %% END PHASE 1: Moving towards prey (exploration phase) %% PHASE 2: Winging on the water surface (exploitation phase) New_Pos=X(i,:)+0.2*(1-t/MaxT).*(2*rand(1,D)-1).*X(i,:);% Eq(6) New_Pos= max(New_Pos,LB); New_Pos = min(New_Pos,UB); % Updating X_i using (7) New_Fit = FitF(New_Pos); if New_Fit <= FitnessVal(i) X(i,:) = New_Pos; FitnessVal(i)=New_Fit; end %% END PHASE 2: Winging on the water surface (exploitation phase) end best_so_far(t)=Best_Val; average(t) = mean (FitnessVal); end Best_Solution=Best_Val; Best_Location=Best_Pos; Sol_con_Curve=best_so_far; end


3.) Main File
clc clear all %Test Function Test_Fun='F3'; % Total Number of Pelicans PopSize=50; % Maximum number of iteration MaxT=500; % Test Function Details [LB,UB,D,FitF]=test_fun_info(Test_Fun); % POA Calculation [BestVal,BestLoc,Sol_con_Curve]=POA(PopSize,MaxT,LB,UB,D,FitF); subplot(1,1,1); semilogy(Sol_con_Curve,'Color','r'); title('Convergence Curve'); xlabel('Iteration'); ylabel('Best Value'); axis tight grid on box on legend ('POA') % Display Solution display(['Best Position' [num2str(Test_Fun)],' = ', num2str(BestLoc)]); display(['Best Solution' [num2str(Test_Fun)],' = ', num2str(BestVal)]);

Comments

Popular Post

PARTICLE SWARM OPTIMIZATION ALGORITHM NUMERICAL EXAMPLE

Cuckoo Search Algorithm for Optimization Problems

Particle Swarm Optimization (PSO)

PSO (Particle Swarm Optimization) Example Step-by-Step

how is the LBP |Local Binary Pattern| values calculated? Step-by-Step with Example

PSO Python Code || Particle Swarm Optimization in Python || ~xRay Pixy

Grey Wolf Optimization Algorithm

Bat algorithm Explanation Step by Step with example

Grey Wolf Optimization Algorithm Numerical Example

Whale Optimization Algorithm Code Implementation || WOA CODE || ~xRay Pixy