FIND MINIMUM TIME OF COMPLETING THE PROJECT BY PERT
Compute following:
- Mean
- Variance
- Latest Completion Time
- Early Start Time
- Critical Path with Critical Activites
Source Code:
start=input("Press any key to start PERT simulation.")
n=10
O=[5 1 1 1 1 1 2 4 2 2]
M=[6 3 4 2 2 5 2 4 5 2]
P=[7 5 7 3 9 9 8 10 8 8]
Activity = ['ABCDEFGHIJ']//use part(Activity,[i])to retrieve
Predecessor = ["","","","A","B","C","C","EF","D","HG"]//part(Predecessor(10),1)
Mean=[]
Variance=[]
for i=1:n
Mean(i)=(O(i)+4*M(i)+P(i))/6
Variance(i)=((P(i)-O(i))/6)**2
end
disp("Mean time of all activities is :- ")
disp(Mean)
disp("Variance of all activities is :-")
disp(Variance)
LCT=[0 0 0 0 0 0 0 0 0 0]
EST=[9999 9999 9999 9999 9999 9999 9999 9999 9999 9999]
funcprot(0)
for i=1:n
//finding EST using forward pass
//if null
if Predecessor(i) == ''
LCT(i) = Mean(i)
else if length(Predecessor(i)) == 1
LCT(i) = Mean(i)+ LCT(strindex(Activity,Predecessor(i)))
else
//finding for more than one predecessor
len=1
maximum=0
while len <= length(Predecessor(i))
if LCT(strindex(Activity,part(Predecessor(i),len))) >maximum
maximum = LCT(strindex(Activity,part(Predecessor(i),len)))
end
len=len+1
end
//found the maximum LCT of predecessor
LCT(i)=Mean(i)+maximum
//also changing LCT of predecessor
len=1
while len <= length(Predecessor(i))
LCT(strindex(Activity,part(Predecessor(i),len)))= maximum
len=len+1
end
end
end
end
//one last thing to check the ending nodes
end_nodes=Activity
for i=1:length(strcat(Predecessor))
end_nodes=strsubst(end_nodes,part(strcat(Predecessor),i),"")
end
//now finding latest completion time
completion_time=0
for i=1:length(end_nodes)
if LCT(strindex(Activity,part(end_nodes(1),i))) > completion_time
completion_time= LCT(strindex(Activity,part(end_nodes(1),i)))
end
end
//set LCT for end nodes as same
//also EST of all activities is easy to find now
for i=1:length(end_nodes)
LCT(strindex(Activity,part(end_nodes(1),i))) = completion_time
EST(strindex(Activity,part(end_nodes(1),i))) = completion_time - Mean(strindex(Activity,part(end_nodes(1),i)))
end
disp("Latest Completion Time of all activities are : - ")
disp(LCT)
//now backward pass for remaining nodes
//finding nodes where backward pass needs to be find
i=length(Activity)
while i>=1
len=1
while len <= length(Predecessor(i))
if EST(i)-Mean(strindex(Activity,part(Predecessor(i),len))) < EST(strindex(Activity,part(Predecessor(i),len)))
//check for start activity
if Predecessor(strindex(Activity,part(Predecessor(i),len))) == ""
EST(strindex(Activity,part(Predecessor(i),len)))=0
else
EST(strindex(Activity,part(Predecessor(i),len))) = EST(i)-Mean(strindex(Activity,part(Predecessor(i),len)))
end
end
len=len+1
end
i=i-1
end
//now finding common predecessor...they should have common minimum start time
//function to find character count
function [k]=char_count(A, c)
k = 0
for p=1:length(A)
if part(A,p) == c then
k=k+1
end
end
endfunction
for i=1:length(Activity)
if char_count(strcat(Predecessor),part(Activity(1),i)) > 1
//found part(Activity(1),i) is common predecessor minimum=999999999
//now finding minimum of that common activity
for j=1:n
len=1
while len <= length(Predecessor(j))
if part(Predecessor(j),len) == part(Activity(1),i)
if EST(j) < minimum
minimum = EST(j)
end
end
len=len+1
end
end
//now replacing that minimum throughout the EST of that Activity
for j=1:n
len=1
while len <= length(Predecessor(j))
if part(Predecessor(j),len) == part(Activity(1),i)
EST(j)=minimum
end
len=len+1
end
end
end
end
//completed backward pass
disp("Early Start Time of all activities are : - ")
disp(EST)
//now the critical path
disp("Critical path of the network is ")
function [k]=EST_successor(c)
k=0
for j=1:n
len=1
while len <= length(Predecessor(j))
if part(Predecessor(j),len) == c
k = EST(j)
end
len=len+1
end
end
//check if the node is ending node
for j=1:length(end_nodes)
if part(end_nodes(1),j) == c then
k=LCT(strindex(Activity,c))
end
end
endfunction
tot=0//to store the path weight
for i=1:length(Activity)
if tot+Mean(i) == EST_successor(part(Activity(1),i))
tot=LCT(i)
disp(" "+part(Activity(1),i)+"-> ")
end
end
disp("Expected project completion time is " + string(completion_time)+" weeks")