This repository contains tools for solving and analyzing the Quadratic Assignment Problem (QAP) using various optimization algorithms.
qap_optimizer/: Rust-based optimization engine.analysis/: Python-based analysis and visualization module.config.toml: Centralized configuration for both components.instances/: (User-provided) Benchmark instances and solutions.data/: (Generated) CSV results and discovery data.figures/: (Generated) Analysis plots.
- Rust (latest stable)
- Python 3.11+ (with
pip)
Before running the optimizer, you must provide the QAP instances. By default, the project expects an instances/ folder in the root directory.
- Create the directory:
mkdir instances - Add
.datfiles (instances) and optionally.slnfiles (optimal solutions).
The instance files follow the standard QAPLIB format:
- The first line contains the problem size
n. - This is followed by two
n x nmatrices:- Flow Matrix: The weights between all pairs of facilities.
- Distance Matrix: The distances between all pairs of locations.
- The first line contains the problem size
nand the optimal cost. - The second line contains the optimal permutation of facilities to locations.
The project is controlled via config.toml. Key settings include:
[paths]: Define where instances are loaded from and where data/figures are saved.[instances]: Specify which instances to solve (the filenames without.dat). If the list is empty, the optimizer will process all.datfiles in theinstances_dir.[benchmarks]: Setnum_runsfor statistical significance andgreedy_top_nfor randomized heuristics.[discovery]: Configure high-repetition runs (ls_runs) for specificenabled_instancesto analyze search space properties.[analysis]: Control plot aesthetics (style, resolution) and limits (e.g.,discovery_max_restarts).
The optimizer processes the instances and saves detailed statistics to the data/ directory.
cd qap_optimizer
cargo run --releaseThe analysis module processes the generated CSV files to produce summary tables in the console and analysis plots in the figures/ directory.
cd analysis
python -m venv .venv
# Activate venv: .\.venv\Scripts\activate (Win) or source .venv/bin/activate (Unix)
pip install -r requirements.txt
python main.py- Adaptive Timing: Random Search and Random Walk are automatically timed to match Local Search algorithms.
- Simulated Annealing: Includes adaptive initial temperature (95% acceptance) and step-wise cooling.
- Lam-like Annealing: Implementation of the adaptive Lam schedule for optimized acceptance rates.
-
Tabu Search: Efficient implementation with tenure management (
$N/4$ ), candidate lists, and aspiration criteria. - Search Space Discovery: High-frequency data collection to analyze correlation between initial and final solution quality.
- Similarity Analysis: Hamming distance calculations between local and global optima.
- Expected Minima Prediction: Statistical estimation of the best expected quality after multiple restarts.