Giter Site home page Giter Site logo

elevator's Introduction

Simple Elevator Prototype

Background & Motivation

An office building has 10 floors and one simple elevator. The people working there are distributed evenly across all floors. The lift has only one external button on each floor. Inside the lift, there is a set of buttons to send the lift to a desired floor. The lift has a maximum capacity of 8 people.

Solutions

Elevator algorithm

The elevator algorithm has two rules:

  • As long as there is someone inside who wants to keep going in that direction or ahead of the elevator, keep heading in that direction.
  • Once the elevator has exhausted the requests in its current direction, switch directions if there's a request in the other direction. Otherwise, stop and wait for a call.

Following the elevator algorithm, the maximum wait time for a passenger would be 90 seconds (10 floors, 10 seconds to travel between adjacent floors). The maximum travel time would be 170 seconds (passengers wants to go from floor 9 to floor 10, and picked up while the elevator is going down). The elevator algorithm ensures that all passengers are served within a reasonable period of time.

Assumptions made

Passengers:

  • Passengers are infinitely patient, and would always wait at the floor until picked up by the elevator.
  • Passengers never change their minds about their destination floor, and would always go to the desired floor.
  • All passenger list passed in is sorted by start waiting at time. This would be the case in for a real elevator, as time flows in only one way.

Elevators:

  • It has no wait time between each floor, even when picking a passenger up (i.e. the time it takes for passenger to enter the lift is much smaller than the time taken for the lift to travel between floor).

Technical Details

The solutions contain 4 classes:

  • CSVFile: reading the passengers' information from a csv file and writing the results to an output.csv file.
  • Elevator: encapsulating the behaviour of an elevator in our prototype.
  • Passenger: encapsulating the behaviour of a passenger.
  • Simulation: encapsulating the information and functionalities needed for the prototype.

The Main() method can be found in the Simulation.cs file.

Results

The result of the simulation is saved in "output.csv". According to the algorithm presented here under the listed assumptions, the elevator takes 665 seconds to respond to all the calls.

The "output.csv" file has 4 columns:

  • Current Time: the current time, in seconds. The simulation starts at time = 1.
  • People In Lift: the list of IDs of the people currently in the lift.
  • Current Floor: the current position of the lift.
  • Floor Queue: the list of floor in order that the lift would have to go to.

Future Enhancements

Measure the performance of the elevator

  • Passenger class to record the customer journey time (time from when the passenger enters the elevator to when the passenger leaves the elevator at the desired floor)
  • Passenger class to record the customer wait time (time from when the passenger starts waiting to when the elevator picks the passenger up)

Enhance the prototype to make it more realistic

  • Add the time elevator wait between floors
  • Run multiple elevators per building
  • Allow passengers to specify which direction (up or down) they would like to travel in

elevator's People

Contributors

lexievu 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.