0% found this document useful (0 votes)
7 views5 pages

Assessment 01 (Modeling & Simulation)

Uploaded by

samabo2268
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

Assessment 01 (Modeling & Simulation)

Uploaded by

samabo2268
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Submitted to: Mr.

Muhammad Usman

Submitted by: Muhammad Usman

Reg.No: 2021-uam-2162

Subject: Modeling & Simulation

Section : (B)

Department: Institue of Computing

MNS University of Agriculture Multan


Assessment of Modeling and Simulation

Question no 01

Statement of Part A

“Define discrete-event simulation and continuous-event simulation. Provide real-world


examples for each type, explaining why they fit into the category of discrete or
continuous simulations”

Given Solution

1. Discrete-Event Simulation (DES)

Discrete-event simulation is a modeling approach where the state of the system changes only at
specific points in time, marked by events. Events occur instantaneously, such as an arrival,
departure, or completion of a task. Between events, the system remains static.

Example: Bank Queue System In a bank queue, customers arrive at random intervals, are
served by tellers, and leave. Events include customer arrivals, service start times, and service
completions. This fits the discrete-event category because system changes happen at discrete
times when these events occur.

2. Continuous-Event Simulation (CES)

Continuous-event simulation models systems that evolve continuously over time, often described
by differential equations. The state of the system changes constantly, not at discrete moments.

Example: Water Tank Level Simulation

The water level in a tank increases or decreases based on inflow and outflow rates. This is a
continuous simulation because the water level changes continuously over time.
Statement of Part B

“Describe the main differences between discrete-event and continuous-event simulations


in terms of Time progression and event handling, Complexity and computational
efficiency, Areas of application and limitations”

Given Solution

Differences Between DES and CES

1. Time Progression and Event Handling:

Time progresses in discrete jumps between events. Events are handled sequentially. Time
progresses continuously, often using small time steps or differential equations.

2. Complexity and Computational Efficiency:

Typically, simpler to implement, efficient for systems with low event density. More complex due
to continuous updates; computationally intensive for fine-grained accuracy.

Areas of Application

Queuing systems, manufacturing processes, network traffic.Physics simulations, fluid dynamics,


biological systems.

Limitations

Cannot model continuous changes within events. Less efficient for systems with discrete
behaviors.

Question no 02
“In a Bank Queue System simulation, customers arrive at random intervals, and each
customer requires a certain amount of time to be served by one of the available tellers.
The bank has limited tellers, so if all tellers are busy, arriving customers must wait in a
queue until a teller is free.

Using the provided Python code for the Bank Queue System simulation:

1. Set Up the Simulation:


● Set the simulation parameters as follows:
● Number of tellers: 3
● Simulation time: 30 minutes
● Average customer arrival interval: 3 minutes
● Service time range (in minutes): between 4 and 10

2. Run the Simulation and observe the following:


The time each customer arrives and leaves the bank.”

Given Solution

Simulation: Bank Queue System in Python

Here's the Python simulation for the bank queue system based on the provided parameters:

import random

import simpy

def customer(env, name, tellers):

"""Represents a customer in the bank queue."""

arrival_time = env.now

print(f"{name} arrives at the bank at {arrival_time:.2f} minutes.")

with tellers.request() as request:

yield request # Wait for an available teller

wait_time = env.now - arrival_time

print(f"{name} starts service after waiting {wait_time:.2f} minutes.")

service_time = random.randint(4, 10)

yield env.timeout(service_time) # Service duration

print(f"{name} leaves the bank at {env.now:.2f} minutes.")

def setup(env, num_tellers, arrival_interval):


"""Sets up the simulation environment with customers arriving."""

tellers = simpy.Resource(env, num_tellers)

customer_id = 0

while True:

yield env.timeout(random.expovariate(1 / arrival_interval)) # Arrival interval

customer_id += 1

env.process(customer(env, f"Customer {customer_id}", tellers))

# Parameters

random.seed(42)

simulation_time = 30 # minutes

num_tellers = 3

arrival_interval = 3 # average minutes between arrivals

# Run the simulation

env = simpy.Environment()

env.process(setup(env, num_tellers, arrival_interval))

env.run(until=simulation_time)

Observations by running code

● Arrival Time: Each customer's arrival time at the bank.


● Service Start Time: Time the customer starts being served by a teller.
● Departure Time: Time the customer leaves the bank after being served.

You can analyze these to determine average wait times and service efficiency. Let me know if
you need an extended version with detailed analysis! By running the above given code

You might also like