Samplers
QUBODrivers includes four utility samplers. They are intentionally simple: their main role is to exercise the interface, provide small-instance baselines, and make examples runnable without external services or fixed solver choices.
| Sampler | Purpose | Main result behavior |
|---|---|---|
ExactSampler.Optimizer | Exhaustive enumeration for small models | returns every state |
RandomSampler.Optimizer | Random baseline and smoke tests | returns num_reads random states |
IdentitySampler.Optimizer | Warm-start and conversion checks | returns the provided start state |
MIPSampler.Optimizer | Exact MIP-backed baseline using a user-supplied MOI optimizer | returns one best incumbent |
Exact Sampler
Use ExactSampler to validate small problem formulations or compare another sampler against a known complete set of states. The cost grows exponentially with the number of variables.
using JuMP
using QUBODrivers
model = Model(ExactSampler.Optimizer)
@variable(model, x[1:2], Bin)
@objective(model, Min, -x[1] - 2x[2] + 3x[1] * x[2])
optimize!(model)
result_count(model)4QUBODrivers.ExactSampler.Optimizer — Type
ExactSampler.Optimizer{T}This sampler performs an exhaustive search over all $2^{n}$ possible states. It is useful as a correctness oracle for small QUBO and Ising models.
Due to the exponentially large number of visited states, this sampler is intended only for small instances.
ExactSampler ignores QUBODrivers.FinalNumberOfReads; it always returns the full exhaustive sample set.
Random Sampler
Use RandomSampler as a cheap stochastic baseline. Set "num_reads" to control how many states are sampled and "seed" for reproducible examples.
using JuMP
using QUBODrivers
model = Model(RandomSampler.Optimizer)
set_optimizer_attribute(model, "num_reads", 4)
set_optimizer_attribute(model, "seed", 1)
@variable(model, x[1:3], Bin)
@objective(model, Min, x[1] + x[2] - x[3])
optimize!(model)
result_count(model)3QUBODrivers.RandomSampler.Optimizer — Type
RandomSampler.Optimizer{T}Sampler that evaluates uniformly random states.
RandomSampler is a lightweight baseline for smoke tests, examples, and benchmark harnesses. It samples independent states in the model domain, evaluates their objective values with QUBOTools, and returns the final sampled states.
Attributes
QUBODrivers.RandomSeed,"seed": Random seed to initialize the random number generator.NumberOfReads,"num_reads": Default final read count.QUBODrivers.FinalNumberOfReads,"final_num_reads": Number of random states emitted in the returned sample set. If unset, this defaults toNumberOfReads.RandomGenerator,"rng": Random Number Generator instance.
Identity Sampler
Use IdentitySampler when the requested result is the warm-start vector itself. It is useful in tests for objective evaluation, fixed variable handling, and model conversion.
using QUBODrivers
MOI = QUBODrivers.MOI
model = MOI.instantiate(IdentitySampler.Optimizer; with_bridge_type = Float64)
x, _ = MOI.add_constrained_variables(model, fill(MOI.ZeroOne(), 3))
for (xi, start) in zip(x, [1.0, 0.0, 1.0])
MOI.set(model, MOI.VariablePrimalStart(), xi, start)
end
objective = MOI.ScalarAffineFunction{Float64}(
MOI.ScalarAffineTerm{Float64}[
MOI.ScalarAffineTerm{Float64}(1.0, x[1]),
MOI.ScalarAffineTerm{Float64}(2.0, x[2]),
MOI.ScalarAffineTerm{Float64}(3.0, x[3]),
],
0.0,
)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.set(model, MOI.ObjectiveFunction{typeof(objective)}(), objective)
MOI.optimize!(model)
(
round.(Int, MOI.get.(model, MOI.VariablePrimal(1), x)),
MOI.get(model, MOI.ObjectiveValue(1)),
)([1, 0, 1], 4.0)QUBODrivers.IdentitySampler.Optimizer — Type
IdentitySampler.Optimizer{T}This sampler selects precisely the state vector provided as warm-start. Use it to check model conversion, objective evaluation, fixed variables, and warm-start plumbing without invoking a stochastic or external backend.
Every variable must have a valid MOI.VariablePrimalStart value before optimization.
IdentitySampler ignores QUBODrivers.FinalNumberOfReads; it always returns the single warm-start state.
MIP Sampler
Use MIPSampler as an exact correctness baseline for small and medium QUBO instances when you want to choose the MIP backend yourself. The sampler is implemented directly against MathOptInterface and does not depend on JuMP or on any concrete MIP solver package.
using JuMP
using QUBODrivers
using GLPK
model = Model(MIPSampler.Optimizer)
set_attribute(model, MIPSampler.MIPOptimizer(), GLPK.Optimizer)
@variable(model, x[1:3], Bin)
@objective(model, Min, x[1] + x[2] - 2x[1] * x[3])
optimize!(model)
value.(x)
objective_value(model)Internally, MIPSampler linearizes binary products with auxiliary variables and the standard Fortet/McCormick inequalities. The reformulation is a baseline route, not a replacement for specialized large-scale QUBO heuristics. For a broader discussion of efficient binary polynomial reformulations, see Elloumi, Sourour, and Verchere, "Efficient linear reformulations for binary polynomial optimization problems", Computers & Operations Research 155 (2023), 106240.
QUBODrivers.MIPSampler.Optimizer — Type
MIPSampler.Optimizer{T}MOI-native exact baseline that linearizes a QUBO into a binary mixed-integer linear model and solves it with a user-supplied MOI optimizer.
MIPSampler does not depend on any concrete MIP solver. Set MIPOptimizer to a compatible optimizer factory, such as HiGHS.Optimizer, GLPK.Optimizer, or MOI.OptimizerWithAttributes(HiGHS.Optimizer, MOI.Silent() => true).
The sampler introduces one binary auxiliary variable for each off-diagonal quadratic term and enforces the product relation with the standard Fortet/McCormick inequalities. This follows the usual linear reformulation route for binary polynomial optimization; see also Elloumi, Sourour, and Verchere, "Efficient linear reformulations for binary polynomial optimization problems", Computers & Operations Research 155 (2023), 106240.
Only one best incumbent sample is returned. MIPSampler ignores QUBODrivers.FinalNumberOfReads.
Attributes
MIPOptimizer,"mip_optimizer": MOI-compatible optimizer factory used to solve the generated binary MIP.
QUBODrivers.MIPSampler.MIPOptimizer — Type
MIPOptimizer()Optimizer attribute that stores the MOI-compatible MIP backend factory used by MIPSampler.Optimizer.
External Sampler Packages
Several JuliaQUBO packages implement the same sampler interface for external libraries, heuristics, or services. Their source can be useful when building a new wrapper.
This table is the reviewed source of truth for public external sampler packages. When a new JuliaQUBO or SECQUOIA driver package is ready for users, open a QUBODrivers documentation PR that adds its package URL, solver type, and source file path.
| Project | Solver | Source Code |
|---|---|---|
| DWave.jl | DWave.Optimizer | src/sampler.jl |
| DWave.jl | DWave.Neal.Optimizer | src/neal/sampler.jl |
| DWave.jl | DWave.Tabu.Optimizer | src/tabu/sampler.jl |
| DWave.jl | DWave.Greedy.Optimizer | src/greedy/sampler.jl |
| DWave.jl | DWave.Random.Optimizer | src/random/sampler.jl |
| QiskitOpt.jl | QiskitOpt.QAOA.Optimizer | src/QAOA.jl |
| QiskitOpt.jl | QiskitOpt.VQE.Optimizer | src/VQE.jl |
| PySA.jl | PySA.Optimizer | src/PySA.jl |
| MQLib.jl | MQLib.Optimizer | src/MQLib.jl |
| CIMOptimizer.jl | CIMOptimizer.Optimizer | src/CIMOptimizer.jl |
| QuantumAnnealingInterface.jl | QuantumAnnealingInterface.Optimizer | src/QuantumAnnealingInterface.jl |