Project Evolution and Review Technique(PERT) with Algorithm and program in c++
For More Detail Information and Algorithm: Click Here
from the above image of pert diagram you have to make adjacency matrix for its optimistic time, most likely Time and pessimistic Time and provide that data as a input so the give program will generate output according to below screen shots
Program Code in C++
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#define MAX 50
class pert{
int optimistic[MAX][MAX];
int mostLikely[MAX][MAX];
int pessimistic[MAX][MAX];
int estimatedTime[MAX][MAX];
int variance[MAX][MAX];
int criticalPath[MAX];
int no_of_activity;
int no_of_critical_activity;
int totalDuration;
public:
pert(){
int i,j;
for(i=0;i<MAX;i++){
criticalPath[i]=0;
for(j=0;j<MAX;j++){
optimistic[i][j]=0;
mostLikely[i][j]=0;
pessimistic[i][j]=0;
estimatedTime[i][j]=0;
variance[i][j]=0;
}
totalDuration=no_of_critical_activity=no_of_activity=0;
}
}
void setNoOfActivity(int no){no_of_activity=no;}
void getData();
void display();
void findEstimatedTime();
void findVariance();
void findCriticalPath();
};
int getMaxVal(int array[],int no){
int i,max=0;
for(i=0;i<no;i++){
if(max<array[i])
max=array[i];
}
return max;
}
int getPosition(int array[],int no,int value){
for(int i=0;i<no;i++)
if(array[i]==value)
return i+1;
return 0;
}
void pert::findCriticalPath(){
int i=0,maxVal,pos,k=0;
criticalPath[k]=1;
do{
maxVal=getMaxVal(optimistic[i],no_of_activity);
if(maxVal!=0){
pos=getPosition(optimistic[i],no_of_activity,maxVal);
criticalPath[++k]=pos;
i=pos-1;
totalDuration+=maxVal;
no_of_critical_activity++;
}
}while(maxVal!=0);
}
void pert::findVariance(){
int i,j,sum=0;
for(i=0;i<no_of_activity;i++){
for(j=0;j<no_of_activity;j++)
if(optimistic[i][j]!=0){
sum=(pessimistic[i][j]-optimistic[i][j])/6;
variance[i][j]=sum*sum;
}
}
}
void pert::findEstimatedTime(){
int i,j;
for(i=0;i<no_of_activity;i++){
for(j=0;j<no_of_activity;j++)
if(optimistic[i][j]!=0){
estimatedTime[i][j]=(optimistic[i][j]+(4*mostLikely[i][j])+pessimistic[i][j])/6;
}
}
}
void pert::getData(){
int i,j;
cout<<"enter adjecency matrix of optimistic data:\n";
for(i=0;i<no_of_activity;i++){
cout<<"Row "<<(i+1)<<" : ";
for(j=0;j<no_of_activity;j++)
cin>>optimistic[i][j];
}
clrscr();
cout<<"enter adjecency matrix of MostLikely data:\n";
for(i=0;i<no_of_activity;i++){
cout<<"Row "<<(i+1)<<" : ";
for(j=0;j<no_of_activity;j++)
cin>>mostLikely[i][j];
}
clrscr();
cout<<"enter adjecency matrix of pessimistic data:\n";
for(i=0;i<no_of_activity;i++){
cout<<"Row "<<(i+1)<<" : ";
for(j=0;j<no_of_activity;j++)
cin>>pessimistic[i][j];
}
}
void pert::display(){
int i,j;
cout<<"enterd Data:\n";
cout<<"\tJob\toptimistic\tmost Likely\tpessimistic\n";
for(i=0;i<no_of_activity;i++){
for(j=0;j<no_of_activity;j++)
if(optimistic[i][j]!=0){
cout<<"\t"<<(i+1)<<" - "<<(j+1)<<"\t\t"<<optimistic[i][j]<<"\t\t"<<mostLikely[i][j]<<"\t\t"<<pessimistic[i][j]<<endl;
}
}
cout<<"\n\n\n\t\tpress any key.......";
getch();
clrscr();
cout<<"\tJob\tTO\tTM\tTP\tTE\tVariance\n";
for(i=0;i<no_of_activity;i++){
for(j=0;j<no_of_activity;j++)
if(optimistic[i][j]!=0){
cout<<"\t"<<(i+1)<<" - "<<(j+1)<<"\t"<<optimistic[i][j]<<"\t"<<mostLikely[i][j]<<"\t"<<pessimistic[i][j]<<"\t"<<estimatedTime[i][j]<<"\t"<<variance[i][j]<<endl;
}
}
cout<<"\ncritical path= ";
for(i=0;i<no_of_critical_activity;i++)
cout<<criticalPath[i]<<" - ";
cout<<no_of_activity;
cout<<"\nTotal Duration : "<<totalDuration<<" Days";
}
void main(){
clrscr();
pert p1;
int no;
cout<<"enter no of Activity :";
cin>>no;
p1.setNoOfActivity(no);
p1.getData();
clrscr();
p1.findEstimatedTime();
p1.findVariance();
p1.findCriticalPath();
p1.display();
getch();
}
output:
Screen 1:
Screen 2:Screen 3:
Screen 4:
Screen 5: