This pull request adds support for the SK problem, an optimization problem related to spin glass. The SK problem involves finding the minimum energy Hamiltonian based on the interaction between spins.
The implementation includes a new class SK in the problem module. The SK class allows the creation of instances of the SK problem. It provides methods for solving the problem using the Docplex solver, visualizing the graph with a given solution, and obtaining the qubo.
Example:
from openqaoa.problems import SK
import matplotlib.pyplot as plt
from openqaoa import QAOA
sk = SK.random_instance(n_nodes=5)
sol = sk.classical_solution()
qaoa = QAOA()
qaoa.compile(sk.qubo)
qaoa.optimize()
sol_qaoa = qaoa.result.lowest_cost_bitstrings()["solutions_bitstrings"][0]
fig, ax = plt.subplots(1, 2, figsize = (10, 5))
sk.plot_solution(sol_qaoa, ax=ax[0])
ax[0].set_title("QAOA Results")
sk.plot_solution(sol, ax=ax[1])
ax[1].set_title("CPLEX Results")
Checklist
[x] I have performed a self-review of my code.
[x] I have commented my code and used numpy-style docstrings
[ ] I have made corresponding updates to the documentation.
[x] My changes generate no new warnings
[x] I have added/updated tests to make sure bugfix/feature works.
[x] New and existing unit tests pass locally with my changes.
Type of change
Please delete options that are not relevant.
[x] New feature (non-breaking change which adds functionality)
How Has This Been Tested?
the test is inside './tests/test_sk.py' and './tests/test_qubo.py'
Adding the Sherrington–Kirkpatrick (SK) problem class with its corresponding test. https://en.wikipedia.org/wiki/Spin_glass
Description
This pull request adds support for the SK problem, an optimization problem related to spin glass. The SK problem involves finding the minimum energy Hamiltonian based on the interaction between spins.
The implementation includes a new class
SK
in the problem module. TheSK
class allows the creation of instances of the SK problem. It provides methods for solving the problem using the Docplex solver, visualizing the graph with a given solution, and obtaining the qubo.Example:
Checklist
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
the test is inside './tests/test_sk.py' and './tests/test_qubo.py'