Skip to main content

Posts

Showing posts with the label Simulation and Modeling

Starting Simulation in Excel

Steps for Starting Simulation in Excel 1. Generating randomness In simulation most important work is to generate random ness. You can use inbuilt rand()function for the same. When you enter the formula =RAND() in a cell, you get a number that is equally likely to assume any value between 0 and 1. Thus, around 25 percent of the time, you should get a number less than or equal to .25; around 10 percent of the time you should get a number that is at least .90, and so on 2. In order to conduct discrete simulation you need to use values of a discrete random variable. 3. Excel's VLOOKUP function stands for vertical lookup helps to find specific information in large data tables such as an inventory list of parts or a large membership contact list. Enter the data in the cells. Let the first column of data contains the part names (say B ) and the second column (column C) contains the price of each part. Vlookup can be used 1.Click on cell B1 and type the title lets say Pa

Coding for distributions (geometric/weibull)

#include #include #include long 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) { if(x =0) return fact(n)/(fact(x)*fact(n-x))*pow(p,x)*pow(q,n-x); else return 0; } int 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."); printf("\nBinomial Distribution."); printf("\nEnter your choice => "); scanf("%d",&ch); if(ch==1) { printf("\n\tEnter the value of x,p,q => "); scanf("%d%lf%lf",&x,&p,&q); prin

Coding for M/M/1 server

#include #include void main() { int i,a,d,arrival[11],clock=0,inter[]={2,3,1,4,1,6,1,1,5,2,1},service[]= {2,5,4,3,3,5,6,6,6,3,2}; int wait[11],q=0,sum=0,avg,server; arrival[0]=clock+inter[0]; d=clock+service[0]; server=1; a=arrival[0]; wait[0]=0; for(i=0;i<11;i++) { arrival[i]=arrival[i-1]+inter[i]; } printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[0]) ; i=1; while(clock<30) { if(a d) {wait[i]=0; printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[1]) ; i++; } else if(d a) { wait[i]=d-a; } printf("\nclock = %d (A,%d) (D,%d) (w,%d)",clock,a,d,wait[i]); } else { wait[i]=0; printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[i]) ; server=0; } } else { clock=0; a=arrival[i]; d=clock+service[i-q]; if(a { wait[i]=d-a; } else { wait[i]=0; i++; printf("clock=%d (A=%d)(D=%d)(W=%d)",clock,a,d,wait[i]) ; } } else { clock=0; a=arrival[i]; d=clock+service[i]; wait[i]=d-a; i++; printf(

Simulation & Modeling (ASSIGNMENTS) [LAB + Theory}

Roll No. Assignments 2032,4501 Music Shop Inventory Problem,Simulation of computer system 4502,4506 Web Simulation, 4507,4568,4538 Food bazaar, Simulation of Queuing System and its applications e.g. Food Bazaar 4508,4536,4546 Simulating a banquet hall,Input Output modeling for simulation 4509 Random Number generation for simulation 4510,4525,4520 Telephone Simulation System, Application of Simulation for solving network flow problems 4511,4543 Simulating Car Parking 4513,4533,4531 Monte-carlo Simulation 4514 Simulating grocery Shop 4516,4535,4551/08 Traffic Simulation, Simulation of websites to improve traffic for a website 4515,4528,4529 Understanding GPSS 4518,4554,4566 Gaming Simulation 4519,4524 Conducing web simulation on e-commerce portals 4530,4551,4556 Simulating Delhi Metro, Understanding Object oriented simulation 4534,4557

Simulation & Modeling Software

We can understand computer simulation language as the language which describes operation of a simulation on a computer. It can be broadly categorized in following two categories: 1. continuous 2. Discrete event Many lnguages have a graphical interface and are capable of performing simple statistical analysis of the results. While using discrete-event languages we can easily generate pseudo-random numbers and determine variables using different probability distributions. Some of the Discrete event and continuous language packages have been listed below: AutoMod eM-Plant Arena ExtendSim simulation environment for discrete event, continuous, discrete-rate and agent-based simulation.[1] GASP GPSS Plant Simulation Simio software for discrete event, continuous, and agent-based simulation.[2] SimPLE++ SimPy, an open-source package based on Python SIMSCRIPT II.5, a well established commercial compiler Simula Java Modelling Tools, an open-source package with grap

Simulation Software

Discuss the following periods in simulation history? a. The period of Search: Simulation was conducted in FORTRAN and other gernal purpose languages. No specific simulation specific routines. Much effort was on expanding searcn for unifying concepts and the development of reusable routines to facilitate simulation(1955-60) b Advent : It is the period of forerunners of SPL we use today(1961-65) GPSS developd by Geoffery Gordon at IBM and appeared in 1961. General Purpose Simulation system was developed for quick simulation of communication and computer system. It is a block disgram based representation (similar to process flow diagram) and suited for queuing models. Phillip J Kiviat developed GASP (General Activity based simulation program). Originally it was based on GPL ALGOL but later based on FORTRAN. other SPL developed are SIhMULA(extension of ALGOL) c. The Formative period (from 1966-1970) Concepts were reviewed adn refined to promote more consistent re

Linear Congruential method ( Random Number generation )

#include #include #define true 1 #define false 0 void main() { int x[30]; int flag=true,i,a,c,m,x0; float r[30]; printf("\n Enter a,c,m,x0"); scanf("%d%d%d%d",&a,&c,&m,&x0); x[0]=x0; i=1; while(flag==true) { x[i]=(a*x[i-1]+c)%m; r[i]=x[i]/(float)m; if(x[i]==x[0])//Now onwards series will repeat flag=false; i++; printf("x[i]=%d\n",x[i-1]); } getch(); } omprakash sharma 4552/09

Weibull Distribution Implementation (Simulation and Modeling)

#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; } Pankaj kumar mca4506/09

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&

Measures of Central tendency

According to Prof Bowley averages are statistical constants which provide an idea about the concentration of values in the central part of the distribution. The five common measures of central tendency are : 1. Mean [Airthmetic mean] 2. Median 3. Mode 4. harmonic mean 5. Geometric mean According to Prof. Yule following are the characterstics required to measure central tendency: 1. Central tendency should be rigidly defined 2. It should be comprehensive and easy to determine 3. Should be based on all observations 4. It should not be much affected by the fluctuation of sampling 5. It should not be affected by extreme values Let us talk about these distributions in detail: 1. Arithmetic mean: Arithmetic mean of a set of observations can be calculated as their sum divided by the number of observations In case f i is the frequency of variable x i then distribution becomes ' Properties of Arithmetic Mean 1. Algebric sum of deviations of a set of v

simulation question bank

What is simulation? List a few advantages and disadvantages of simulation. Differentiate between the following: Continuous and Discrete Systems Static and Dynamic Systems Open and Closed Systems Deterministic and Stochastic activities Static Physical Models and Dynamic Physical Models Static Mathematical Models and Dynamic Mathematical Models Write short notes on Monte –Carlo methods M/M/1 model Continuous probabilistic distributions Binomial Distribution Bernoulli Distribution Exponential Distribution Poisson Distribution Erlang Distribution Log normal distribution Geometric distribution Hyper geometric distribution Normal distribution What is Discrete system simulation? Write short notes on GPSS. Explain at least 5 GPSS block-diagram symbols. What do you mean by Action Times and Succession of Events. Design a supermarket simulation model using GPSS symbols. Design a Telephone System simulation model using GPSS symbols. Writ

Simulation Practice Problems

1. There is only one telephone in a public booth of a metro station. Following table indicates the distribution of arrival time and duration of calls: Time Between arrivals (minutes) 4 5 6 Probability 0.1 .6 0.3 Call Duration (minutes) 3 4 5 6 Probability 0.14 0.6 0.12 0.14 Simulate for 100/500/1000 times. Conduct 3 such trials. It is proposed to add another telephone to the booth. Justify the proposal based on the waiting time of caller.Generate graphs to support your answer. 2. A baker needs to find out the cookies he need to bake each day. The probability distribution for the cookies customers is as follows: Number of customers/day 7 9 11 14 Probability 0.35 0.30 0.15 0.20 C

Simulation and Modeling FAQ continued

1. Discuss the usage of DEVS in detail? 2. Describe the steps involved in a simulation study?Illustrate with a relevant example 3. Explain the four steps involved in the model building process? 4. Simulation can be used to solve traffic problems at major intersections?Explain the steps involved to carry this simulation study? 5. How can simulation be used to study the queuing systems? 6. Describe pictorially the arrival and departure in a queuing system? 7. Give an example of Single channel queue. How can you use simulation to study such a system? 8. What according to you are the performance measures required to analyze a queuing system? 9. How will you calculate following performace measures for a sing server queuing system a. Average waiting system. b. Probability a customer has to wait. c. probability of idle server d. Average service time e. Expected service time f. Average time between arrivals. g. Average time customer

Simulation & Modeling FAQs

1. Discuss the advantages and disadvantages of Simulation? 2. Discuss with example case when not to use Simulation? 3. What according to you are the real world problems where you find simulation is the most appropriate tool? 4. Discuss the role play of simulation in following fields? 1. Business Processes? 2. Manufacturing Application 3. Military Applications 4. Logistics and Supply chains 5. Discuss system and its components in detail? 6. Differentiate the following a. Open System and Closed System b. Exogenous and Endogenous System c. Discrete and continuous system d. Static Vs Dynamic system 7. what are the different types of models/ 8. Name the entities,attributes,activities,events and state variables for the following systems a. College library b. Mobile Call center c. Hospital Ward d. Departmental Store e. Airport ticketing