Skip to content

An M/M/1/K queue Python3 simulator that compares the simulation results against the analytics results. The queue have limited capacity K and processes may be blocked (if queue is full) or leave queue before get service (there is a deadline for each process) or get service from server.

License

Notifications You must be signed in to change notification settings

kargaranamir/M-M-1-Queue-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

M-M-1-Queue-Simulator

M/M/1/K queue Python3 simulator

A M/M/1/K queue Python3 simulator that compares the simulation results (QSim.py module) against the analytics results (QAnalyic.py module). The queue have limited capacity K and processes may be blocked (if queue is full) or leave queue before get service (there is a deadline for each process) or get service from server.

Features

  • Compute probability of process blocking or leaving in a limited queue in analytic and simulation ways

How to use

import QAnalytic
import QSim

if __name__ == "__main__":
# set parameters
    mu = 1 # service rate
    theta = 2 # deadline rate or deadline time
    lambdas = 5 # arrival rate of customers
    num_customers = 10 ** 6 #number of customers in simulation 
    queue_size = 12 #size of queue
    is_exp_drop = True # or False
    
    simulator = QSim.simulator(lambda_,
                                mu,
                                theta,
                                queue_size,
                                is_exp_drop)

    analyzer = QAnalytic.analyzer(lambda_,
                                  mu,
                                  theta,
                                  queue_size,
                                  is_exp_drop)

            sim_pb, sim_pd = simulator.run(num_customers)
            anal_pb, anal_pd = analyzer.run()
            print(f"is_exp_drop:{is_exp_drop}, lambda:{lambda_}, mu:{mu}, theta:{theta} => simulation pb:{sim_pb}, analytic pb:{anal_pb}, simulation pd:{sim_pd}, analytic pd:{anal_pd} \n")

Parameters

QSim and QAnalytic
lambda_ : arrival rate of customers
mu: server rate
theta: deadline rate or deadline time
size: size of the Queue (K)
is_exp_drop: Is deadline time follow a exponential distribution? or not (Fixed)?
num_customers: number of customers

License

GNU General Public License v3.0

About

An M/M/1/K queue Python3 simulator that compares the simulation results against the analytics results. The queue have limited capacity K and processes may be blocked (if queue is full) or leave queue before get service (there is a deadline for each process) or get service from server.

Topics

Resources

License

Stars

Watchers

Forks

Languages