This project demonstrates how to use a Quadratic Unconstrained Binary Optimization (QUBO) algorithm to optimize the selection of a balanced Pokémon team. The solution utilizes quantum-inspired computing principles and simulated annealing to solve the problem, while fetching Pokémon data dynamically via the PokéAPI or using an offline dataset.
- Fetches Pokémon data (types, strengths, weaknesses) from the PokéAPI.
- Processes data to calculate weaknesses and strengths for team balance.
- Utilizes a QUBO matrix to formulate team selection constraints.
- Solves the QUBO problem using simulated annealing for optimal team selection.
- Outputs a balanced Pokémon team based on selected constraints (e.g., type coverage).
- Visualizes the QUBO matrix as a heatmap to better understand its structure.
- Visualizes the type distribution of the selected Pokémon team using bar charts.
project-root/
|-- data/
| |-- pokemon_dataset.json # Offline dataset for Pokémon data
|
|-- qubo_solver/
| |-- qubo_matrix.py # Generates the QUBO matrix
| |-- qubo_solver.py # Solves the QUBO problem using simulated annealing
|
|-- utils/
| |-- api_client.py # Fetches data from the PokéAPI
| |-- data_utils.py # Processes Pokémon data and calculates type weaknesses
|
|-- visualization/
| |-- qubo_heatmap.py # Generates heatmap visualization for QUBO matrix
| |-- team_distribution.py # Generates bar chart for team type distribution
|
|-- main.py # Orchestrates the entire process
|-- requirements.txt # Project dependencies
|-- .gitignore # Files and folders to be ignored in Git
|-- README.md # Project documentation (this file)
- Python 3.8+
pip(Python package installer)
-
Clone the repository:
git clone <repository_url> cd project-root
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
If using the PokéAPI to fetch live data, ensure you have internet access.
If using the offline dataset, ensure data/pokemon_dataset.json is populated.
- Run the main script:
python main.py
- Follow the prompts to select constraints (e.g., team size, type preferences).
- The script outputs the optimized Pokémon team and visualizations.
-
Fetch or Load Data:
- The
api_client.pyscript fetches live data from the PokéAPI. - Alternatively, data is loaded from
pokemon_dataset.json.
- The
-
Process Data:
- The
data_utils.pyscript calculates type strengths and weaknesses.
- The
-
Generate QUBO Matrix:
- The
qubo_matrix.pyscript constructs the QUBO matrix based on constraints such as type diversity, coverage, and balance.
- The
-
Visualize QUBO Matrix:
- The
qubo_heatmap.pyscript generates a heatmap to visualize the QUBO matrix structure.
- The
-
Solve QUBO:
- The
qubo_solver.pyscript uses simulated annealing to solve the QUBO problem and output an optimal team.
- The
-
Visualize Team Distribution:
- The
team_distribution.pyscript generates a bar chart showing the type distribution of the selected Pokémon team.
- The
Optimal Team:
1. Pikachu (Electric)
2. Charizard (Fire/Flying)
3. Bulbasaur (Grass/Poison)
4. Squirtle (Water)
5. Gengar (Ghost/Poison)
A heatmap showing the QUBO matrix structure to understand relationships between Pokémon selection constraints.
A bar chart showing the count of Pokémon types in the selected team for better visualization of team diversity.
- Update the constraints in
qubo_matrix.pyto modify the team selection logic. - Use different parameters in
qubo_solver.pyto adjust the optimization process.
requests: For fetching data from the PokéAPI.numpy: For matrix and numerical computations.matplotlib: For generating visualizations (heatmaps and bar charts).
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- PokéAPI: For providing Pokémon data.
- Quantum computing principles and QUBO optimization techniques.
Feel free to reach out for any questions or collaboration!