This project attempts to solve the problem of allocating patients to hospital wards, considering their admission days, and surgery days, using metaheuristic algorithms such as Hill Climbing, Simulated Annealing, Tabu Search, and Genetic Algorithm.
It includes a graphical interface to easily load instances and visualize the evolution of solution costs.
- Python 3.8 or higher
matplotlibtkinter(usually included in Python on Windows/macOS; may need to be installed manually on Linux)
Simply run the main script:
python main.pyThis will launch a graphical interface (built with tkinter) where you can:
- Load
.datinstance files. - Choose one of the metaheuristic algorithms.
- Select the initialization strategy (
Worst,Random,Optimized). - Visualize the cost evolution over iterations.
- View the final patient allocation (ward, admission day, surgery day).
- Save results to a text file in the
results/folder.
├── main.py # GUI + control logic
├── algorithms/
│ ├── genetic_algorithm.py
│ ├── simulated_annealing.py
│ ├── tabu_search.py
│ ├── hill_climbing.py
│ └── genetic_utils.py
├── allocation/
│ ├── patient_allocation.py
│ └── allocation_criteria.py
├── solution_utils/
│ ├── solution_generator.py
│ └── evaluation_criteria.py
├── parser/
│ └── parser.py
├── results/ # Saved output files
├── data/ # For instance files
└── requirements.txt
- Hill Climbing
- Simulated Annealing
- Tabu Search
- Genetic Algorithm
- Includes support for memetic enhancement (hybrid with local search)
Each algorithm evaluates cost based on:
- Delay in admission
- OT over/underuse
- Bed overflow
- Workload excess and workload distribution
For each execution:
- The solution is printed in the GUI.
- The cost evolution is plotted.
- A summary is saved to
results/, including:- Initial cost
- Final cost
- Absolute and relative improvement
- Final allocation of each patient
- Input files must be in
.datformat. - The project handles both feasible and infeasible solutions and applies penalties accordingly.
- This system is designed for experimentation and comparison of different metaheuristic strategies.
Developed By:
Sofia Reis, up201905450
Miguel Valente, up201704608
Gonçalo Ferros, up202207592
For the IART (Artificial Intelligence) course at FEUP.
Supervised by Luís Paulo Reis.