The program presents an algorithm that handles the elevator management system. It also provides a visualization of the designed algorithm and allows the user to try it out.
- The elevator can be in an IDLE state (not moving) or directed up/down.
- When it comes to elevators that move up and down, it is necessary for the floor from which the request is made to be located along their route.
- The elevator that is IDLE and closest to the floor from which the request is made is selected if none of the moving elevators have that floor on their route.
- If there is no elevator that meets these criteria, then the elevator with the closest destination to the given floor is chosen.
- If there are no more stops in the direction in which the elevator is moving, it changes direction (if there are stops in the opposite direction) or becomes IDLE (if there are no more stops).
I believe that my algorithm is optimal and performs better than the "First Come, First Serve" algorithm. Let's consider a scenario where passengers are waiting on the first, fifth, and eighth floors, and we have only one elevator. If the requests are sent first by the passenger on the first floor, then the eighth floor, and finally the fifth floor, even though the elevator will pass the fifth floor where a passenger is waiting, it will not pick them up. It will have to return for them later, adding extra distance and time. In such a situation, my algorithm will pick up the person waiting on the fifth floor before person waiting on eight floor, because fifth floor will be on its route to eight floor.
- Java 17
- JavaFX
- Gradle
- The icons have been sourced from here.
To run the program you can execute the following commands:
./gradlew run
or to avoid gradle command prompt use:
./gradlew -q --console plain run
The application will first ask for data. Remember that the number of elevators must be less than or equal to 16 and greater than 0. Otherwise, the program will throw an IllegalArgumentException.
The application allows for easy monitoring of the situation. At the beginning, each elevator is in the IDLE state and located on the 0th floor. On the right side, there is a sidebar that describes the current status of each elevator.
The desired floor to which the passenger wants to go can be entered in the TextField located under the red button. For example, if the passenger is on the 3rd floor and wants to go to the 10th floor, they must enter 10 in the TextField corresponding to the floor number 3. Then, to call the elevator, the red button must be pressed.
If a passenger enters a floor that does not exist (less than zero or greater than the highest floor), the program will throw an IllegalArgumentException.