Thursday 21 April 2016

Infinite Markovian

#include<stdio.h>
#include<conio.h>
#include<math.h>
struct infi
{ int s;
float m,l,p,lq,w,wq;
};
void main()
{ char c;
int i;
float l;
struct infi v[2];
clrscr();
printf("\nEnter rate per hour: ");
scanf("%f",&l);
printf("\nEnter average service time of Pawan: ");
scanf("%f",&v[0].m);
printf("\nEnter standard deviation: ");
scanf("%d",&v[0].s);
printf("\nEnter average service time of Ramdas: ");
scanf("%f",&v[1].m);
printf("\nEnter standard deviation: ");
scanf("%d",&v[1].s);
l=l/60;

for(i=0;i<2;i++)
{ v[i].m=1/v[i].m;
v[i].p=l/v[i].m;
v[i].l=v[i].p+((l*l)*(1/pow(v[i].m,2)+pow(v[i].s,2)))/(1-v[i].p);
v[i].w=1/v[i].m + (l*(1/v[i].m+pow(v[i].s,2))/(2*(1-v[i].p)));
v[i].wq=(l*(1/pow(v[i].m,2) + pow(v[i].s,2)))/(2*(1-v[i].p));
v[i].lq=(pow(v[i].p,2)*(1+pow(v[i].s,2)*pow(v[i].m,2)))/(2*(1-v[i].p));
}

printf("\n\t------------------------------------------");
printf("\n\t Parameters||\tPawan\t|\tRamdas");
printf("\n\t------------------------------------------");
printf("\n\t P\t   ||\t%.2f\t|\t%.2f",v[0].p,v[1].p);
printf("\n\t L\t   ||\t%.2f\t|\t%.2f",v[0].l,v[1].l);
printf("\n\t Lq\t   ||\t%.2f\t|\t%.2f",v[0].lq,v[1].lq);
printf("\n\t w(mins)   ||\t%.2f\t|\t%.2f",v[0].w,v[1].w);
printf("\n\t wq(mins)  ||\t%.2f\t|\t%.2f",v[0].wq,v[1].wq);
printf("\n\t------------------------------------------");
printf("\n\nP = Steady State");
printf("\nL = No. of customers in System");
printf("\nLq = No.of customers in queue");
printf("\nw = Time spent in System");
printf("\nwq = Time spent in queue");
if(v[0].lq<v[1].lq)
printf("\n\n\tPawan will be Hired.");
else
printf("\n\n\tRamdas will be Hired.");
getch();
}


No comments:

Post a Comment