Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/janisz/task
Elevator Control System
https://github.com/janisz/task
Last synced: 22 days ago
JSON representation
Elevator Control System
- Host: GitHub
- URL: https://github.com/janisz/task
- Owner: janisz
- License: bsd-2-clause
- Created: 2015-12-22T12:02:52.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-22T17:05:21.000Z (almost 9 years ago)
- Last Synced: 2023-03-23T07:49:56.153Z (over 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elevator
## Run
To build project you should have JDK 8 then just run `./gradlew build` to run tests and get binary jar.
## Task
Design and implement an elevator control system. What data structures, interfaces and algorithms will you need?
Your elevator control system should be able to handle a few elevators — up to 16.You can use the language of your choice to implement an elevator control system. In the end,
your control system should provide an interface for:* Querying the state of the elevators (what floor are they on and where they are going),
* receiving an update about the status of an elevator,
* receiving a pickup request,
* time-stepping the simulation.For example, we could imagine in Scala an interface like this:
trait ElevatorControlSystem {
def status(): Seq[(Int, Int, Int)]
def update(Int, Int, Int)
def pickup(Int, Int)
def step()
}Here we have chosen to represent elevator state as 3 integers:
* Elevator ID
* Floor Number
* Goal Floor NumberA pickup request is two integers:
* Pickup Floor
* Direction (negative for down, positive for up)This is not a particularly nice interface, and leaves some questions open. For example,
the elevator state only has one goal floor; but it is conceivable that an elevator holds more than one person,
and each person wants to go to a different floor, so there could be a few goal floors queued up.
Please feel free to improve upon this interface!The most interesting part of this challenge is the scheduling problem.
The simplest implementation would be to serve requests in FCFS (first-come, first-served) order.
This is clearly bad; imagine riding such an elevator! Please discuss how your algorithm improves on FCFS in your write-up.Please provide a source tarball (or link to a GitHub repository) containing code in the language of your choice,
as well as a README discussing your solution (and providing build instructions).
The accompanying documentation is an important part of your submission. It counts to show your work.Good luck!
## Solution
I tried to solve this assignment with following idea: Let all elevators keep track of their passengers and pickup requests.
Global controller is responsible only for finding elevator that could first serve people in the moment they press UP/DOWN
button. Each elevator has it's own priority queue witch is responsible for optimally schedule visiting floors and also
give a priority to people that are already inside (unless they click DOWN button but then want to go UP) and with less
priority people waiting for lift.
Probably better approach could be to store global registry of pickups than move it locally to elevator, because when user
get inside he decide where to go which could increase waiting time, but is also harder to implement.