Você está na página 1de 59

Simulation and Modeling - 732

B. Tech. (IT)
SEMESTER - VII SEMESTER - VII
Part I
July - 2013
System Simulation
Introduction
Simulation is a very powerful and widely used
computational science technique for the analysis and study
of complex systems.
Simulation may be defined as a technique that imitates the
operation of a real-world system as it evolves over time.
This is normally done by developing a simulation model. A This is normally done by developing a simulation model. A
simulation model usually takes the form of a set of
assumptions about the operation of the system, expressed
as mathematical or logical relations between the objects of
interest in the system.
Simulation has its advantages and disadvantages. We will
focus our attention on simulation models and the
simulation technique.
Simulation
What is simulation
The !rocess o" desi#nin# a mathematical or
lo#ical model o" a real-system and then lo#ical model o" a real-system and then
conductin# com!uter-$ased e%!eriments &ith
the model to descri$e' e%!lain' and !redict
the $eha(ior o" the real system)
Simulation
Where simulation "its in
Programming
Simulation
Analysis
Modeling
Probability
&
Statistics
*asic Terminolo#y
In most simulation studies' &e are concerned &ith
the simulation o" some system)
Thus' in order to model a system' &e must
understand the conce!t o" a system)
Definition: + systemis a collection o" entities that
act and interact to&ards the accom!lishment o"
some lo#ical end)
Systems #enerally tend to $e dynamic , their status
chan#es o(er time) To descri$e this status' &e use
the conce!t o" the state o" a system)
E%am!les o" - Simulation Model
-ano cars - num$ers o" cars !roduced !er day
.throu#h!ut/
Emer#ency Room , .$eds' doctors' nurses/' .minor'
moderate' ma0or' critical/ moderate' ma0or' critical/
Missile , *allistic Missile Sur(i(a$ility a#ainst Some
Threat
Institutes .IIIT +/ Par1in# !lace
Po&er Inte#ration , Semiconductor 2a!acity' and
random machine do&n times
Value o" Simulation
Em!irical Method (erses Mathematical model
+llo& you to calculate the e%treme (alues not +llo& you to calculate the e%treme (alues not
0ust the e%!ected (alue
Simulation
What is simulation
Simulation is the actual running of the model
system to gain insight into its performance. system to gain insight into its performance.
Simulation
Why use simulation
Simulation is used to better understand the
expected performance of the real system and to expected performance of the real system and to
test the effectiveness of the system design.
Simulation
Why use simulation
Without $uildin# them
e%!erimental system
ne& conce!ts ne& conce!ts
Without distur$in# them
costly e%!erimentation
unsa"e e%!erimentation)
Without destroyin# them
3etermine limits o" stress
Alternative to simulation
Simulation
+nalytic models
Physical e%!erimentation Physical e%!erimentation
Visit other sites
Simulation (s) +nalytic modelin#
+d(anta#e
(arious !er"ormance measures
#reater realism
easier to understand easier to understand
model the steady-state as &ell as the transit
$eha(ior)
3isad(anta#e
May not !ro(ide you &ith the o!timal
solution
time to construct model &ill $e lon#er)
Simulation (s) Physical
+d(anta#e
4i#h S!eed
-ot disru!ti(e
Re!lication easy Re!lication easy
2ontrol (ariations
5enerally less costly
3isad(anta#e
Realism
Validity
Simulation (s) +lternati(es
V A S P
Realism
V A
V A S P
Cost
Re!resentin# system
System
a collection o" mutually interactin# o$0ects
desi#ned to accom!lish a #oal .machines
re!air system/ re!air system/
Entities
denotes an element6o$0ect &ithin $oundary
o" system .machines' o!erators' re!airman/
Entity , &or1 $ein# !er"ormed on o$0ect
Resource , !er"ormin# the &or1
Re!resentin# system
+ttri$ute
2haracteristic or !ro!erty or an entity
.machine I3' Ty!e o" $rea1do&n' time that
machine &ent do&n/ machine &ent do&n/
+cti(ity
trans"orms the state o" an o$0ect usually o(er
some time .re!airman ser(ice time' machine
run time/
Re!resentin# system
State o" the system
-umeric (alues that contain all the
in"ormation necessary to descri$e the system
at any time) at any time)
3elays
Processes that ta1e a conditional len#th o"
time in the system
Re!resentin# system
E(ents
2han#e the state o" the system.end o" ser(ice
o" machine'machine $rea1s do&n/
7ueue
it is set' used to model &aitin#
E%) Ele(ator systems
Entities
Ele(ators' !eo!le
Sets
Peo!le &aitin# at each "loor
+ttri$utes
Ele(ators , ca!acity' s!eed' destination'
current location o" each ele(ator
Peo!le , inter-arri(al time at each "loor'
destination o" each !eo!le
E%) Ele(ator systems
State o" system
8 o" !eo!le on each ele(ator
8 o" !eo!le in each "loor
+cti(ities +cti(ities
9oad6:nloadin# !assen#er
Tra(el to ne%t "loor .s!eed and distance/
Persons tra(el to ele(ator
E%) Ele(ator systems
3elays
Persons &aitin# "or ele(ator
E(ents
Ele(ator arri(al
End unloadin#
End 9oadin#
Person +rri(al
Simulation ty!es
Static (s) dynamic
3eterministic (s) stochastic
2ontinuous (s) discrete
Simulation model system model Simulation model system model
Static Simulation (s) 3ynamic
Simulation
There are t&o ty!es o" simulation models'
static and dynamic)
Definition: + static simulation model is a
re!resentation o" a system at a !articular re!resentation o" a system at a !articular
!oint in time)
We usually re"er to a static simulation as a
Monte 2arlo simulation)
Static Simulation (s) 3ynamic
Simulation
Definition: + dynamic simulation is a
re!resentation o" a system as it e(ol(es
o(er time)
Within these t&o classi"ications' a Within these t&o classi"ications' a
simulation may $e deterministic or
stochastic)
+ deteministic simulation model is one
that contains no random (aria$les; a
stochastic simulation model contains one
or more random (aria$les)
3iscrete E(ent (s) 2ontinuous
E(ent Simulation
3iscrete e(ent
state o" system chan#es only at discrete !oints
in time.e(ents/
e%) Machine re!air !ro$lem e%) Machine re!air !ro$lem
Pro#rammin#
9oo1 at system only &hen e(ents occur; time is
ad(anced "rom e(ent to e(ent)
3iscrete E(ent (s) 2ontinuous
E(ent Simulation
2ontinuous e(ent
state o" system chan#es continuously o(er
time
E%) 9e(el o" "luid in tan1 E%) 9e(el o" "luid in tan1
Pro#rammin#
+d(ances time in small inter(als) :se di""erential
e<uations to re!resent "lo&s)
+n E%am!le o" a 3iscrete-E(ent
Simulation
To simulate a <ueuin# system' &e "irst ha(e to
descri$e it)
We assume arri(als are dra&n "rom an in"inite callin#
!o!ulation)
There is unlimited &aitin# room ca!acity' and There is unlimited &aitin# room ca!acity' and
customers &ill $e ser(e in the order o" their arri(al
.=2=S/)
+rri(als occur one at a time in a random "ashion)
+ll arri(als are e(entually ser(ed &ith the distri$ution
o" ser(ice teams as sho&n in the $oo1)
Ser(ice times are also assumed to $e random) +"ter
ser(ice' all customers return to the callin#
!o!ulation)
=or this e%am!le' &e use the "ollo&in# (aria$les to
de"ine the state o" the system .1/ the num$er o" de"ine the state o" the system .1/ the num$er o"
customers in the system; .2/ the status o" the ser(er
, that is' &hether the ser(er is $usy or idle; and
.3/the time o" the ne%t arri(al)
+n e!ent is de"ined as a situation that causes the
state o" the system to chan#e instantaneously)
3iscrete E(ent Simulation
E(ent schedulin#
Write modules that descri$e chan#es in the
state o" the system at each e(ent
Main !ro#ram ad(ances time Main !ro#ram ad(ances time
>ne su$!ro#ram "or each e(ent
5eneral !ur!ose !ro#rammin# lan#ua#e
3iscrete E(ent Simulation
Process interaction
Write modules that descri$e the !ro#ress o"
entities throu#h the system
+s entities mo(e the systems chan#es state +s entities mo(e the systems chan#es state
Entities are held to re!resent acti(ities and
delays
Promodel !ro#rammin# lan#ua#e
E(ent schedulin#
Time is ad(anced "rom e(ent to e(ent
=uture e(ents list , ordered list o"
u!comin# e(ents
+s e(ents are scheduled' they are added to
the list
+s e(ents occur they are remo(ed "rom list
+cti(ities in e(ent . one 6 e(ent ty!e/
E(ent schedulin#
9ist is re<uired to 1ee! trac1 o" entities in a
set
Statistics , T&o ty!es
Sam!le statistics , a(era#e o" some (alues
.W/
W ? .W1 @W2 @ A@Wn/6n ? Total Wait 6 8 o" &ait
Time a(era#e statistics , time &ei#hted .9/
9 ? .0.t1/ @ 1.t2-t1/ @ 2.t3-t2/ @ 1.tB-t3// 6 tB
+cti(ity scannin#
+cti(ity scannin#
Time is modeled in "i%ed time increments to
chec1 i" acti(ity occurred
Small time increments is ine""icient Small time increments is ine""icient
9ar#e time increments may miss acti(ity
descri$es the acti(ities in &hich the entities in
the system en#a#e)
Process >riented
Process oriented
Many simulation models include elements
&hich occur in de"ined !atterns
The lo#ic associated &ith such a system or The lo#ic associated &ith such a system or
e(ents can $e #eneraliCed and de"ined $y a
sin#le statement
+ simulation lan#ua#e could then translate
such statement into the a!!ro!riate se<uence
o" e(ents
descri$es the !rocesses throu#h &hich the
entities in the system "lo&)
Process >riented
Process oriented
These statements' de"ine a se<uence o"
e(ents &hich are automatically e%ecuted $y
the simulation lan#ua#e as the entities mo(e the simulation lan#ua#e as the entities mo(e
throu#h the !rocess
2reate arri(al entities e(ery t time units
4o&e(er' since &e are normally restricted to a
set o" standardiCed statement' !ro(ided $y
the simulation lan#ua#e' our model "le%i$ility
is not as #reat as &ith the e(ent condition
=eature !ro(ided $y a lan#ua#e
2once!tual "rame&or1.entities' attri$utes'
resource' <ueues/
Maintenance o" e(ent list
Random (aria$le #eneration Random (aria$le #eneration
+nimation
3e$u##in# "unction
>ut!ut analysis
In!ut analysis
Re!ort #eneration
The Simulation Modelin# Ste!s
We no& discuss the !rocess "or a com!lete
simulation study and !resent a systematic a!!roach
o" carryin# out a simulation)
+ simulation study normally consists o" se(eral
distinct sta#es) distinct sta#es)
4o&e(er' not all simulation studies consist o" all
these sta#es or "ollo& the order stated here)
>n the other hand' there may e(en $e considera$le
o(erla! $et&een some o" these sta#es)
+ircra"t Per"ormance Model
an e%am!le o" 3eterministic Systems Modelin#
Lift force (L) = Weight of aircraft (W)
Engine Thrust (T) = Drag force (D)
+ircra"t Per"ormance Model))
Expressions for lift and drag forces
+ircra"t Per"ormance Model))
Rate of decrease of aircraft weight due to fuel
consumption
An empirical relation for drag polar relating C
L
and C
D
Now the collection model equations
+ircra"t Per"ormance Model))
OR
The air density ratio at an altitude
T =
Where = 9296 $elo& 11 Dm
The "ngineeing
#o$lem Sol!ing
B3
#ocess
Newtons 2
nd
law of Motion
The time rate change of momentum of a body is equal
to the resulting force acting on it.
Formulated as F = m.a
F = net force acting on the body
m = mass of the object (kg)
a
2
BB
a = its acceleration (m/s
2
)
Some complex models may require more sophisticated
mathematical techniques than simple algebra
Example, modeling of a falling parachutist:
F
U
= Force due to air resistance = -cv (c = drag coefficient)
F
D
= Force due to gravity = mg
U D
F F F + =
cv mg dv
cv F
mg F
F F F
m
F
dt
dv
U
D
U D

=
=
=
+ =
=
This is a first order ordinary differential equation.
We would like to solve for v (velocity).
It can not be solved using algebraic manipulation
Analytical olution!
If the parachutist is initially at rest (v"# at t"#)$
using calculus dv%dt can be solved to give the result!
m dt
=
v
m
c
g
dt
dv
=
using calculus dv%dt can be solved to give the result!
( )
t m c
e
c
gm
t v
) / (
1 ) (

=
Independent
variable
Dependent
variable
Parameter
s
Forcing function
**here Analytical Solution
( )
t m c
e
c
gm
t v
) / (
1 ) (

=
t (sec.) V (m/s)
0 0
If v(t) could not be solved analytically, then
we need to use a numerical method to solve
g = 9.8 m/s
2
c =12.5 kg/s
m = 68.1 kg
BE
0 0
2 16.40
4 27.77
8 41.10
10 44.87
12 47.49
53.39
) (
) ( ) (
lim ........
) ( ) (
1
1
0
1
1
i
i i
i i
t
i i
i i
t v
m
c
g
t t
t v t v
t
v
dt
dv
t t
t v t v
t
v
dt
dv
=

+
+

+
+
c
This equation can be rearranged to
yield
Numerical Solution
BF
) )]( ( [ ) ( ) (
1 1 i i i
t t t v
m
c
g t v t v
i i
+ =
+ +
yield
t = 2 sec
To minimize the error, use a smaller step size, t
No problem, if you use a computer!
t (sec.) V (m/s)
0 0
2 19.60
4 32.00
8 44.82
10 47.97
12 49.96
53.39
t (sec.) V (m/s)
0 0
2 19.60
4 32.00
8 44.82
t (sec.) V (m/s)
0 0
2 16.40
4 27.77
8 41.10
m=68.1 kg c=12.5
kg/s g=9.8 m/s
t = 2 sec
Analytical
t (sec.) V (m/s)
0 0
2 17.06
4 28.67
8 41.95
t = 0.5 sec
t (sec.) V (m/s)
0 0
2 16.41
4 27.83
8 41.13
t = 0.01 sec
Numerical solution
vs.
8 44.82
10 47.97
12 49.96
53.39
8 41.10
10 44.87
12 47.49
53.39
( )
t m c
e
c
gm
t v
) / (
1 ) (

=
t t v
m
c
g t v t v
i i i
+ = + )] ( [ ) ( ) ( 1
8 41.95
10 45.60
12 48.09
53.39
8 41.13
10 44.90
12 47.51
53.39
CONCLUSION: If you want to minimize
the error, use a smaller step size, t
Manual Simulation E%am!le
5i(en the "ollo&in# arri(al times "or a sin#le ser(er
system &hat &ill $e the a!eage num$e in the
%ueue' a!eage num$e in the system& a!eage time
in system& a!eage time in %ueue' the num$e of
com'leted (o$s& num$e in the %ueue& num$e in com'leted (o$s& num$e in the %ueue& num$e in
the system& and se!e utili)ation at time 1G i" the
ser(ice time is 3 time units "or each entity)

1' 3' G' H'13'1G'1F


3istri$uti(e Systems
G0
3istri$uti(e Systems
The Messa#e Passin# Paradi#m
Message 'assing is the most fundamental 'aadigm fo disti$uted
a''lications.
* 'ocess sends a message& often e'esenting a e%uest.
The message is deli!eed to a ecei!e& +hich 'ocesses the message&
and 'ossi$ly sending a message in es'onse.
In tun& the e'ly may tigge a futhe e%uest& +hich leads to a
su$se%uent e'ly& and so foth.
G1
In tun& the e'ly may tigge a futhe e%uest& +hich leads to a
su$se%uent e'ly& and so foth.
Process A
Process B
a message
Message passing
The Messa#e Passin# Paradi#m - 2
The $asic o'eations e%uied to su''ot the $asic message 'assing
'aadigm ae send& and receive.
,o connection-oiented communication& the o'eations connect and
disconnect ae also e%uied.
-ith the a$staction 'o!ided $y this model& the inteconnected
'ocesses 'efom in'ut and out'ut to each othe& in a manne simila
to file I./. The I./ o'eations enca'sulate the details of net+o0
G2
to file I./. The I./ o'eations enca'sulate the details of net+o0
communication at the o'eating-system le!el.
The Client The Client The Client The Client- -- -Server Paradigm Server Paradigm Server Paradigm Server Paradigm
Best known paradigm for network applications -- the client-server
model assigns asymmetric roles to two collaborating processes.
One process, the server, plays the role of a service provider which
waits passively for the arrival of requests. The other, the client,
issues specific requests to the server and awaits its response.
G3
.
.
.
service request
a server process
a client process
a service
The Client-Server Paradigm, conceptual
Server host
Client host
The Client The Client The Client The Client- -- -Server Paradigm Server Paradigm Server Paradigm Server Paradigm- 2
Simple in concept, the client-server model provides an efficient
abstraction for the delivery of services.
Operations required include those for a server process to listen for
and to accept requests, and for a client process to issue requests
and accept responses.
By assigning asymmetric roles to the two sides, event
GB
By assigning asymmetric roles to the two sides, event
synchronization is simplified: the server process waits for requests,
and the client in turn waits for responses.
Many Internet services are client-server applications. These
services are often known by the protocol that the application
implements. Well known Internet services include HTTP, FTP, DNS,
finger, gopher, etc.
The Peer-to-Peer System +rchitecture
htt!66&&&)!eer-to-!eer&#)or#6&hatis6inde%)html
In system architecture and net&or1s' !eer-to-!eer is an
architecture &here com!uter resources and ser(ices are
directly e%chan#ed $et&een com!uter systems)
These resources and ser(ices include the e%chan#e o"
in"ormation' !rocessin# cycles' cache stora#e' and dis1
stora#e "or "ilesA
GG
stora#e "or "ilesA
In such an architecture' com!uters that ha(e traditionally
$een used solely as clients communicate directly amon#
themsel(es and can act as $oth clients and ser(ers' assumin#
&hate(er role is most e""icient "or the net&or1)
The Peer-to-Peer 3istri$uted 2om!utin#
Paradi#m
In the peer-to-peer paradigm, the participating processes play equal
roles, with equivalent capabilities and responsibilities (hence the
term peer). Each participant may issue a request to another
participant and receive a response.
process 1
3istri$uted So"t&are Systems GE
request
response
request
response
process 2
Peer-to-Peer distri$uted
com!utin#
Whereas the client-server paradigm is an ideal model for a
centralized network service, the peer-to-peer paradigm is more
appropriate for applications such as instant messaging, peer-to-peer
file transfers, video conferencing, and collaborative work. It is also
possible for an application to be based on both the client-server
model and the peer-to-peer model.
3istri$uted So"t&are Systems GF
model and the peer-to-peer model.
A well-known example of a peer-to-peer file transfer service is
Napster.com Napster.com Napster.com Napster.comor similar sites which allow files (primarily audio files)
to be transmitted among computers on the Internet. It makes use of
a server for directory in addition to the peer-to-peer computing.
3istri$uted So"t&are Systems GI
Peer-to-Peer distri$uted
com!utin#
The !eer-to-!eer !aradi#m can $e im!lemented &ith "acilities usin# any tool
that !ro(ide messa#e-!assin#' or &ith a hi#her-le(el tool such as one that
su!!orts the !oint-to-!oint model o" the Messa#e System !aradi#m)
=or &e$ a!!lications' the web agent is a !rotocol !romoted $y the J-S>R5
.the J-S Pu$lic Trust >r#aniCation/ "or !eer-to-!eer inter!rocess
communication
KPro0ect JJT+ is a set o" o!en' #eneraliCed !eer-to-!eer !rotocols that allo&
3istri$uted So"t&are Systems GH
KPro0ect JJT+ is a set o" o!en' #eneraliCed !eer-to-!eer !rotocols that allo&
any connected de(ice .cell !hone' to P3+' P2 to ser(er/ on the net&or1 to
communicate and colla$orate) JJT+ is short "or Ju%ta!ose' as in side $y
side) It is a reco#nition that !eer to !eer is 0u%ta!ose to client ser(er or
We$ $ased com!utin# -- &hat is considered todayLs traditional com!utin#
model) K

Você também pode gostar