You are reading QUBO Solver v0.7.2, an older version of this documentation. Go to the latest version (v0.10.0)
Simulated Annealing
SimulatedAnnealingSolver
Section titled “SimulatedAnnealingSolver”Simple classical solver class using Simulated Annealing. Designed to integrate with the solver factory.
Signature
Section titled “Signature”class SimulatedAnnealingSolver(BaseClassicalSolver): def solve(self) -> QUBOSolutionDescription
Section titled “Description”This solver uses a Simulated Annealing to probabilistically explore the solution space. It is suitable for approximating solutions on medium-sized QUBO instances. Computation is entirely classical and based on the SimulatedAnnealingSolver. The output is fully compatible with the QUBOSolution structure used in the qubo-solver package.
Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
use_quantum |
bool |
Have to be False to uses a classical solver. |
classical_solver_type |
str |
Set to "simulated_annealing" to use Simulated Annealing as the solving method. |
max_iter |
int |
Maximum number of iterations to perform for simulated annealing or tabu search. |
sa_initial_temp |
float |
Starting temperature (controls exploration). |
sa_final_temp |
float |
Minimum temperature threshold for stopping. |
sa_alpha |
float |
Cooling rate - should be slightly below 1 (e.g., 0.95–0.99). |
from qubosolver import QUBOInstancefrom qubosolver.solver import QuboSolverfrom qubosolver.config import SolverConfig, ClassicalConfig
qubo = QUBOInstance(coefficients=[[-2.0, 1.0], [1.0, -2.0]])config = SolverConfig(use_quantum = False, classical=ClassicalConfig(classical_solver_type="simulated_annealing"))
solver = QuboSolver(qubo, config)
solution = solver.solve()print(solution)QUBOSolution(bitstrings=tensor([[0, 1]], dtype=torch.int32), costs=tensor([-2.], dtype=torch.float64), counts=tensor([1]), probabilities=tensor([1.]), solution_status=)
NotesRecommended for local, classical solving when exact optimization is not required.
var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))
{"annotate": null, "base": "../../../..", "features": ["content.code.annotate", "content.action.view", "content.action.edit", "navigation.tabs", "navigation.indexes", "navigation.sections", "content.code.copy"], "search": "../../../../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"provider": "mike"}}