Skip to main content

Posts

Showing posts with the label Simulation and Modeling

M/M/1 Queuing Model code

Program code in C for M/M/1 queuing model #include<stdio.h> #include<conio.h> void main() { int lam,mu,n,i; float l,lq,ls,wq,ws,rho,p[20]; clrscr(); printf("\nEnter value for lam="); scanf("%d",&lam); printf("\nEnter value for mu="); scanf("%d",&mu); printf("\nEnter value for n="); scanf("%d",&n); l=(float)lam/(lam-mu); ws=(float)(lam/mu); wq=(float)(ws-(1/mu)); lq=(float)(pow(mu,2)/((mu)*(mu-lam))); rho=(float)lam/mu; p[0]=(float)(1-(lam/mu)); for(i=1;i<n;i++) p[i]=(float)(p[0]*(pow(rho,i))); printf("\n\n\nThe calculated results are=\n"); printf("\n l=%f",l); printf("\n ws=%f",ws); printf("\n wq=%f",wq); printf("\n lq=%f",lq); printf("\n p=%f",p); printf("\nThe probablities are!!\n"); for(i=0;i<n;i++) printf("\np[%d]=\t%f",i,p[i]); getch(); } by A...

M/M/1 Queuing Simulator

Hi   All Its a very good simulator   for M/M/1. It brings t he power of Discrete Event Simulation and Web technologies for teaching and learning Queuing Theory and Queuing Networks.     Complex networks of M/M/1 queues can be modeled and simulated easily with this web-based simulator. The simulator runs a complete discrete event simulation to generate the statistics of queues and systems. http://www.simjs.com/queuing/

FEL program of grocery shop

FEL is Future event list. A list of event notices for future events. The event notice must contain all the information necessary to execute the event (in particular the time it is scheduled to occur).  The event list is the main data structure in a  discrete-event simulator  so its important to code for FEL. #include<stdio.h> #include<conio.h> /*****************************FEL for a grocery shop!!**********************************/ //Defining structure for customer!! typedef struct { int cno,inter_arr,arr_time,ser_time,beg_time,wait_time,end_time,sys_time,idle_time; }cust; //Defining structure for FEL because we have entries for arrival,departure,end & their respective time!! typedef struct { char ename; int time; }event; //For lookup function for inter-arrival time!! int lookup_interarr(int i) { if(i>=0 && i<13) return 1; else if(i>=13 && i<25) return 2; else if(i...

Multiplicative congruential method program

#include<stdio.h> #include<conio.h> void print(int x[],float r[],int n,int p) { int i; clrscr(); printf("\n\nLinear Congruential Method!!"); printf("\n\ni\tNumbers\t\tRandom Numbers\n\n"); for(i=0;i<n;i++) printf("\n%d\t%d\t\t%f",i+1,x[i],(float)r[i]); printf("\n\nThe total periods=%d",n); if(i%p==0) printf("\n\nThe generator achieved the max period!!"); else printf("\n\nThe generator does not achieved max period!!"); getch(); exit(0); } void main() { int i,x[40],a,m,x0,ch,p; float r[40]; clrscr(); printf("\n\n*************Multiplicative Congruential Generator*****************\n"); printf("\n\n1.a=11,m=16,x0=7"); printf("\n\n2.a=11,m=16,x0=8"); printf("\n\n3.a=7,m=16,x0=7"); printf("\n\n4.a=7,m=16,x0=8"); printf("\n\n5.Exit!!"); printf("\n\n********************************************************************\n"); printf("\nEnter...

Random Variable Generation program

#include<stdio.h> #include<conio.h> void print(int x[],float r[],int n) { int i; clrscr(); printf("\ni\tNumbers\t\tRandom Numbers\n\n"); for(i=0;i<n;i++) printf("\n%d\t%d\t\t%f",i+1,x[i],(float)r[i]); printf("\n\nThe total periods=%d",n); getch(); exit(0); } void main() { int i,x[40],a,c,m,x0; float r[40]; clrscr(); printf("\nEnter value for a="); scanf("%d",&a); printf("\nEnter value for c="); scanf("%d",&c); printf("\nEnter value for m="); scanf("%d",&m); printf("\nEnter value for x0="); scanf("%d",&x0); x[0]=x0; r[0]=(float)x[0]/m; for(i=1;i<40;i++) { x[i]=((x[i-1]*a)+c)%m; r[i]=(float)x[i]/m; if(x[0]==x[i]) print(x,r,i); } }  by Aanchal Gupta(MCA/4510/11)

Application of neural network

INTRODUCTION Road accidents involving the release of toxic or hazardous materials (such as hydrocarbons and chlorinated solvents, which are non-aqueous phase liquids or NAPL) during their transportation may cause severe environmental problems. A particular attention is given to denser than water NAPLs (DNAPLs), which may reach deep into the aquifer and thus durably contaminate the groundwater. This study is concerned with the impact of a DNAPL spill on the water resource for a road project infringing a zone of drinking water catchments in the case of a road accident involving a DNAPL transporting vehicle. The zone of study spans over several kilometers, along which soil properties vary significantly. Simulation metamodelling is based on the substitution of the simulation model by an approximation of the input–output relationship. Metamodelling, first proposed by Blanning, makes the computations much faster, allowing for more cases to be studied. Originally based ...

Auto-correlation program

/*program for autocorrelation */ #include<stdio.h> #include<conio.h> #include<math.h> int main() { int i,m,a,c,x[30]={27},count=0,M,j,k,n; double r[30],z,R[30],sum=0.0,R0,z0,R1; double sq,zA=1.96; clrscr(); printf("Enter the values of a,c,m:\n"); scanf("%d%d%d\n",&a,&c,&m); for(i=1;i<=30;i++) { x[i]=(a*x[i-1]+c)%m; r[i]=(float)x[i]/m; count++; printf("\tRand No.::%f\n",r[i]);   } scanf("%d%d%d",&j,&n,&M); if((j+(M+1)*n)<= r)     { for(k=0;k<=M;k++)    {      R[k]=r[i+(k*m)]* r[i+(k+1)*m];      sum=sum+R[k];    }    R1=sum/(M+1)-0.25;    sq=sqrt((13*M)+7);    R0=sq/(12*(M+1));    z0=R1/R0;    printf("%f",z0); }   if(z0>=-zA && z0<=zA)  printf("\n ACCEPTED");  else  printf("\n REJECTED");   getch(); return...

Inverse Random Variable program

#include<stdio.h> #include<conio.h> #include<math.h> float triangular(float a,float b,float R) {  if(a>b)      return (0.0);  else      return(a+(b-a)*R);   } float exponential(float mean,float R) {   if(R>1)     return (0.0);   else  return (-1/mean*logl(1-R)); } float weibull(float alpha,float beta,float R) {   if(R>1)     return (0.0);   else  return (alpha*(pow(logl(1/(1-R)),1/beta)));  } void main() {  float x[10],mean,a,b,r[10]; int i,n,ch; char c; clrscr(); printf("How many Random Nos. you want to enter:"); scanf("%d",&n); while(1) { printf("\n\t 1. Exponential \n\t 2. Triangular\n\t 3. Weibull\n\t"); printf("\n\t Enter Your Choice "); scanf("%d",&ch); for(i=0;i<n;i++) r[i]=(float)(rand()%1000)/1000; switch(ch) { case 1: printf("\n\t Enter value m...

Acception rejection using poisson

/*acception rejection using poisson*/ #include<stdio.h> #include<conio.h> #include<math.h> #include<stdlib.h> main() {       float p[30],r[30],random[30],a;       int i,j,k,n;       int count =0;       int flag=0;          printf("Enter the number of random numbers  \t e.g 5\n");       scanf("%d",&n);        printf("enter the value of alpha \t e.g 0.2 \n");       scanf("%f",&a);       random[0]=0.4357;       random[1]=0.4146;       random[2]=0.8353;       random[3]=0.9952;       random[4]=0.8004;      printf("\n");       p[0]=1;       system("cls");       printf("n\t\tR(n+i)\t\tP\t\tAcc/Rej\n");       i=0;    ...

MCA V Simulation and Modeling assignments

1        Input Modeling of Simulation   2   Application of Simulation for solving network flow problems 3   Learning NS2 4  Web Based Simulation 5   Learning NS3 7   Web Based Simulation 9   Simulation of Computer Networks 10   Queuing based website simulation 11   Winter conference simulation research papers -4 12   Online Simulation tool 15  Creating Search Engine Simulator 17     Search Engine Optimization using Simlation 18  Flight Simulation      20    Studying neural network simulation 21   Website simulation  22    Simulation Tools comparitive study   23   Simulation in Java 24  Using Simulation for forecasting 25  Simulation for predictive analysis 26  Using Data mining for Simulation 27   Simulation for predictive analysis 28   simulation with Fuzzy logic 29...

VBA LAB Exercises (SimulatioModeling)

                                                   Even Roll No.s Write a program in VB to pick a value from the excel and sheet and print out its square root,cube root on the excel sheet. Also, check whether the number is prime or not.  Once this task is complete take a range of values (depicting arrival of customer) from excel and generate its cumulative frequency and using a rand function  generate arrival distribution Odd RollNO.s Write a program in VB to pick two values from the  excel and sheet and print out their addition and multiplication results on the excel sheet.  Also, check whether the sum of number is even or odd  Once this task is complete take a range of values (depicting arrival of customer) from excel and generate its cumulative frequency and using a rand function   generate arrival d...

Code for printing the grade of a studente on Excel sheet using VBA

Private Sub CommandClicking_Click() Dim m As Integer Dim g As String Randomize Timer m = Int(Rnd * 100) Cells(10, 1).Value = m If m < 35 And m >= 0 Then g = "F" Cells(11, 1).Value = g ElseIf m < 55 And m >= 35 Then g = "E" Cells(11, 1).Value = g ElseIf m < 65 And m >= 55 Then g = "D" Cells(11, 1).Value = g ElseIf m < 75  And m >= 65 Then g = "B" Cells(11, 1).Value = g ElseIf mark < 90 And mark >= 75 Then g = "A" Cells(11, 1).Value = g ElseIf mark < 100 And mark >= 90 Then grade = "A*" Cells(11, 1).Value = g End If End Sub

AUTOCORRELATION PROGRAMME

Manish Kumar MCA/4528/10 /* Thursday Lab Work AUTOCORRELATION PROGRAMME*/ #include void main() { int random[50],i,j,k,m,M,N,flag=1; float temp=0; clrscr(); printf( "Enter parameters:\n" ); printf( "\nEnter Total Random Number N: " );scanf( "%d" ,&N); printf( "\nTable of Random no.:\n" ); for (j=0;j { random[j]=rand()%10; printf( "%d\t" ,random[j]); } while (flag) { printf( "\nEnter i: " );scanf( "%d" ,&i); printf( "Enter m: " );scanf( "%d" ,&m); printf( "Enter M: " );scanf( "%d" ,&M); if ((i+(M+1)*m)<=N) flag=0; else { flag=1; printf( "wrong enteries! Enter the parameters again\n" ); } } for (k=0;k { temp+=random[i+(k*m)] * random[i+(k+1)*m]; } temp-=0.25; printf( "\n\nResult:%f" ,temp); ...

Random Number generation

shubh laxmi   #include #include #include #include #define MAX 100 void main() { int i,m,M,c,a,x[MAX]; float r[MAX]; clrscr(); printf( "enter the value of a c m :-" ); scanf( "%d %d %d" ,&a,&c,&m); printf( "Enter the value of x0:" ); scanf( "%d" ,&x[0]); r[0]=( float )x[0]/m; printf( "r[0]=%.3f\n" ,r[0]); for (i=1;i { x[i]=(a*x[i-1]+c)%m; r[i]= ( float )x[i]/m; } for (i=1;i { if (x[i]!=x[0]) printf( "Random nos are:-%.3f\n" ,r[i]); else break ; } getch(); }

Weibull Binomial and Geo mean distribution

Jainendra Sharma MCA/4531/10  #include #include #include double fact( int n) { if (n<=0) return 1; else return n*fact(n-1); } double geomean( int x, double p, double q) { if (x>0) return pow(q,x-1)*p; else return 0; } double weibpdf( int x, double v, double a, double b) { int n1,p1,q1; if (x==0) return fact(n1)/(fact(x)*fact(n1-x))*pow(p1,x)*pow(q1,n1-x); else return 0; } double poisson( int x, double a) { if (x return 0; else { return (exp(-a)*pow(a,x))/fact(x) ; } } double binomial( int n, double p, int r) { return fact(n)/(fact(n-r)*fact(r))*pow(p,r)*pow(1-p,n-r); } void main() { int ch; double p,q,v,a,b; int x,n; clrscr(); do { printf( "\nExit." ); printf( "\nGeometric Mean." ); printf( "\nWeibull Distribution." ); printf( "\nPoisson Distribution."...