Chapter 3 Monte Carlo Computations & Simulation

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

System Simulation and Modeling - ITec4163 Department of IT

Chapter 3: Monte Carlo Computation & Stochastic Simulation

Monte Carlo Simulation: refers to the type of simulation in which a static, approximate, and
stochastic model is used for a deterministic system.
These techniques are based on the use of random numbers and probability statistics to investigate
problems in areas as diverse as economics, nuclear physics, and flow of traffic.

Example: Monte Carlo Calculation of π


Let us now look at an example of Monte Carlo simulation. Consider estimating the value of pi by
finding the approximate area of a circle with a unit radius. The first quadrant of the circle is
enclosed by a unit square.
If pairs of uniformly distributed pseudo-random values for the x and y coordinates in [0, 1] are
generated, the probability of the corresponding points falling in the quarter circle is simply the
ratio of the area of the quarter circle to that of the unit square.

4
System Simulation and Modeling - ITec4163 Department of IT

Let us illustrate the use of the MC technique as a method of integration and let us begin with a
simple geometric MC experiment which calculates the value of π based on a "hit and miss"
integration.

Monte Carlo integration: Such an integral can be partitioned into segments above or below the
horizontal axis. Without loss of generality, let us assume f (x)>=0, a <= x<=b. We can then
bound the curve with a rectangle with borders of x = a, x = b, y = 0, and y = y max, where y max
is the maximum value of f (x) in the interval [a, b]. By generating random points uniformly
distributed over this rectangular area, and deciding whether they fall above or below the curve f
(x), we can estimate the integral.

4
System Simulation and Modeling - ITec4163 Department of IT

 MC simulation gives properties via ensemble averaging. Random numbers are used to
generate large number of states of the system (members of an ensemble) with a
distribution characteristic for a given statistical mechanics ensemble.
 Metropolis Monte Carlo – a method to generate a sequence of random states of the
system with probability distribution characteristic for the system in equilibrium.
 If we start our simulation away from the equilibrium, the random walk in MC should
bring us to the equilibrium. We can use MC to find equilibrium structure and
composition.
 Simulations discussed until now are performed at constant T without any special efforts.
No need to ensure that energy is conserved after a trail move.
 MC can be adapted to the calculation of averages in any statistical mechanics ensemble.
For example, simulation of isothermal – isobaric ensemble involves random volume
change (volume is added to the set of independent variables that characterize the state of
the system); simulation of grand-canonical ensemble has “moves” that insert/delete
atoms/molecules.
 MC cannot address kinetics or dynamical properties (diffusion, mean square
displacements, velocity autocorrelation functions, vibrational spectra etc.)

4
System Simulation and Modeling - ITec4163 Department of IT

Dynamic Simulation
Dynamic stochastic simulation models will be emphasized. A dynamic simulation program that
is written in a general purpose programming language (such as
Turing) must:
 keep track of ‘‘simulated’’ time,
 schedule events at ‘‘simulated’’ times in the future, and
 cause appropriate changes in state to occur when ‘‘simulated’’ time reaches the time at
which one or more events take place.
The structure of a simulation program may be either time-driven or event-driven, depending on
the nature of the basic loop of the program. In time-driven models, each time through the basic
loop, simulated time is advanced by some ‘‘small’’ (in relation to the rates of change of the
variables in the program) fixed amount, and then each possible event type is checked to see
which, if any, events have occurred at that point in simulated time. In event driven models,
events of various types are scheduled at future points in simulated time. The basic program loop
determines when the next scheduled event should occur, as the minimum of the scheduled times
of each possible event. Simulated time is then advanced to exactly that event time, and the
corresponding event handling routine is executed to reflect the change of state that occurs as a
result of that event.

Stochastic Simulation:
A stochastic simulation is a simulation that traces the evolution of variables that can
change stochastically (randomly) with certain probabilities.
With a stochastic model we create a projection which is based on a set of random values. Outputs
are recorded and the projection is repeated with a new set of random values of the variables.
These steps are repeated until a sufficient amount of data is gathered. In the end,
the distribution of the outputs shows the most probable estimates as well as a frame of
expectations regarding what ranges of values the variables are more or less likely to fall in.

4
System Simulation and Modeling - ITec4163 Department of IT

Pure Pursuit Problem: A fighter aircraft sights an enemy bomber and flies directly toward it,
in order to catch up and destroy it. We have to determine the attack course of the fighter and how
long does the fighter take to catch up with the bomber.
If the target flies along a straight line, the problem can be solved directly with analytic
techniques. But if the path of the bomber is curved, the problem cannot be solved directly. We
can solve such problems using simulation.
We are given following conditions:

 Both target and pursuer are flying in the same 2 dimensional plane.
 The fighter's speed is constant that is VF.
 The target's path is known.
 Minimum distance required by the fighter to fire a missile at bomber is 10 units.
 If the target is not caught within given time t∘ (here t∘ = 12), the target escapes.
 Initial coordinates of the pursuer (fighter) are known.

4
System Simulation and Modeling - ITec4163 Department of IT

We will choose our coordinate system such that, initially target will be lying on the X axis and
pursuer will be lying on Y axis as shown in the figure below.
The fighter looks at the target at instant t, aligns its velocity vector with line of sight (i.e. points
itself towards the target). It continues to fly in that direction for one unit of time (up to t+1). At
(t+1) it looks at the target again and realigns itself.

4
System Simulation and Modeling - ITec4163 Department of IT

SIMULATION OF PURE PURSUIT PROBLEM


Bomber Aircraft and the Fighter Aircraft are flying in the same horizontal plane. For simulation
purpose it is assumed that both the Aircrafts are flying in a rectangular coordinate system with
corners (0,0) & (1000,1000). Velocity of the fighter Aircraft is assumed to be 20 units per
second. When the distance between the Bomber and the Fighter is less than 100 units, it is
assumed that the Bomber is shot down. When the distance between them is more than 900 units,
it is assumed that the Bomber escapes from the sight of the Fighter. The initial positions of the
Bomber and Fighter is decided randomly. During the pursuit, the position of the Bomber is
randomly generated.

4
System Simulation and Modeling - ITec4163 Department of IT

Queueing Systems
Most simulations contain queues as part of the model. Queueing theory refers to the
mathematical models used to simulate these queues.
A queueing system consists of at least a server, a waiting line, and a calling population.
A queueing system is described by • Calling population • Arrival rate • Service mechanism •
System capacity • Queueing discipline.

Examples;

 people being served at an ATM,


 1 cars served (serviced) in a garage,
 1 printer jobs at a local network,
 1 requests to a web server

Discipline refers to the logical order in which customers are served. Often used models are:
 FIFO (first-in-first-out), LIFO (last-in-first-out);
 SIRO (service in random order);
 SPT (shortest processing time first);
4
System Simulation and Modeling - ITec4163 Department of IT
 PR (service according to priority).

Example

Problem:
As a first example, we look at a simple queue model which has an infinite population, one queue,
and one server.

Solution:
Suppose inter-arrival times are determined by rolling a die. If the numbers 6, 1, 4, 3, 6, 5 are
rolled this means that the customers arrive at times 0,6,7,11,14,20,25 as in the following table:

4
System Simulation and Modeling - ITec4163 Department of IT

Two-Server Model
We consider a second simulation. Here two servers serve one queue. We assume that a customer
is served by the server that is available. If both servers are available then the customer is
assigned randomly to one of the servers. The servers take different times to serve a customer
(these could be mechanics, one being more senior and faster than the other, or network servers,
where one model is older than the other).

4
System Simulation and Modeling - ITec4163 Department of IT

SIMULATION IN INVENTORY MANAGEMENT

An inventory control system should take into account key factors such as demand fluctuation
based on market trends, spoilage in unstable goods such as food or chemicals, shrinkage due to
spills, product damaged in shipping, and shrinkage caused by staff. Demand fluctuation based on
market trends can only be predicted in a general sense by analyzing past precedences with
similar products and how they relate to new items. In contrast, the spoilage of unstable goods is
usually a very predictable process and can be minimized by effectively estimating how much
product will be sold before the shelf-life of the item expires, thereby eliminating over-
purchasing. Within inventory control, estimating the market demand for unstable goods and
ensuring that the company does not buy too much or too little of a product is among the most
difficult of tasks, and must be supported by large volume data samples before an informed
decision can be made. Shrinkage due to spills can be minimized through the employee training
programs, although the exact amount of shrinkage will vary dramatically between locations and
require some real-world data gathering. Shrinkage due to internal and external staff can be
virtually eliminated by enhancing systemic security protocols, including adequate security
monitoring and loss-prevention technology.

Choosing an inventory control strategy for the simulation experiment requires an intimate
knowledge of the specific nature of the business being analyzed. A small-scale greengrocer, for
example, should focus their inventory control strategy on anticipating consumer demand and
minimizing loss due to spoilage, whereas a large stable goods retailer such as Wal-Mart, Kmart
or Target can afford to make large purchase orders of items, store them in a warehouse and
distribute them internally while receiving volume purchasing discounts. To provide efficient
service to customers, it is necessary to choose reorder point with proper consideration of demand
during lead time. If the lead time and demand of inventory per unit time both are random
4
System Simulation and Modeling - ITec4163 Department of IT
variables, then the simulation techniques can be applied to determine the effect of alternate
inventory policies on a stochastic inventory system i.e. different combinations of order quantity
and reorder point. Thus, we run the inventory system artificially by generating the future
observations on the assumptions of the same distributions. In inventory control, the problem of
determining the replenishment policy due to uncertain demand and lead time can be solved by
simulation. Instead of trying manually the three replenishment alternatives for each level of
demand and lead time for a period of one year and then selecting the best one, we process on the
computer and obtain the results in a very short time at a small cost. Uncertainty and variation in
construction process has an important influence on project performance. The common practice to
deal with variation is the holding of inventory. A suitable inventory improves the performance of
project. However, excessive inventory induces no-added value. Simulation experiments show
that application of DES (discrete event simulation) and CONWIP(constant work-in-progress)
provides an effective way of inventory control, simultaneously, maintain throughout the cycle
time .

Using advanced computer simulation models is an economical way to help in decision-making


which allows the user to visualize the effects of changes to existing systems and what the costs
will be prior to implementation. Just -in-Time(JIT), Total Quality Management (TQM), decision
support systems for continuous improvement, graphical display of physical elements, simulating
dynamic changes of the system, communication tool, problem understanding tool, AS-IS vs. TO-
BE models, random behavior of system elements captured in models, manufacturing oriented
models, models usually represent the flow of physical object, is used in Inventory control
management. A simulation model of a production system could be used for investigating
operating strategies that would reduce the size of inventory, machine cycle times, assess various
scheduling rules, or reduce the level of faults. By doing this, any changes to be done to the real
system could be tested on the model to avoid risks of inadequate decisions, and business
activities could then be better understood. When changes tested on the model are implemented in
the real system, effectiveness of the system should be improved as well as the competitiveness of
an organization. Simulation can be performed for existing or proposed systems to help cost-
justification of decisions for improving the productivity of a system(Simulation). It analyzes the
trade-offs between demand forecasts, material availability, lead times, and resource capacity to
reduce product time in the supply chain and meet inventory and safety stock targets. Models
were developed to include all the planning, production, and distribution functions in the current
business process. It helps planners to meet forecasted and unexpected demand for produced
goods. A supply chain process is made up of the flow of materials, information, and services and
the monitoring and control of this flow, which includes raw materials, procurement, production,
inventory management, order processing, warehousing, transportation, and distribution. The
development of functions to support these operations is known as supply chain management
(SCM). Simulations can help with justifying capital equipment expenditures, flexible automation
changes, the effects of downtime and setup time of the new system, and material handling
selections.

You might also like