0% found this document useful (0 votes)
33 views

Assignment 4

assignment

Uploaded by

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

Assignment 4

assignment

Uploaded by

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

Assignment-4 (Unit-3)

Q.7:- Write short notes on simulators and software


a. Queuing-MATLAB and simulink
b. M/M/n queuing model simulation
c. QSIM

Ans:- (a) MATLAB:-


● MATLAB (Matrix Laboratory) is a high-level programming language and
environment used for numerical computing, data analysis, algorithm
development, and visualization.
● It provides a wide range of functions for mathematical modeling and simulation.
● It offers a variety of built-in functions and toolboxes for different applications,
including simulations of queuing systems.
● In queuing theory, MATLAB can be used to model, analyze, and simulate
complex systems, such as customer service scenarios, network traffic, and
manufacturing processes.
● Users can write scripts to implement queuing models, analyze performance
metrics (like wait times and queue lengths), and visualize results using
MATLAB's powerful plotting capabilities.
● Functions like poissrnd, exprnd, and custom scripts can be used to
generate random arrival and service times based on various probability
distributions.

Key features include:

● Extensive Libraries
● Visualization Tools
● Customization

Simulink

● Simulink allows users to build graphical models of queuing systems using


blocks that represent different components of the system (e.g., arrival
processes, servers, and queues).
● Simulink's graphical interface facilitates the simulation of queuing systems,
allowing for real-time analysis and visualization of performance metrics
through various output blocks.
● Simulink is an add-on product for MATLAB that offers a graphical
environment for modeling, simulating, and analyzing dynamic systems.
● It uses block diagrams to represent system components and their
interactions, making it intuitive for users who prefer visual programming.
● Simulink can be employed to create simulations that visualize the flow of
entities through various queues and processes.

Key features include:

● Graphical Interface
● Dynamic Simulation
● Integration with MATLAB

(b) M/M/n queuing model simulation

● M/M/n queuing model is a foundational concept in queuing theory used to


analyze systems where customers arrive, wait for service, and depart after
receiving it.
● This model is particularly relevant for systems like call centers, computer
networks, and service stations.

Model Characteristics:-

(1)M: The first "M" stands for "Memoryless" or "Markovian," indicating


that the arrival process follows a Poisson distribution.
(2) M: The second "M" also represents "Memoryless," referring to the
service times, which are also exponentially distributed.
(3) n: The variable “n” denotes the number of servers available to serve
customers.

Queue Behavior:-

● In an M/M/n system, If all servers are busy, arriving customers must


wait in line until a server becomes available.

Simulation of the M/M/n Model:-

Steps to simulate an M/M/n queuing model include:

1. Initialization: Set parameters (λ,μ,n\lambda, \mu, nλ,μ,n) and initial state


variables (time, queue length, number of customers served).
2. Event Generation:
○ Customer Arrivals: Use an exponential distribution to simulate arrival
times based on λ\lambdaλ.
○ Service Completion: Use an exponential distribution to simulate
service times based on μ\muμ.
3. Event Handling: Process events in chronological order:
○ When a customer arrives, check if a server is available. If so, assign
the customer to the server; otherwise, add them to the queue.
○ When a service completes, remove the customer from service and
check the queue for waiting customers. If there are any, assign them
to the now-available server.
4. Data Collection: Track various performance metrics throughout the
simulation, such as wait times, queue lengths, and the number of customers
served.
5. Termination: Define a termination condition for the simulation (e.g., run for
a specific time or process a certain number of customers).
6. Analysis: Analyze the collected data to derive insights about the queuing
system's performance, such as average wait times and server utilization.

(c)QSIM

● QSIM stands for Queueing System Simulator.


● It is a discrete-event simulation software designed to model, analyze, and
visualize queueing systems.
● QSIM is a powerful tool for professionals and researchers seeking to
understand and optimize queueing systems.
● It is widely used in various fields such as telecommunications,
manufacturing, service industries, and computer networks, where
understanding and optimizing queue behavior is essential.

Key Features Applications

1.Discrete-Event Simulation 1. Telecommunication

2.Modeling Capabilities 2. Manufacturing

3.Customizability 3. Service Industries


4.Analysis Tools 4. Logistics and Transportation

5.Visualization
Ques8:- Write an algorithm to update the queue length for a queuing system. Queue
length is updated as and when a person joins or leave the queue.

Ans:- Step1:- Start

Step2:- // Initialize the queue length

queue_length = 0

Step3:- // Function to handle a person joining the queue

function join_queue():

queue_length = queue_length + 1

print("A person joined the queue. Updated queue length: ", queue_length)

Step4:- // Function to handle a person leaving the queue

function leave_queue():

if queue_length > 0:

queue_length = queue_length - 1

print("A person left the queue. Updated queue length: ", queue_length)

else: print("Queue is empty, no one to leave.")

Step5:- // Main execution loop (simulate events)

while true:

// Assume we receive an event indicating a person joins or leaves

event = get_next_event() // This is a placeholder for event retrieval

if event == "join":

join_queue()

else if event == "leave":

leave_queue()

Step6:- END
Ques9:- Write an algorithm to update queue length and queue time for a queuing
system if each service takes 3 minutes.

Ans:- Step1:- Start

Step2:- //Initialize Variables:

● Set queue_length to 0 (the initial number of customers in the queue).


● Set total_queue_time to 0 (the cumulative time customers spend waiting in
the queue).
● Set service_time to 3 (fixed time for servicing each customer in minutes).
● Set current_time to 0 (the simulation start time).

Step3:- //Define Function: Process Customer Arrival:

● Input: Arrival time of the customer.


● Output: Updated queue_length and total_queue_time.

Function: process_customer_arrival(arrival_time)

● If arrival_time > current_time:


○ Update current_time to arrival_time (advance the simulation clock).
● Add 1 to queue_length (a new customer has arrived).
● If queue_length == 1 (this is the first customer in the queue):
○ Update current_time to current_time + service_time (the
service starts immediately).
● Else:
○ Add service_time to total_queue_time (this customer has to wait).
● Return updated values of queue_length and total_queue_time.

Step4:- //Define Function: Process Customer Departure:

● Output: Updated queue_length.

Function: process_customer_departure()

● If queue_length > 0:
○ Subtract 1 from queue_length (a customer has been serviced).
○ If queue_length > 0:
■ Update total_queue_time by adding service_time (next
customer starts service).
○ Else:
■ Update current_time to current_time (no customers left to
service).
● Return updated value of queue_length.

Step5:- //Simulation Loop:

● For each customer in the arrival list:


○ Call process_customer_arrival(arrival_time) with their arrival
time.
○ If the queue length is greater than 0, call
process_customer_departure() after the service time.

Step6:- //Output Results:

● Display the final queue_length and total_queue_time.

Step7:- End

Ques10:- Write an algorithm to update queue length and queue time for a queuing
system. New queue is formed only when a queue has 10 or more people in the queue.
Maximum number of queue are 4, after that a person can not join the system. Service
time is 5 minute per person.Update queue length, number of queues and queue time.

Ans:- Algorithm to Update Queue Length and Queue Time

Variables:

● maxQueues: Maximum number of queues (set to 4).


● queues[]: Array to hold the current queue lengths for each queue.
● queueTime[]: Array to hold the total queue time for each queue.
● serviceTime: Time taken to serve one person (set to 5 minutes).
● totalPeople: Total number of people currently in the system.
ALGORITHM

Step1:- Start

Step2:- Initialize Variables:

● Set maxQueues = 4
● Create arrays queues[maxQueues] and queueTime[maxQueues] to
store queue lengths and queue times.
● Initialize all elements of queues and queueTime to 0.
● Set totalPeople = 0.

Step3:- Function to Add Person to Queue:

● Input: personCount (number of people trying to join the queue)


● Output: Updated queues, queueTime, and totalPeople.

Step4:- Function to Update Queue Status:

● Output: Current state of queues and total queue time.

Step5:- Main Execution:

● Call AddToQueue(personCount) whenever new people arrive.


● Call UpdateQueueStatus() to view the current state of the queues.

Step6:- End

Ques6:- Draw flow chart, write algorithm and programs for: a. Queuing Model
{(M / M /1):(∞/ FCFS)}.

Ans:-

You might also like