A comprehensive Django-based web application for solving and comparing various combinatorial optimization problems using multiple algorithmic strategies.
-
Multiple Problem Types
- Knapsack Problem
- Traveling Salesman Problem (TSP)
- Graph Matching Problem
-
Multiple Solving Algorithms
- Greedy Algorithm
- Divide & Conquer
- Dynamic Programming
- Backtracking
- Branch & Bound
-
Flexible Input Methods
- Manual input via web forms
- File upload (CSV, JSON, TXT)
- Random problem generation
-
Performance Benchmarking
- Compare multiple algorithms simultaneously
- Visualize runtime, memory usage, and solution quality
- Interactive charts using Chart.js
-
Legacy Mode
- Backward-compatible single-algorithm solver
- Focused on Knapsack problem
- Python 3.8+
- Django 4.0+
- Modern web browser with JavaScript enabled
-
Navigate to the project directory
cd combinatorial_optimization_django
-
Create and activate virtual environment
Windows (CMD):
python -m venv venv venv\Scripts\activate
Windows (PowerShell):
python -m venv venv venv\Scripts\Activate.ps1
Linux/Mac:
python -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run migrations
python manage.py makemigrations python manage.py migrate
-
Test the setup (optional)
python test_setup.py
-
Start the development server
python manage.py runserver
-
Access the application Open your browser and navigate to:
http://127.0.0.1:8000/
For detailed setup instructions, see SETUP.md
- Select Problem Type: Choose from Knapsack, TSP, or Graph Matching
- Choose Input Method: Manual, File Upload, or Random Generation
- Select Algorithms: Pick one or more algorithms to compare
- Enter Problem Data: Provide the problem instance data
- Run Optimization: Click the button to execute and compare algorithms
- Weights: Comma-separated integers (e.g.,
10,20,30
) - Values: Comma-separated integers (e.g.,
60,100,120
) - Capacity: Single integer (e.g.,
50
)
- Cities: Semicolon-separated x,y coordinates (e.g.,
0,0;10,10;20,5;15,20
)
- Edges: Semicolon-separated u,v,weight tuples (e.g.,
0,1,5;1,2,3;0,2,8;2,3,4
)
{
"weights": [10, 20, 30],
"values": [60, 100, 120],
"capacity": 50
}
10,20,30
60,100,120
50
10 20 30
60 100 120
50
combinatorial_optimization_django/
โโโ combinatorial_optimization_django/
โ โโโ __init__.py
โ โโโ settings.py
โ โโโ urls.py
โ โโโ wsgi.py
โโโ optimizer/
โ โโโ problems/
โ โ โโโ knapsack.py
โ โ โโโ tsp.py
โ โ โโโ graph_matching.py
โ โโโ solvers/
โ โ โโโ greedy.py
โ โ โโโ divide_conquer.py
โ โ โโโ dynamic_programming.py
โ โ โโโ backtracking.py
โ โ โโโ branch_bound.py
โ โโโ templates/
โ โ โโโ base.html
โ โ โโโ index.html
โ โ โโโ results.html
โ โ โโโ legacy.html
โ โ โโโ result.html
โ โโโ static/
โ โ โโโ style.css
โ โโโ models.py
โ โโโ views.py
โ โโโ forms.py
โ โโโ benchmark.py
โ โโโ urls.py
โโโ manage.py
โโโ db.sqlite3
- Fast execution time
- May not always find optimal solution
- Good for quick approximations
- Breaks problem into smaller subproblems
- Efficient for certain problem structures
- Moderate complexity
- Guarantees optimal solution
- Higher memory usage
- Excellent for overlapping subproblems
- Explores all possible solutions
- Can be slow for large problems
- Guarantees finding optimal solution
- Prunes search space intelligently
- Balances speed and optimality
- Good for medium-sized problems
The application tracks and displays:
- Runtime: Execution time in seconds
- Memory Usage: Peak memory consumption in MB
- Solution Quality: Objective value (maximization/minimization)
- Solution Details: Actual solution representation
The application features a clean, professional design with:
- Responsive Bootstrap 5 layout
- Interactive forms with dynamic field visibility
- Real-time chart visualizations
- Mobile-friendly interface
- Intuitive navigation
To run tests:
python manage.py test optimizer
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is open-source and available under the MIT License.
- Combinatorial Optimization Framework Team
- Large problem instances (>1000 items) may cause performance degradation
- Some algorithms may timeout on very complex problems
- Add more optimization problems (Set Cover, Bin Packing, etc.)
- Implement parallel algorithm execution
- Add solution visualization (graphs, charts)
- Export results to PDF
- User authentication and saved sessions
- API endpoints for programmatic access
For issues, questions, or suggestions, please open an issue on the GitHub repository.
- Django Framework
- Bootstrap 5
- Chart.js
- Python Community