GithubHelp home page GithubHelp logo

awanishsingh / elevator-simulator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from donnemartin/elevator-simulator

0.0 1.0 0.0 388 KB

Simulates four elevators available to take passengers up and down a 100 floor building

License: Other

C++ 99.61% C 0.39%

elevator-simulator's Introduction

elevatorsimulator

Simulates four elevators available to take passengers up and down the floors of a 100 floor building, written in C++.

Simulation mechanics:

  • There are 4 elevators available to take passengers up and down the floors of a 100 floor building.
  • Each Elevator can be stopped, stopping, moving up, or moving down.
  • It takes an elevator 2 seconds of stopping to be stopped.
  • It takes each elevator 10 seconds of moving to move between each floor.
  • There is a maximum of 8 passengers allowed in a single elevator.
  • The elevator data file determines when passengers ask for an elevator, their starting floor, and their destination floor.
  • A passenger arrives at the start floor at the start fime, waits for the elevator to arrive and stays on the elevator until arriving at the end floor.
  • When a elevator arrives at a floor, it picks up all of the passengers waiting at the floor, up to the maximum capacity of 8, and then starts moving to the End Floors.
  • Passengers are queued waiting, if necessary, for elevators.
  • The simulation performs one loop each simulated second.
  • During each loop, each object decides what to do.
  • If stopped and current time is equal to or greater than the next start time, the elevator either begins moving up or moving down depending on the direction needed to pick up the passenger.
  • If moving up or moving down and there are one or more passengers waiting at a floor along the way, or if there are current passengers with end floor being the current floor, it begins stopping.
  • When stopped at a floor, if there are any passengers in the elevator with that end Floor as a destination, it discharges the passengers. Then, if there are any passengers with that floor as their start Floor it picks up passengers up to the capacity of the elevator.
  • Only one elevator can pick up a passenger.
  • There is no central controller of elevators as each elevator is making its own decisions as to which passengers to pick up and discharge, therefore there are no conflicts.

The simulation implements an elevator solution then determines the average wait time and the average travel time it takes for passengers. The simulation is run twice, one for each elevator taking 10 seconds to move between each floor, and the other for each elevator taking 5 seconds instead. For the second run, the simulation determines the % reduction of average wait time and the % reduction of average travel time for passengers.

##License

Copyright 2014 Donne Martin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Elevator data:

alt tag

Simulation run snippet:

alt tag

Simulation results:

alt tag

elevator-simulator's People

Contributors

donnemartin avatar

Watchers

 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.