Markov Proces-System Engineering-Lab Report, Exercises of Systems Engineering

This lab report is for System Engineering course. It was submitted to Katyayani Yatindra at Bengal Engineering and Science University. It includes: Markov, Process, Premptive, Theoretical, Probability, MATLAB, Code, Results, Stochastic, Time-varying

Typology: Exercises

2011/2012

Uploaded on 07/17/2012

gaggandeep
gaggandeep 🇮🇳

4.6

(40)

100 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Premptive Markov chain analysis 1
2
TA BLE OF CONTENTS
Markov process ............................................................................................................................................. 3
Task 1 ............................................................................................................................................................ 3
Theoretical Probability .............................................................................................................................. 3
Matlab Results .......................................................................................................................................... 3
Matlab Code .............................................................................................................................................. 3
FlowChart .................................................................................................................................................. 4
Task2 ............................................................................................................................................................. 5
Theoretical probability .............................................................................................................................. 5
Matlab results ........................................................................................................................................... 5
Matlab code .............................................................................................................................................. 5
Flowchart .................................................................................................................................................. 7
Task 3,Task4 .................................................................................................................................................. 8
Theoretical probability .............................................................................................................................. 8
Matlab results ........................................................................................................................................... 8
Matlab code .............................................................................................................................................. 8
Flowchart ................................................................................................................................................ 10
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Markov Proces-System Engineering-Lab Report and more Exercises Systems Engineering in PDF only on Docsity!

TABLE OF CONTENTS

  • Markov process
  • Task
    • Theoretical Probability
    • Matlab Results
    • Matlab Code..............................................................................................................................................
    • FlowChart
  • Task2
    • Theoretical probability
    • Matlab results
    • Matlab code
    • Flowchart
  • Task 3,Task4
    • Theoretical probability
    • Matlab results
    • Matlab code
    • Flowchart

MARKOV PROCESS

In probability theory and statistics, a Markov process, named after the Russian mathematician

Andrey Markov, is a time-varying random phenomenon for which a specific property (the Markov

property) holds. In a common description, a stochastic process with the Markov property, or

memorylessness, is one for which conditional on the present state of the system, its future and past

are independent.

TASK 1

Given a single server, determine the probability the server remains busy.

Assume the packet arrival time is distributed by ‘Poisson Distribution’ and service time is

distributed by ‘Exponential Distribution’.

THEORETICAL PROBABILITY

( )

for λ=5 and μ=15 ,P(1)=0.

( )

λ=5 and μ=15 ,P(0)=0.

MATLAB RESULTS

p_1 =0.

p_0 =0.

MATLAB CODE

clear all clc lambda=5; A=exprnd(lambda,1,5001); P(1)=A(1); for i=2:5001 P(i)=A(i)+P(i-1);%Poisson dist from exp end arrival=P; %inter arrival time service=exprnd(15,1,5000); %exponential distribution [l m]=size(arrival);

TASK

If ‘4’ number of servers are available, and packets arrive through a single channel, what is

the probability ‘4’ number of servers remain busy simultaneously.

Theoretical Probability

theoretical probability for multiple servers with single stream of packets is found by formula

λ=5 and μ=5 P(0)=0.369, P(1)=0.369, P(2)=0.1845, P(3)= 0.

Matlab Results

p0 =0.

p1 = 0.

p2 =0.

p3 =0.

Matlab Code..............................................................................................................................................

clear all close all clc lambda=5; A=exprnd(lambda,1,500); P(1)=A(1); for i=2: P(i)=A(i)+P(i-1); %Poisson dist from exp end arrival=P; service=exprnd(5,1,500); [l m]=size(arrival); %% initialization %first element=arrival time %2nd element=service time %3rd element=busy

S1=[arrival(1) service(1) 1]; S2=zeros(1,3); S3=zeros(1,3); S4=zeros(1,3); sum=1; %number of server busy( sum of flags of servers) n1=0; n2=0;

, 0 , 1 , 2 , ,. /!

/!

0

j s k

j P (^) s

k

k

j

j   

n3=0; n4=0; b= %% Execution for i=2:m- t=arrival(i)+service(i-1);

if S1(3)== if (S1(1)+S1(2))<arrival(i) S1(3)=0; disp('S1 is free') end end if S2(3)== if (S2(1)+S2(2))<arrival(i) S2(3)=0; disp('S2 is free') end end if S3(3)== if (S3(1)+S3(2))<arrival(i) S3(3)=0; disp('S3 is free') end end if S4(3)== if (S4(1)+S4(2))<arrival(i) S4(3)=0; disp('S4 is free') end end sum=S1(3)+S2(3)+S3(3)+S4(3); if sum== n1=n1+1; elseif sum== n2=n2+1; elseif sum== n3=n3+1; elseif sum== n4=n4+1; end %% Assigning data to free server D=[S1(3) S2(3) S3(3) S4(3)]; j=find(D==0); if ((isempty(j))) disp('all server are busy') b=b+1; elseif j(1)== S1(1)=arrival(i); S1(2)=service(i); S1(3)=1; disp('S1 is bze')

elseif j(1)== S2(1)=arrival(i); S2(2)=service(i); S2(3)=1; disp('S2 is bze') elseif j(1)== S3(1)=arrival(i); S3(2)=service(i); S3(3)=1; disp('S3 is bze') elseif j(1)== S4(1)=arrival(i); S4(2)=service(i); S4(3)=1; disp('S4 is bze') end

TASK 3,TASK

Suppose, ‘3’ number of servers are available, and packets arrive through two channels,

channel A and channel B, with packets from B given a higher priority. What is the

probability that packets from channel A are

i. blocked due to unavailability of servers?

ii. forced terminated due to preemption?

Theoretical probability

The calculations are done by following formulas

Matlab results

prem = 0

true =

Matlab code

clear all close all clc lambda1=5; a=exprnd(lambda1,1,10000); P(1)=a(1); for i=2: P(i)=a(i)+P(i-1);%Poisson dist from exp end arrival1=P; A=exprnd(5,1,10000); lambda2=5; a1=exprnd(lambda2,1,10000); P2(1)=a1(1); for i=2: P2(i)=a1(i)+P2(i-1);%Poisson dist from exp end arrival2=P2; B=exprnd(5,1,5000); [l m]=size(A); % A has higher priority than B %%% 1st element arrival %%% 2nd element service time

%%% 3rd element flag 1 for A, 2 for B & 0 for free S1=[0 0 0 ]; S2=[0 0 0 ]; S3=[0 0 0 ]; Arrival=[0 0]; block=0;kickout=0; %%% A has higher priority while B has lower priority for i=1:1:m if arrival1(i)>arrival2(i) Arrival(1)=arrival2(i); %assignment of time which is less Arrival(2)=2; else Arrival=arrival1(i); Arrival(2)=1; end if (S1(3)~=0) if Arrival(1)<(S1(1)+S1(2)) S1(3)=0; end end if (S2(3)~=0) if Arrival(1)<(S2(1)+S2(2)) S2(3)=0; end end if (S3(3)~=0) if Arrival(1)<(S3(1)+S3(2)) S3(3)=0; end end D=[S1(3) S2(3) S3(3)]; j=find(D==0); if (S1(3)==1 && S2(3)==1 && S3(3)==1) %if all server having data from A disp('all server have data from A'); block=block+1; elseif(isempty(j)) %if no server is busy j1=find(D==2); if(isempty(j)) elseif j(1)==1 %%checking for the server with data from B for kickout S1(1)=Arrival(1); kickout=kickout+1; if Arrival(2)== S1(2)=A(i); S1(3)=1; else S1(2)=B(i); S1(3)=2; end elseif j(1)== S2(1)=Arrival(1); kickout=kickout+1; if Arrival(2)== S2(2)=A(i); S2(3)=1;