Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Fix variable holes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromxavier committed Aug 14, 2023
1 parent 26a98f7 commit 5b3718f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name = "DWaveNeal"
uuid = "870cdf72-5502-4b10-839c-127ceab78f22"
authors = ["Pedro Maciel Xavier <[email protected]>"]
version = "0.4.1"
version = "0.4.2"

[deps]
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
QUBODrivers = "a3f166f7-2cd3-47b6-9e1e-6fbfe0449eb0"
micromamba_jll = "f8abcde7-e9b7-5caa-b8af-a437887ae8e4"

[compat]
PythonCall = "0.9.12"
PythonCall = "0.9.13"
QUBODrivers = "0.2"
julia = "1.6"
micromamba_jll = "<1.4.3"
23 changes: 12 additions & 11 deletions src/DWaveNeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,23 @@ function sample(sampler::Optimizer{T}) where {T}
for param in _DWAVE_NEAL_ATTR_LIST
)

n = MOI.get(sampler, MOI.NumberOfVariables())

# Call D-Wave Neal API
sampler = neal.SimulatedAnnealingSampler()
results = @timed sampler.sample_qubo(Q; params...)
records = results.value.record

# Format Samples
samples = [
Sample{T}(
# state:
pyconvert.(Int, ψ),
# value:
α * (pyconvert(T, λ) + β),
# reads:
pyconvert(Int, r),
) for (ψ, λ, r) in records
]
samples = Vector{Sample{T,Int}}()

for ϕ in results.value.samples()
# Complete state
ψ = [pyconvert(Int, get(ϕ, i, 0)) for i = 1:n]
λ = QUBOTools.value(Q, ψ, α, β)
s = Sample{T}(ψ, λ)

push!(samples, s)
end

# Write metadata
metadata = Dict{String,Any}(
Expand Down

0 comments on commit 5b3718f

Please sign in to comment.