Wednesday, 4 February 2015

Project Evolution and Review Technique(PERT) with Algorithm and program in c++

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:




 

9 comments:

  1. excuse me, thanks for your program above. it's totally help me for doing my task in school. but i have a lil problem, just a lil, but it was confusing me. i try to input the data in winqsb and borland c++ with your program, but two software did not give the same answer. the result from winqsb is 480 days, but from borland c++ is only 107 days. can you give me a solution? thank a lot before :)

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. actually i have developed this program in turbo c++ compiler so please try to run this program in turbo c++ compiler first.

      Delete
    3. you can download this program from below link
      https://docs.google.com/uc?authuser=0&id=0B_gzkgGG9xg4ZHRabEFmNjdWMTQ&export=download

      Delete
    4. if you don't have Turbo c++ then you can get it from the below link:
      http://filehippo.com/download_turbo_c_/

      Delete
    5. the site can't be reached, do you have another link?

      Delete
    6. http://filehippo.com/download_turbo_c_/download/697dfd076ced1ee9121a5d2976fe0db4/

      Above url will copy and paste in new tab.
      you will get it !...

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. will you plz send me test mail to jitenvaghela2@gmail.com i will send you a link so you can get it.

    ReplyDelete