Giter Site home page Giter Site logo

singleserversimulation's Introduction

Single Server Queue Simulation

This is a project on creating a single server based queuing system

To Dos:

  • Implement main()
  • void initialize();
  • void timing();
  • void arrive();
  • void depart();
  • void report();
  • void update_stats();
  • float generator();
  • Implement arrive()
  • Implement depart()

Definitions of the global variables used(shared across functions):

State Variables:

  • int:
    • num_custs_delayed: instant of time a customer is delayed
    • num_delays_required: How many customers to run simulation for? => input.txt line 3
    • next_event_type: 1 is arrive() 2 is depart()
    • num_events: 2 events possible so set at 2 used by timing()
    • num_in_queue: number of cust in a queue at an instant
    • server_status: state of server BUSY or IDLE
  • float:
    • sim_time: time of simulation
    • time_last_event: time of last arrival or departure
    • time_next_event[2]:
      • time_next_event[0] : represents the time next arrival will occur
      • time_next_event[1] : represents the time next departure will occur

Statistical counters:

  • *float:
    • avg_num_in_q: average number of cust in queue
    • avg_server_util: average utilisation of server (0-1)
    • avg_interarrival: What is the average rate at which customers arrive. i.e. mean of Poisson process to be => input.txt line 1
    • avg_service_time: We assume that a service usually takes about a fixed time. i.e. Approximation how long service takes => input.txt line 2
    • time_arrival[Q_LIMIT+1]: The arrival time array of all customers in the queue at any instant
    • total_delays: Used to calculate average delay in report(). Holds cumilitive delay for all customers.

Building and running

After cloning into a local repo:

  • compile as gcc main.c -lm
  • load 3 lines of input values into input.txt:
    • line 1: mean for arrival rate (used to generate arrival time in Poisson distribution )
    • line 2: mean for service rate (an estimation of how long each service take)
    • line 3: desired number of customers to run simulation for (imported as num_delays_required)
  • run binary program as ./a.out

Feel free to leave any comments. Peace! โœŒ

singleserversimulation's People

Watchers

Ashish avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.