You are on page 1of 20

Simulation and Modelling

Chapter Three

Monte Carlo Computations vs. Stochastic


Simulation

By: Hayelom M. (PhD Candidate at UESTC)


Monte Carlo Simulation
• Monte Carlo method is a (computational)
method that relies on the use of random
sampling and probability statistics to obtain
numerical results for solving deterministic or
probabilistic problems.
• Give an approximate solution to a problem
that is too big, too hard, too irregular for
deterministic mathematical approach
Application of Monte Carlo Simulation
• Monte Carlo simulation methods are
especially useful in studying systems with a
large number of coupled degrees of freedom,
such as fluids, disordered materials, strongly
coupled solids, and cellular structures.
• Monte Carlo simulation methods do not
always require truly random numbers to be
useful.
• while for some applications, such as primality
testing, unpredictability is vital.
Cont..
• Two types of applications:
1. The problems that are stochastic (probabilistic)
by nature:
• Particle transport,
• Telephone and other communication systems,
• Population studies based on the statistics of survival
and reproduction.
2. The problems that are deterministic by nature:
• The evaluation of integrals,
• Solving partial differential equations
Cont..
Monte-Carlo methods generally follow the following steps:
1. Define a domain of possible inputs and determine the
statistical properties of these inputs
2. Generate many sets of possible inputs that follows
the above properties via random sampling from a
probability distribution over the domain
3. Perform deterministic calculations with these input sets
4. Aggregate and analyze statistically the results

The error on the results typically decreases as 1=1/sqrt(N)


• Given a high-resolution computer image of a map of an irregularly shaped
lake with several islands, determine the water surface
area.
• Assume that the x-y coordinates of every point on the map can be measured.

Figure 1: Monte Carlo Simulation


Step 1:
Enclose the area of interest in the smallest rectangle of known dimensions X
and Y.
Set j = 1, S = 0, and choose a large value for N where:
j = trial number
S = number of hits on the water surface area
N = total number of trials
Step 2:
Generate a uniformly distributed random number, RNx
over the length of X.
Step 3:
Generate another uniformly distributed random number, Rny over the length of
Y.
Step 4:
If the point of intersection, (RNx , RNy), falls on the water
surface area, add 1 to S.
Step 5:
Add 1 to j. If j > N, go to Step 6; otherwise, go to Step 2.
Step 6:
The estimate of the water surface area, A, is given by:
Simulation of a Pure-pursuit Problem
• Pure pursuit is a tracking algorithm that
functions by scheming the curvature that will
shift a vehicle from its existing position to
some objective position.
• The entire point of the algorithm is to select a
goal position that is some distance forward of
the vehicle on the path.
Pursuit Algorithm
The execution of the pure pursuit algorithm itself
is quite simple. The pure pursuit algorithm
can be summarized as below:
1. Establish the current location of the vehicle.
2. Locate the path point closest to the vehicle.
3. Locate the goal point
4. Convert the goal pole to vehicle coordinates.
5. Compute the curvature and appeal the vehicle
to set the routing to that curvature.
6. Update the vehicle’s location.
Case Study
• Establish the current location of the vehicle. Both the HMMWV
and NavLab have a central vehicle organizer that offers functions
which account the vehicle’s current location as (x,y,heading). The
position is reposed with respect to the vehicle’s location at
initialization time. This original location is the global reference
frame for the run.
• Locate the path point closest to the vehicle. In the geometric origin
it was confirmed that the goal point would be inside one look ahead
distane of the vehicle. It is probable that there are numerous points
one look ahead distance from the vehicle’s existing location.
The vehicle should steer toward the closest point one look ahead
distance from its existing location. So, the path point closest to the
vehicle will first be establish, and the search for a point 1 look ahead
distance away from the vehicle will start at this point and initiate up
the path.
Cont..
• Locate the goal point. The goal point is set up by
moving up the path and computing the distance
between that path point and the vehicle’s existing
location. Path point positions are recorded in the
global frame; this computation is done in
worldwide coordinates.
• Convert the goal point to vehicle coordinates.
Once the goal point has been establish, it must be
converted to the vehicle’s local coordinates. The
derivation for the curvature was performed in
vehicle coordinates and curvature commands to the
vehicle make sense in
vehicle. coordinates.
Cont..
• Compute the curvature. Using the curvature
equation, compute the desired vehicle
curvature. The curvature is converted into
steering wheel angle by the vehicle’s on board
controller.
• Update the vehicle’s location. During
simulation, it is essential to determine what
effects the command has upon the vehicle’s
location and heading.
Single-Server Queuing System

• In the mini type super-market, there is a cash


desk, and customers reaches the desk in random.
• Provided that the customer reaches as the
cashier is idle, the customer will pay off
immediately and leave.
• If the cashier is busy as the customer reaches,
the customer will have to wait in the line, no
person leaves without waiting.
• Once the customer enters in the queue, he will
receive service according to FCFS rule.
Cont..
• A Single-sever service node consists of a server plus its queue.
• Queue discipline: The algorithm used when a job is selected from
the queue to enter service
– FIFO – first in, first out
– LIFO – last in, first out
– SIRO – serve in random order
– Priority – typically shortest job first (SJF)
• FIFO is also known as first come, first serve (FCFS)
1. The order of arrival and departure are the same
2. This observation can be used to simplify

Figure
Cont..

• Service is non-preemptive
Once initiated, service of a job will continue
until completion
• Service is conservative
Server will never remain idle if there is one or
more jobs in the service node
Cont..
Single Server Simulation Algorithm
Cont..
Q&A

I Thank You

You might also like