QBSolvLikeSimulatedAnnealing¶
QBSolv Like Simulated Annealing breaks down the problem and solves the parts individually using a classic solver that uses Simulated Annealing. This particular implementation uses hybrid.SimulatedAnnealingSubproblemSampler as a sampler for the subproblems to achieve a QBSolv like behaviour.
Note
This solver is only available for commercial and academic licenses.
Compatible Backends¶
The QBSolvLikeSimulatedAnnealing
algorithm supports the following backends:
By default, QBSolvLikeSimulatedAnnealing
uses the DWave
backend.
Initialization¶
The following section outlines the default configurations of QBSolvLikeSimulatedAnnealing
. You can also specify other compatible backends for the algorithm. When backend=None
is specified, the default backend will be initialized automatically. In this case, if the backend requires a token, it will be taken from the environment variables.
from luna_quantum.solve.parameters.algorithms import QBSolvLikeSimulatedAnnealing
from luna_quantum.solve.parameters.algorithms.base_params import SimulatedAnnealingBaseParams
algorithm = QBSolvLikeSimulatedAnnealing(
decomposer_size=50,
rolling=True,
rolling_history=0.15,
max_iter=100,
max_time=5,
convergence=3,
target=None,
rtol=1e-05,
atol=1e-08,
backend=None,
simulated_annealing=SimulatedAnnealingBaseParams(
num_reads=None,
num_sweeps=1000,
beta_range=None,
beta_schedule_type='geometric',
initial_states_generator='random'
)
)
Parameter Details
For a complete overview of available parameters and their usage, see the QBSolvLikeSimulatedAnnealing API Reference.
Usage¶
from luna_quantum import LunaSolve
LunaSolve.authenticate("<YOUR_LUNA_API_KEY>")
# Define your model and algorithm
model = ...
algorithm = ...
solve_job = algorithm.run(model, name="my-solve-job")
API Reference¶
Bases: LunaAlgorithm[DWave]
, QBSolvLikeMixin
QBSolv Like Simulated Annealing solver.
QBSolv Like Simulated Annealing breaks down the problem and solves the parts individually using a classic solver that uses Simulated Annealing. This particular implementation uses hybrid.SimulatedAnnealingSubproblemSampler (https://docs.ocean.dwavesys.com/projects/hybrid/en/stable/reference/samplers.html#simulatedannealingsubproblemsampler) as a sampler for the subproblems to achieve a QBSolv like behaviour.
This class combines parameters from multiple sources: - QBSolvLikeMixin: Provides parameters for the QBSolv-like decomposition approach - SimulatedAnnealingParams: Provides parameters specific to simulated annealing
Attributes:
Name | Type | Description |
---|---|---|
decomposer_size |
int
|
Size for the decomposer, which determines the maximum subproblem size to be handled in each iteration. Larger values may produce better solutions but increase computational complexity exponentially. Default is 50, which balances solution quality with reasonable runtime. |
rolling |
bool
|
Whether to use rolling window decomposition for the solver. When enabled, this allows for overlapping subproblems with shared variables, which can improve solution quality by better handling interactions across subproblem boundaries. Default is True. |
rolling_history |
float
|
Rolling history factor controlling how much of previous subproblem solutions are considered when solving subsequent subproblems. Higher values incorporate more historical information but may slow convergence to new solutions. Default is 0.15 (15% retention). |
max_iter |
int | None
|
Maximum number of iterations (decomposition and solving cycles) to perform. Higher values allow for more thorough optimization but increase runtime. Default is 100. |
max_time |
int
|
Time in seconds after which the algorithm will stop, regardless of convergence status. Provides a hard time limit for time-constrained applications. Default is 5. |
convergence |
int
|
Number of iterations with unchanged output to terminate algorithm. Higher values ensure more stable solutions but may increase computation time unnecessarily if the algorithm has already found the best solution. Default is 3. |
target |
float | None
|
Energy level that the algorithm tries to reach. If this target energy is achieved, the algorithm will terminate early. Default is None, meaning the algorithm will run until other stopping criteria are met. |
rtol |
float
|
Relative tolerance for convergence. Used when comparing energy values between iterations to determine if significant improvement has occurred. Default uses DEFAULT_RTOL. |
atol |
float
|
Absolute tolerance for convergence. Used alongside rtol when comparing energy values to determine if the algorithm has converged. Default uses DEFAULT_ATOL. |
num_reads |
Union[int, None]
|
Number of independent runs of the algorithm, each producing one solution sample. Multiple reads with different random starting points increase the chance of finding the global optimum. Default is None, which matches the number of initial states (or just one read if no initial states are provided). |
num_sweeps |
Union[int, None]
|
Number of iterations/sweeps per run, where each sweep updates all variables once. More sweeps allow more thorough exploration but increase runtime. Default is 1,000, suitable for small to medium problems. |
beta_range |
Union[List[float], Tuple[float, float], None]
|
The inverse temperature (β=1/T) schedule endpoints, specified as [start, end]. A wider range allows more exploration. Default is calculated based on the problem's energy scale to ensure appropriate acceptance probabilities. |
beta_schedule_type |
Literal['linear', 'geometric']
|
How beta values change between endpoints: - "linear": Equal steps (β₁, β₂, ...) - smoother transitions - "geometric": Multiplicative steps (β₁, r·β₁, r²·β₁, ...) - spends more time at lower temperatures for fine-tuning Default is "geometric", which often performs better for optimization problems. |
initial_states_generator |
Literal['none', 'tile', 'random']
|
How to handle cases with fewer initial states than num_reads: - "none": Raises error if insufficient initial states - "tile": Reuses provided states by cycling through them - "random": Generates additional random states as needed Default is "random", which maximizes exploration. |
backend
class-attribute
instance-attribute
¶
model_config
class-attribute
instance-attribute
¶
simulated_annealing
class-attribute
instance-attribute
¶
simulated_annealing: SimulatedAnnealingBaseParams = Field(
default_factory=SimulatedAnnealingBaseParams
)
get_compatible_backends
classmethod
¶
get_compatible_backends() -> tuple[type[DWave]]
Check at runtime if the used backend is compatible with the solver.
Returns:
Type | Description |
---|---|
tuple[type[IBackend], ...]
|
True if the backend is compatible with the solver, False otherwise. |
get_default_backend
classmethod
¶
get_default_backend() -> DWave
Return the default backend implementation.
This property must be implemented by subclasses to provide the default backend instance to use when no specific backend is specified.
Returns:
Type | Description |
---|---|
IBackend
|
An instance of a class implementing the IBackend interface that serves as the default backend. |
run ¶
run(
model: Model | str,
name: str | None = None,
backend: BACKEND_TYPE | None = None,
client: LunaSolve | str | None = None,
*args: Any,
**kwargs: Any,
) -> SolveJob
Run the configured solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model or str
|
The model to be optimized or solved. It could be an Model instance or a string identifier representing the model id. |
required |
name
|
str | None
|
If provided, the name of the job. Defaults to None. |
None
|
backend
|
BACKEND_TYPE | None
|
Backend to use for the solver. If not provided, the default backend is used. |
None
|
client
|
LunaSolve or str
|
The client interface used to interact with the backend services. If not provided, a default client will be used. |
None
|
*args
|
Any
|
Additional arguments that will be passed to the solver or client. |
()
|
**kwargs
|
Any
|
Additional keyword parameters for configuration or customization. |
{}
|
Returns:
Type | Description |
---|---|
SolveJob
|
The job object containing the information about the solve process. |