This repository contains a solution to the Warehouse Selection Puzzle, a combinatorial optimization problem. The project uses OpenJij, a heuristic optimization library, to solve the problem using Simulated Annealing (SA).
The problem is formulated as a QUBO (Quadratic Unconstrained Binary Optimization) model, treating the optimization landscape as a spin-glass system where constraints create "frustration" and the ground state represents the optimal shipment selection.
The objective is to select a subset of inventory items from a distribution hub to maximize total monetary value while adhering to strict operational constraints.
The facility holds exactly 100 distinct items, each defined by three attributes:
- Monetary Figure: Value in whole dollars (100ドル–1000ドル).
- Mass Value: Integer mass in kilograms (10–100 kg).
- Categorical Tag: Integer label (0–9) representing the supplier or group.
The solution must satisfy three non-negotiable rules:
- Rule A (Mass Ceiling): The total mass of selected items must not exceed exactly 1000 kg (one metric tonne).
- Rule B (Category Exclusivity): The shipment must not contain more than one item from the same categorical tag.
- Rule C (Taboo Pairs): Specific pairs of items are incompatible and cannot be shipped together.
To solve this using a quantum-inspired sampler, we map the problem to a Hamiltonian (energy equation) where binary variables
The total Hamiltonian
We minimize the negative total value to maximize profit, where
We use a squared penalty term to enforce the capacity limit
To ensure only one item is selected per category
For every forbidden pair
- Language: Python
-
Solver:
OpenJij(Simulated Annealing Sampler) -
Data Generation: As the specific item list was not provided in the prompt, the script generates:
- 100 items with random values (
$p$ ), masses ($m$ ), and categories. - 25 random "Taboo Pairs" to simulate Rule C.
- 100 items with random values (
-
Penalty Weights (
$\lambda$ ):-
$\lambda_{cat} = 10^{10}$ (Highest priority: Rule B is strict) $\lambda_{taboo} = 10^5$ $\lambda_{mass} = 10^4$
-
Install the required dependencies:
pip install numpy pandas openjij