Notices
Notice: Exam Form BE IV/II & BAR V/II (Back) for 2076 Magh
Routine: BE IV/II & BAR V/II - 2076 Magh
Result: BCE I/II exam held on 2076 Bhadra
Result: All (except BCE & BEI) I/II exam held on 2076 Bhadra
Notice: Exam Center for Barrier Exam (2076 Poush), 1st Part
View All
View Old Questions
Computer Engineering(BCT)
Electrical Engineering(BEL)
Electronics and Communication(BEX)
View All
View Syllabus
Computer Engineering(BCT)
Electrical Engineering(BEL)
Electronics and Communication(BEX)
View All

Notes of Simulation and Modelling [CT 753]

Simulation software

 

Simulation in Java

- JAVA is a widely used programming language. But, it does not provide any modules directly aimed for simulation system.

- The components that all the simulation models written in JAVA are as follows:
1. Clock : It is a variable that defines the simulated time.
2. Initialization Method : It is a method to define the system state at initial time.
3. Min-time event method : It is a method that identifies the imminent (about to happen) event.
4. Event method: It is a method for each event that update the system state when it occurs.
5. Random variate generator : It is a method to generate random samples from the desired probability distributions.
6. Main program : It is the core of the simulation system that controls the overall event scheduling algorithms.
7. Report generator : It is a method that summarizes the collected statistics to give the report at the end of the simulation.


The time advance flowchart of the simulation models in JAVA can be depicted in the given figure:

java1


Explanation

- Simulation begins by setting clock to zero, initializing cumulative statistic to zero, generating any initial events and placing them in the FutureEventList (FEL).
- The simulation program then cycles repeatedly passing the current least time event to approximate event methods until the simulation is over.
- At each step, clock is advanced to the time of the imminent event after finding the imminent event but before calling the event method.
- The appropriate event method is called to execute imminent event, update cumulative statistics and generate future events.
- All actions in an event method takes place at one instant of the simulated time.
- When the simulation is over, the control passes to the report generator.


Example : Single Server Queue Simulation

Consider a grocery checkout counter. The simulation will run until 1000 customers have been serviced. It is assumed that the interarrival times are exponentially distributed with mean 4.5 mins and the service times are normally distributed with mean of 3.2 mins and standard deviation of 0.6 mins. When cashier is busy, a queue forms with no customers turned away.

- Class Event represents an event that stores code for arrival or departure and the event time stamp.
- It consists of associated methods for creating an event and accessing its data.
- It also has method compareTo that compares the event with another and reports whether the first event should be considered smaller, equal or greater than the argument event.

java2


Variables Used:

QueueLength
NumberInService
Customers
FutureEventList

MeanInterArrivalTime (4.5 mins)
MeanServiceTime (3.2 mins)
Sigma (0.6 mins)
TotalCustomers (1000)

Clock
LastEventTime
TotalBusy
MaxQueueLength
SumResponseTime
NumberOfDepartures
LongService

RHO = BusyTime / Clock
AVGR
PC4

Functions Used:

exponential(mu)
normal(xmu, Sigma)

Methods Used:

Initialization()
ProcessArrival()
ProcessDeparture()
ReportGeneration()


Simulation in GPSS

- GPSS (General Purpose Simulation System) is a highly structured and special purpose simulation language based on process interaction approach and oriented toward queuing systems.
- The system being simulated is described by the block diagram using various GPSS blocks.
- Each block represents events, delays or other actions that affect the transaction flow.
- GPSS model is developed by converting the block diagram into block statements and adding the control statements.


The general blocks used in GPSS block diagram is shown in figure below:

gpss3


Example 1 - Manufacturing Shop Model Simulation

A machine tool is turning outparse at a rate of 1 per every 5 minutes. As they are finished, the parse goes to an inspector, who takes 4 (+ or -) 3 minutes to examine each one and rejects about 10 % of the parse. Simulate the system using GPSS model.

IMG_20170809_122114


GENERATE 5 0
QUEUE
SEIZE
DEPART
MARK
ADVANCE 4 3
RELEASE
TABULATE
TRANSFER 0.1 ACC REJ
TERMINATE


Example 2 - Single Server Queue System (Checkout Counter)

IMG_20170809_122131


GENERATE RVEXPO(1, &IAT)
QUEUE
SEIZE
DEPART
MARK
ADVANCE RVNORM(1, &MEAN, &STDEV)
RELEASE
TEST GE M1, 4, TER
BLET &COUNT = &COUNT + 1
TER TERMINATE


Example 3 - Ambulances are dispatched at a rate of one every 15 (+ or -) 10 mins. Fifteen percent of the calls are false alarms, which require 12 (+ or -) 2 mins to complete. All other calls can be one of two kinds. The first kind are classified as serious. They constitute 15% of non false alarms and take 25 (+ or -) 5 mins to complete. The other calls take 20 (+ or -) 10 mins. Simulate the model using GPSS.

IMG_20170809_122140


GENERATE 15, 10
QUEUE
SEIZE
DEPART
MARK
TRANSFER 0.15 FALSE NON-FALSE
FALSE ADVANCE 12, 2
NON-FALSE TRANSFER 0.15 SERIOUS OTHER
SERIOUS ADVANCE 25, 5
OTHER ADVANCE 20, 10
RELEASE
TERMINATE


Simulation in SSF

- SSF stands for Scalable Simulation Framework.
- SSF provides a single, unified interface for discrete-event simulation.
- It is an API that describes a set of capabilities for object oriented and process view simulation available for C++ and JAVA.
- It is designed to achieve high performance.
- It defines five base classes; Event, Entity, inChannel, outChannel and process.
- Process implements thread of control in which action method contains the execution body.
- Entity describes simulation objects.
- inChannel and outChannel describes the communication endpoints.
- Event defines messages sent between entities.


SSF Model

1. Starting the Simulation : A simulation starts when any entity’s startAll() method is called, commonly from the main() routine. The caller of startAll() speci- fies two timestamps: the simulation’s start time, which defaults to 0, and the end time.

2. Initialization : After startAll() has been called, but before any process has started executing, the framework calls the init() routines of all processes and entities. The Entity method now() shall return the simulation start time for the duration of initialization.

3. Process Execution : After all processes have been initialized, they become eligible to run at the start time; their actual execution is controlled by the framework, which executes the process’s action() callback method. Every time the action() method returns to the caller, the framework executes it again immediately, as many times are are necessary to reach the end of the simulation.

4. Framework Inner Loop : The SSF framework provides nonpreemptive scheduling of processes. Once resumed by the framework, in order to allow the simulation clock to advance, processes must eventually suspend themselves by issuing waitOn() or waitFor() calls. Within the framework, simulation time advances at a (possibly variable) rate determined by the arrival of events on channels, and the duration of waitFor() statements. When simulation time exceeds the end time specified in the original startAll() call, the simulation ends.

5. Start, Pause, Resume and Join : The startAll(), pauseAll(),resumeAll(), and joinAll() methods may not be called from within process code. The pauseAll() method allows the simulation to be paused gracefully after some implementationdependent delay. A call to pauseAll() blocks until the simulation has paused, and then returns the current simulation time. After pauseAll(), a call to resumeAll() resumes the simulation’s forward progress. At any point, a call to joinAll() (e.g., from main()) will block without possibility of pause or resumption until simulation execution is complete.

6. Framework Concurrency : Each entity is said to be aligned to some object. Processes that are eligible to execute at each instant of simulation time will be scheduled by the framework: sequentially within an alignment group (but in implementation-dependent order), and concurrently across alignment groups.

7. Simulation Time : The behavior of an SSF model is defined by the collective actions of its processes on its state. Every process resumption takes place at a particular simulation time, and each modification of model state by that resumption of the process takes place at that time.


Example : Single Server Queue System (Checkout Counter)

1. SSQueue Class : It is the class that contains the whole simulation experiment. It defines the experimental constants, contains SSF communication endpoints and defines inner class arrival.

2. Arrival process : It is a SSF process that stores identity of entity, creates a random number generator and enqueue the generated new arrivals, then blocks for inter arrival time.

3. Server process : It is the process that is called when a job has completed service or by a signal from the arrival process. It also updates statistics. Customers are dequeued from the waiting list or the process suspends if no customers were waiting.


Other simulation software

Selection of Simulation Software

1. Model Building Features
- It is the features that facilitates the development process of the model.
- It includes modeling worldview, input data analysis capability, graphical model building, simulation programming, syntax, input flexibility, randomness, and so on.

2. Runtime Environment
- It is the feature that determines how the model acts during the simulation run.
- It includes execution speed, model size, interactive debugger, model statistics and so on.

3. Animation and Layout Features
- It is the feature that maps the graphical motions of the objects or entities during the simulation run.
- It includes animation type, import files, dimension, movement, motion qualities, navigation, display step, views and so on.

4. Output Features
- It is the feature that optimizes the output of the simulation model.
- It includes scenario manager, run manager, independent replication, optimization, reports, statistical analysis, file export and so on.

5. Vender Support Features
- It is the feature that shows how the user can get support from the vender whenever necessary.
- It includes training, documentation, help system, tutorials, support, upgrades, maintenance and so on.


Sponsored Ads