Various elevator algorithms complete with a passenger load simulator and activity monitor for measuring efficiency.
- Node.js 18.x or higher
- npm 8.x or higher
npm install- Decide which algorithm you want to run (details below):
- Independent
- Call the associated script. For example:
npm run independentnpm test- Run all unit testsnpm run lint- Check code for linting errorsnpm run lint:fix- Automatically fix linting errorsnpm run format- Format code with Prettiernpm run format:check- Check if code is formatted correctly
The project uses Jest for testing. All tests are located alongside their respective modules with a .test.js suffix.
npm testOne of the primary curiosities of this project is to write and evaluate the efficiencies of various algorithms that control elevators. In this context, efficiency means reducing both the amount of time a passenger must wait to board an elevator and how long they must be inside the elevator.
This algorithm was the first and it's not at all optimised. In this implementation each elevator operates completely independently with no consideration for the state of the other elevators. This causes all elevators to respond to a single passenger, which is one of the main behaviours that will improve efficiency in other algorithms. Perhaps a coordinator or shared queue would be more efficient. That said, this does work and the tests pass.
Building
elevatorCountnumberOfLevelsnumberOfSublevels
Elevator
idfloordirectiondoorsOpen
Passenger
sourcedestinationinElevator(0while not inside or the id of the elevator once inside)waitTimetravelTime
- Runtime: Node.js (ES Modules)
- Testing: Jest
- Linting: ESLint 9 (flat config)
- Formatting: Prettier
- CI/CD: GitHub Actions
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting:
npm test && npm run lint - Format your code:
npm run format - Submit a pull request
All pull requests are automatically checked by CI for tests, linting, and formatting.