Programming a simulation

# Programming a simulation - Programming a simulation...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Programming a simulation Simulation is an area where object-oriented programming really helps. This is because in a simulation, we typically have several “things” (objects) that interact with each other. We can model each “thing” by a Java class. Our project is to simulate the waiting process in a bank or post office. Using statistical data about the number of expected clients at different times of the day and what they typically want (that is, how long they need), such a simulation can be used by the bank to see how varying the number of open counters can influence the waiting time. We keep things very simple: Clients come into the bank at random time intervals (determined by the average time between clients). If a counter is open (we will say a server is free), they directly start to be served by this server, otherwise they stand in a single queue. Whenever a server finishes serving a client, the next client from the queue comes to this server. ... Client Server Server Server Server Client Client Client Client Figure 1: An illustration of the bank simulation model Discrete time-step simulation We simulate the entire process in discrete time units (called ticks ). Events such as a client coming in can only occur in these discrete time steps. for (int t = 0; t < timeSteps; ++t) sim.simulate(t); We now define what happens in each tick. There is a fixed probability that a client comes in. The probability that a client comes at a unit time interval is: 1 (mean interval of client arrival times) Although this is a Poisson process (you will run into this if you learn more about probability and statistics), for simplicity we are not considering the case that more than one clients are coming on an unit time interval.for simplicity we are not considering the case that more than one clients are coming on an unit time interval....
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

Programming a simulation - Programming a simulation...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online