Skip to content

Commit

Permalink
Fix MQLib format + Bump Version
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromxavier committed Oct 2, 2024
1 parent d4ea2cd commit 2d38ca7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
22 changes: 11 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QUBOTools"
uuid = "60eb5b62-0a39-4ddc-84c5-97d2adff9319"
authors = ["pedromxavier <mail@pedro.ϵλ>", "pedroripper <[email protected]>", "AndradeTiago <[email protected]>", "joaquimg <[email protected]>", "bernalde <[email protected]>"]
version = "0.10.0"
version = "0.10.1"

[deps]
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
Expand All @@ -26,14 +26,14 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
QUBOTools_MOI = ["MathOptInterface"]

[compat]
GeometryBasics = "0.4"
Graphs = "1"
HDF5 = "0.16.15"
JSON = "0.21.3"
JSONSchema = "1"
MathOptInterface = "1"
NetworkLayout = "0.4.5"
GeometryBasics = "0.4"
Graphs = "1"
HDF5 = "0.16.15"
JSON = "0.21.3"
JSONSchema = "1"
MathOptInterface = "1"
NetworkLayout = "0.4.5"
PseudoBooleanOptimization = "0.2"
RecipesBase = "1"
Statistics = "1"
julia = "1.9"
RecipesBase = "1"
Statistics = "1"
julia = "1.9"
5 changes: 3 additions & 2 deletions src/library/format/qubo/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ function _parse_entry!(data::Dict{Symbol,Any}, line::AbstractString, ::QUBO, ::V
return false
end

i = parse(Int, m[1]) + 1
j = parse(Int, m[2]) + 1
# NOTE: MQLib format is 1-indexed
i = parse(Int, m[1])
j = parse(Int, m[2])
c = parse(Float64, m[3])

if i == j
Expand Down
6 changes: 4 additions & 2 deletions src/library/format/qubo/printer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ end
function _print_entries(io::IO, data::Dict{Symbol,Any}, ::QUBO, ::Val{:dwave})
println(io, "c linear terms")

# NOTE: D-Wave format is 0-indexed
for (i, l) in data[:linear_terms]
println(io, "$(i-1) $(i-1) $(l)")
end
Expand All @@ -116,16 +117,17 @@ end
function _print_entries(io::IO, data::Dict{Symbol,Any}, ::QUBO, ::Val{:mqlib})
println(io, "# linear terms")

# NOTE: MQLib format is 1-indexed
for (i, l) in data[:linear_terms]
println(io, "$(i-1) $(i-1) $(l)")
println(io, "$(i) $(i) $(l)")
end

println(io, "# quadratic terms")

for ((i, j), q) in data[:quadratic_terms]
# NOTE: in MQLib qubo files, quadratic coefficients
# are halved when written to the file
println(io, "$(i-1) $(j-1) $(q/2)")
println(io, "$(i) $(j) $(q/2)")
end

return nothing
Expand Down

2 comments on commit 2d38ca7

@pedromxavier
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/116448

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.1 -m "<description of version>" 2d38ca7cb8cd4db5852c35305bf61d6c1b45646e
git push origin v0.10.1

Please sign in to comment.