Elevator control system for the company Wonderland.
Design and implement an elevator control system for the company Wonderland. What data structures, interfaces and algorithms will you need? Your elevator control system should be able to handle multiple 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 should be possible.
We expect that your code is well-factored, without needless duplication, follow good practices and be automatically verified.
What we will look at:
- How clean is your design and implementation, how easy it is to understand and maintain your code
- How you verified your software, if by automated tests or some other way
I've chosen Java as programming language and Spring Boot as framework to build the application. The application can be run via command line and the interaction with it is done via REST.
To keep it simple, I've decided to have maximum 10 floors and maximum 10 open pickup requests per elevator.
The number of elevators can be configured in application.properties.
To be able to run the application JDK 11 needs to be installed. Then it can be run by executing the following command:
mvn spring-boot:runReturns all elevators with its current floors, directions, open pickup requests and pickup requests in progress.
curl --request GET 'localhost:8080/api/v1/elevator'
Sends a pickup request. The request is assigned to an elevator if there is an
elevator available. If no elevator is available, the pickup request will remain
open until there is an elevator available. The maximum number of open
unassigned pickup requests is <number of elevators> * 10.
curl --request POST 'localhost:8080/api/v1/elevator/pickup' \
--header 'Content-Type: application/json' \
--data-raw '{
"currentFloor": 8,
"destinationFloor": 1
}'
To perform one time step in the simulation it is necessary to trigger the corresponding endpoint. It's possible to trigger several time steps within one single request.
The parameter numberOfSteps is optional. If there is no such parameter one
time step will be performed.
curl --request POST 'localhost:8080/api/v1/elevator/step?numberOfSteps=10'
- The maximum limit for pickup requests is a random number to have such a limit.
- There is no instance that holds information about assigned requests. If one elevator would loose the information about a request, the request would be gone.
- Distributing the pickup requests is basic and needs improvement.
- E.g.: Elevator is at floor 1 and has an assigned request "from 8 to 4" and
the elevator is moving up. When another request comes in "from 8 to 5" one
would think that it will get assigned to the same elevator. But this is
not the case yet because the logic in
PickupRequestRatingis not good enough for it.
- E.g.: Elevator is at floor 1 and has an assigned request "from 8 to 4" and
the elevator is moving up. When another request comes in "from 8 to 5" one
would think that it will get assigned to the same elevator. But this is
not the case yet because the logic in
- ... let's talk about it :-) ...