This project simulates elevator behavior using a finite state machine (FSM) and a per-tick scheduler. It includes a JavaFX GUI, CSV-driven passenger arrivals, and configurable elevator parameters.
- Model realistic elevator behavior with clear, testable state transitions
- Explore scheduling choices (direction, prioritization, capacity, patience)
- Produce logs and per-passenger metrics for analysis
- FSM-driven elevator states: STOP, MVTOFLR, OPENDR, OFFLD, BOARD, CLOSEDR, MV1FLR
- Call prioritization across floors via
CallManager - Passenger groups with politeness and give-up (timeout) behavior
- CSV-based configuration and test scenarios
- Logging and per-passenger outcome exports
src/building/: core simulation (Building, Elevator, Floor, Passengers, CallManager)src/: GUI (ElevatorSimulation) and controller (ElevatorSimController)src/genericqueue/: queue utilitysrc/myfileio/: lightweight file I/O helperstest_data/,test_data2/: sample passenger scenarios and configscmpElevator.jar: optional log comparison tool used by some tests
- Use a JDK with JavaFX (or add the JavaFX SDK to your IDE run configuration).
- Place a config file named
ElevatorSimConfig.csvin the repo root. For example:- copy
test_data2/ElevatorSimConfig.csvtoElevatorSimConfig.csv
- copy
- Ensure
passCSVin that file points to a valid passenger CSV (e.g.test_data2/ElevatorTest.csv). - Run
ElevatorSimulation(JavaFXApplication) with the working directory set to the repo root.
From the repo root (example for macOS/Linux):
export PATH_TO_FX=/path/to/javafx-sdk/lib
javac --module-path "$PATH_TO_FX" --add-modules javafx.controls,javafx.graphics -d out $(find src -name "*.java")
java --module-path "$PATH_TO_FX" --add-modules javafx.controls,javafx.graphics -cp out ElevatorSimulationOn Windows, use ; instead of : in module paths and an equivalent file list (e.g. dir /s /b src\\*.java).
ElevatorSimConfig.csv is read from the working directory by ElevatorSimController and supports:
numFloorsnumElevatorspassCSV(path to passenger CSV)capacityfloorTicksdoorTickspassPerTick
ElevatorSimConfig.csv:
numFloors,6
numElevators,1
passCSV,test_data2/ElevatorTest.csv
capacity,15
floorTicks,5
doorTicks,2
passPerTick,3Header + rows:
Time,NumPass,FromFloor,To Floor,Polite,Wait
Floors in the CSV are 1-based; the simulation converts them to 0-based internally.
Example:
Time,NumPass,FromFloor,To Floor,Polite,Wait
10,3,1,6,TRUE,1000<passCSV-name>.logif logging is enabled (GUI "Log" button orBuilding.enableLogging()in tests)<passCSV-name>PassData.csvwith per-passenger outcomes (wait-to-board, total time, give-up)
Example log lines:
CONFIG: Capacity=15 Ticks-Floor=5 Ticks-Door=2 Ticks-Passengers=3 CurrState=STOP CurrFloor=1
Time=12 Prev State: STOP Curr State: MVTOFLR PrevFloor: 1 CurrFloor: 1
Example PassData rows:
ID,Number,From,To,WaitToBoard,TotalTime
0,3,1,6,5,23
1,2,3,1,12,-1- The GUI currently visualizes a single elevator, even if multiple are configured.
ElevatorSimConfig.csvis loaded from the working directory, so run from the repo root.- Passenger CSVs use 1-based floors; internal simulation uses 0-based indexing.
- JavaFX is required to run the GUI.
Add a GIF or screenshot of the GUI here to make the README more inviting.
JUnit 5 test suites live in src/ (e.g. BuildingFSMBasicTest, ExecFullElevatorTests). Run them from your IDE or a JUnit runner with the working directory set to the repo root. Some tests invoke cmpElevator.jar for log comparisons.