Skip to main content

Simulators

Solvers

ModelSolvers
Quadratic Unconstrained Binary Optimization (QUBO)sim.SimulatedAnnealingSampler, sim.RandomSampler

Simulated Annealing

A simple simulated annealing sampler for testing and debugging code.

dimod Simulated Annealing Sampler 🔗

import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import DwaveSamplerParameterModel
from dimod import BinaryQuadraticModel

sw.authenticate(api_key)

linear = {1: -2, 2: -2, 3: -3, 4: -3, 5: -2}
quadratic = {(1, 2): 2, (1, 3): 2, (2, 4): 2, (3, 4): 2, (3, 5): 2, (4, 5): 2}
model = BinaryQuadraticModel(linear, quadratic, "BINARY")

solver = "sim.dimod_simulated_annealing_sampler"

options = DwaveSamplerParameterModel(num_reads=1000)
so = StrangeworksOptimizer(model=model, solver=solver, options=options)
sw_job = so.run()

print(f"Job slug: {sw_job.slug}")
print(f"Job status: {so.status(sw_job.slug)}")

results = so.results(sw_job.slug)

print(f"Best solution:\n{results.solution.first}")

Random Sampler

A sampler that gives random samples for testing.

dimod Random Sampler 🔗

import strangeworks as sw
from strangeworks_optimization import StrangeworksOptimizer
from strangeworks_optimization_models.parameter_models import DwaveSamplerParameterModel
from dimod import BinaryQuadraticModel

sw.authenticate(api_key)

linear = {1: -2, 2: -2, 3: -3, 4: -3, 5: -2}
quadratic = {(1, 2): 2, (1, 3): 2, (2, 4): 2, (3, 4): 2, (3, 5): 2, (4, 5): 2}
model = BinaryQuadraticModel(linear, quadratic, "BINARY")

solver = "sim.dimod_random_sampler"

options = DwaveSamplerParameterModel(num_reads=1000)
so = StrangeworksOptimizer(model=model, solver=solver, options=options)
sw_job = so.run()

print(f"Job slug: {sw_job.slug}")
print(f"Job status: {so.status(sw_job.slug)}")

results = so.results(sw_job.slug)

print(f"Best solution:\n{results.solution.first}")

Parameters

from strangeworks_optimization_models.parameter_models import DwaveSamplerParameterModel

options = DwaveSamplerParameterModel(.....)

Solvers

  • dwave.Advantage_system4.1
  • dwave.Advantage_system5.4
  • dwave.Advantage_system6.4
  • dwave.Advantage2_prototype2.6
  • sim.SimulatedAnnealingSampler
  • sim.RandomSampler
NameTypeDescriptionDefaultValues (Range)
num_readsintSpecifies the number of reads (solutions) to be obtained.1[1, max_num_reads]
chain_strengthintSets the strength of the chains in the embedding.Determined by solver[Depends on system]
anneal_offsetsList[float]Provides offsets to annealing paths, per qubit.No offsetsSpecified per qubit
anneal_scheduleList[List[float]]Specifies the custom annealing schedule as time and fraction.Standard scheduleSpecified per system
annealing_timefloatSets the duration of the annealing process per read.Default system valueSpecified per system
auto_scaleboolAutomatically rescales h and J values to the QPU's range.True[True, False]
flux_biasesList[float]Applies manual flux biases for qubit calibration.No biases[Depends on system]
flux_drift_compensationboolCompensates for flux drift in qubits.True[True, False]
h_gain_scheduleList[List[float]]Sets time-dependent gains for qubit biases.Not specified[Depends on system]
initial_statedictSets the initial state for reverse annealing.Not specified[Depends on system]
max_answersintLimits the number of answers returned.num_reads[1, num_reads]
num_spin_reversal_transformsintApplies spin reversal transforms to reduce noise.0[0, max_transforms]
programming_thermalizationfloatTime to wait post-programming for thermalization.1000 μs[0μs, max_thermal]
readout_thermalizationfloatTime to wait post-readout for thermalization.0 μs[0μs, max_thermal]
reduce_intersample_correlationboolAdds delays between samples to reduce correlations.False[True, False]
reinitialize_stateboolReinitializes to the initial state for each anneal cycle.False[True, False]
embedding_parametersdictSpecifies the embedding parameters.False[True, False]