Skip to main content

Posts

Future Event LIST (Simulation & Modeling)

BY NEHA BAHADUR MCA/4553/09 #include #include #include int inter[9] = {1,1,6,3,7,5,2,4,1}; int service[9] = {4,2,5,4,1,5,4,1,4}; int i=0,j=0; struct eventinfo { int type; int time; struct eventinfo *next; } * header; void addevent(int time, int type) { struct eventinfo * node = (struct eventinfo *)malloc(sizeof(struct eventinfo)); struct eventinfo *p, *q; node->type = type; node -> time = time; if(header->next == NULL) { header ->next = node; node->next = NULL; return ; } p = header->next; q = header; while((p->time next; } q->next = node; node -> next = p; } void print() { struct eventinfo * p = header->next; while(p!=NULL) { //printf("\n"); if(p->type ==1) printf("(A,"); else printf("(D,"); printf("%d)",p->time); p =p->next; } } void depart() { int nexttm; struct eventinfo * node =

Future Event LIST (Simulation & Modeling) (Linked list Implementation)

by Himanshu Singla #include #include #include int inter[9] = {1,1,6,3,7,5,2,4,1}; int service[9] = {4,2,5,4,1,5,4,1,4}; int i=0,j=0; struct eventinfo { int type; int time; struct eventinfo *next; } * header; void addevent(int time, int type) { struct eventinfo * node = (struct eventinfo *)malloc(sizeof(struct eventinfo)); struct eventinfo *p, *q; node->type = type; node -> time = time; if(header->next == NULL) { header ->next = node; node->next = NULL; return ; } p = header->next; q = header; while((p->time next; } q->next = node; node -> next = p; } void print() { struct eventinfo * p = header->next; while(p!=NULL) { //printf("\n"); if(p->type ==1) printf("(A,"); else printf("(D,"); printf("%d)",p->time); p =p->next; } } void depart() { int nexttm; struct eventinfo * node = header->ne

Application of Weibull Distribution

#include #include #include double f(int x, double v, double a, double b) { if(x< v) return 0; else { return b/a*(pow((x-v)/a,b-1))*exp(-pow((x-v)/a,b)); } } double F(int x, double v, double a, double b) { if(x return 0; else { return (1 - exp(-pow((x-v)/a,b))); } } int main() { int x; double v,a,b; clrscr(); printf("enter d value of x, location, shape & scale: "); scanf(" %d %lf %lf %lf",&x, &v, &b, &a); printf(" f(%d) = %f",x,f(x,v,a,b)); printf(" F(%d) = %f",x,F(x,v,a,b)); getch(); return 0; }

Application of Poisson Distribution

#include #include #include long fact(int n) { if(n<=0) return 1; else return n*fact(n-1); } double poisson(int x, double a) { if(x<0) return 0; else { return (exp(-a)*pow(a,x))/fact(x) ; } } int main() { int x; double mean; clrscr(); printf("enter d value of x & mean: "); scanf(" %d %lf",&x, &mean); printf(" p(%d) = %f",x,poisson(x,mean)); getch(); return 0; } by Amrender

Triangular Distribution

#include #include #include double f(double x, double a, double b, double c) { if(a <= x && x <= b) { return (2*(x-a))/((b-a)*(c-a)); } else if( b < x && x <= c) { return 2*(c-x)/((c-b)*(c-a)); } else return 0; } double F(double x, double a, double b, double c) { if(x<=a) return 0; else if( a c) return 1; } int main() { double x,a,b,c; clrscr(); printf("enter d value of x, a, b & : "); scanf(" %lf %lf %lf %lf",&x, &a, &b, &c); printf(" f(%.2f) = %f",x,f(x,a,b,c)); printf(" F(%.2f) = %f",x,F(x,a,b,c)); getch(); return 0; } ) By Alka (4501/09)

Future Event LIST (Simulation & Modeling)

Script for grocery shop with given inter-arrival/service time distribution assumed by Amrendra Kumar mca/4549/09 #include #include #include void addevent(int,int); void depart(); void arrival(); struct eventinfo { int type; int time; struct eventinfo *next; } * header; int inter[9] = {1,1,6,3,7,5,2,4,1}; int service[9] = {4,2,5,4,1,5,4,1,4}; int i=0,j=0; void main() { int t, eventtime; clrscr(); header = (struct eventinfo *) malloc(sizeof(struct eventinfo)); header ->time=0; header->next = NULL; header->type = 0; t =0; addevent(0,1); eventtime = header->next->time; while(t<=60) { if(t == eventtime) { printf("\nt=%d ",t); if(header->next->type ==1) arrival(); else depart(); if(header->next != NULL) eventtime = header->next->time; else eventtime = 100; if(i>=9 || j&