review from last time
play

Review from Last Time Motivations to do simulations Modeling - PDF document

Review from Last Time Motivations to do simulations Modeling characteristics CSCI 8220 Simulation & Modeling Time and event driven simulations Process Oriented Simulation 2 Maria Hybinette, UGA Maria Hybinette, UGA


  1. Review from Last Time � � Motivations to do simulations � � Modeling characteristics CSCI 8220 Simulation & Modeling � � Time and event driven simulations Process Oriented Simulation 2 Maria Hybinette, UGA Maria Hybinette, UGA Today Event-Oriented World View Event handler procedures state variables � � � Event-Oriented Simulation (review) Departure � Arrival � Landed � Integer: InTheAir; � � � Process-oriented simulation Integer: OnTheGround; � Event � Event � Event � Boolean: RunwayFree; � { � { � { � » � Fundamental concepts: Processes, resources … � … � … � » � Simulation primitives } � } � } � Simulation application � » � Example Simulation executive � » � Implementation Event processing loop while(simulation not finished) � Now = 8:45 � � E = smallest time stamp event in PEL � Pending Event List (PEL) � � Remove E from PEL � 9:00 � 10:10 � � Now := time stamp of E � 9:16 � � call event handler procedure � 3 4 Maria Hybinette, UGA Maria Hybinette, UGA Example: Event-Oriented Air traffic Execution Example Simulation State � R=3 � Variables � Now: current simulation time � G=4 � InTheAir : number of aircraft landing or waiting to land OnTheGround : number of landed aircraft RunwayFree : Boolean, true if runway available InTheAir � 0 � 1 � 2 � 1 � 0 � Arrival Event: � OnTheGround � 0 � 1 � 2 � 1 � 0 � InTheAir := InTheAir+1; � if( RunwayFree ) � RunwayFree � true � false � true � � RunwayFree:=FALSE; � 0 � 1 � 2 � 3 � 4 � 5 � 6 � 7 � 8 � 9 � 10 � 11 � � Schedule Landed event @ Now + R; � Simulation Time � Landed Event: � Processing: � Arrival F1 � Arrival F2 � Land F1 � Land F2 � Depart F1 � Depart F2 � InTheAir := InTheAir-1; � Time � Event � Time � Event � Time � Event � Time � Event � Time � Event � Time � Event � Time � Event � OnTheGround := OnTheGround + 1; � 1 Arrival F1 � Schedule Departure event @ Now + G; � 3 Arrival F2 � 3 Arrival F2 � if( InTheAir > 0 ) Schedule Landed event @ Now + R; � 4 Land F1 � 4 Land F1 � 7 Land F2 � else RunwayFree := True; � 8 Depart F1 � 8 Depart F1 � Departure Event: � 11 Depart F2 � 11 Depart F2 � OnTheGround := OnTheGround - 1; � Now=0 � Now=1 � Now=3 � Now=4 � Now=7 � Now=8 � Now=11 � 5 Maria Hybinette, UGA

  2. Event-Oriented World View Process Oriented Event handler procedures state variables � � � A simulation process models a specific entity Departure � Arrival � Landed � Integer: InTheAir; � with a well defined behavior. Integer: OnTheGround; � Event � Event � Event � Boolean: RunwayFree; � » � It describes the action performed of the process { � { � { � through out its lifetime. … � … � … � – � Models a specific entity with well defined behavior } � } � } � Simulation application � and it is encapsulated within the process. � � Event-oriented simulation programs may be difficult to – � Example: an aircraft understand and modify: � � Event oriented view: lifetime of an event is a » � Program organized around state transitions SINGLE instant in time. » � Behavior of an aircraft distributed across multiple event handlers � � Process oriented view: lifetime is a time » � Flow of control among event handlers not obvious period of the ‘process’ or ‘thread’ » � Suppose you want to model: Different aircrafts, airlines, pilots – imagine events for each segment (volume) of airspace 7 8 Maria Hybinette, UGA Maria Hybinette, UGA Event versus Process Oriented Views Process Oriented Execution Model Event Oriented View � � Focus simulation program around behavior of entities state variables � » � Aircraft: arrives, waits for runway, lands, departs Arrival � Landed � Departure � Integer: InTheAir; � Event � Event � Event � � � Process-oriented simulation Integer: OnTheGround; � Boolean: RunwayFree; � { � { � { � » � Process : Thread of execution describing entity behavior over time … � … � … � » � Resources : Shared resource used by entities (e.g., the runway) } � } � } � � � Execution: alternate between Focus of model is on EVENTS and how they affect the state of the simulation. » � simulation computations at a single instant of simulation time, and Process Oriented View » � advances in simulation time (no computation) Simulation time advances state variables � Aircraft1 � Aircraft2 � AircraftN � Computation at a single (no computation) Integer: InTheAir; � Instant of simulation time { � { � { � Integer: OnTheGround; � Arrive � Arrive � Arrive � Boolean: RunwayFree; � Land � Land � Land � Computation Time advance Computation Time advance Depart � Depart � Depart � } � } � } � 9 10 Entities modeled by processes. Wall clock time Maria Hybinette, UGA Maria Hybinette, UGA Simulation Primitives Process Model Example: Aircraft Primitives needed to advance simulation time A new aircraft process is created with each Arrival event � � AdvanceTime( T ) : advance T units of simulation time /* simulate aircraft arrival, circling, and landing */ » � Also called “hold” Integer: InTheAir; Integer: OnTheGround; » � Example: AdvanceTime(R) to model using runway R units Boolean: RunwayFree; of simulation time � � WaitUntil( p ) : simulation time advances until predicate 1 InTheAir := InTheAir + 1; p becomes true 2 WaitUntil( RunwayFree ); /* circle */ » � Predicate based on simulation variables that can be modified 3 RunwayFree := FALSE; /* land */ by other simulation processes 4 AdvanceTime( R ); » � Example: WaitUntil(RunwayFree) to wait until runway 5 RunwayFree := TRUE; becomes available for landing /* simulate aircraft on the ground */ 6 InTheAir := InTheAir - 1; � � Other combinations 7 OnTheGround := OnTheGround + 1; » � WaitUntil(p,T) : Wait up to T units of simulation time for 8 AdvanceTime( G ); predicate p to become true /* simulate aircraft departure */ » � Not used in the air traffic example 9 OnTheGround := OnTheGround - 1; 11 12 Maria Hybinette, UGA Maria Hybinette, UGA

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend