Giter VIP home page Giter VIP logo

task's Introduction

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 Number

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

task's People

Contributors

janisz avatar

Watchers

James Cloos avatar  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.