Hidden Markov Model (HMM) VIDEO LINK: https://youtu.be/YIGCWNG8BIA A Hidden Markov Model (HMM) is a statistical model in which the system has hidden states that cannot be directly observed, but produce observable outputs. It is based on the Markov property, meaning the next state depends only on the current state. Video Chapters: HMM in Artificial Intelligence 00:00 Introduction 00:31 Statistical Model 00:54 HMM Examples 02:30 HMM 03:10 HMM Components 05:23 Viterbi Algorithm 06:23 HMM Applications 06:38 HMM Problems 07:28 HMM in Handwriting Recognition 11:20 Conclusion HMM COMPONENTS A Hidden Markov Model (HMM) is a statistical model in which the system has hidden states that cannot be directly observed, but produce observable outputs. It is based on the Markov property, meaning the next state depends only on the current state. An HMM consists of states, observations, transition probabilities, emission probabilities, and initial probabilities. It is commonly used in a...
Learn Pelican Optimization Algorithm Code Implementation Step-By-StepPOA-CODE Video Chapters:00:00 Introduction01:22 Test Function Information Program File02:37 Pelican Optimization Algorithm Program File11:23 Main Program File12: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
Post a Comment