Skip to content

Commit 4aab7cd

Browse files
authored
Merge pull request #9 from JuliaQUBO/px/checkpoint
Merge pending changes
2 parents fbddd39 + 04eebbc commit 4aab7cd

File tree

9 files changed

+79
-33
lines changed

9 files changed

+79
-33
lines changed

.github/workflows/docs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- uses: actions/checkout@v2
1414
- uses: julia-actions/setup-julia@latest
1515
with:
16-
version: '1.6'
16+
version: '1.10'
1717
- name: Install dependencies
18-
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
18+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(path=@__DIR__); Pkg.instantiate()'
1919
- name: Build and deploy
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
22-
run: julia --project=docs/ docs/make.jl
22+
run: julia --project=docs/ docs/make.jl

.github/workflows/multidocs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- uses: julia-actions/setup-julia@latest
1313
with:
14-
version: '1.6'
14+
version: '1.10'
1515
- name: Install dependencies
16-
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
16+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(path=@__DIR__); Pkg.instantiate()'
1717
- name: Aggregate and deploy
1818
run: |
1919
git config user.name github-actions

Project.toml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
name = "QUBO"
22
uuid = "ce8c2e91-a970-4681-856b-16178c24a30c"
3-
authors = ["pedromxavier <[email protected]>", "pedroripper <[email protected]>", "joaquimg <[email protected]>", "AndradeTiago <[email protected]>", "bernalde <dbernalneira@usra.edu>"]
4-
version = "0.3.1"
3+
authors = ["pedromxavier <[email protected]>", "pedroripper <[email protected]>", "joaquimg <[email protected]>", "AndradeTiago <[email protected]>", "bernalde <dbernaln@purdue.edu>"]
4+
version = "0.3.2"
55

66
[deps]
77
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
8+
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
89
QUBODrivers = "a3f166f7-2cd3-47b6-9e1e-6fbfe0449eb0"
910
QUBOTools = "60eb5b62-0a39-4ddc-84c5-97d2adff9319"
1011
ToQUBO = "9a412ddf-83fa-43b6-9748-7843c851aa65"
1112

1213
[compat]
13-
JuMP = "1"
14-
QUBODrivers = "0.3.2"
15-
QUBOTools = "0.9.3"
16-
ToQUBO = "0.1.8"
17-
julia = "1.6"
14+
JuMP = "1"
15+
MathOptInterface = "1"
16+
QUBODrivers = "0.3.3"
17+
QUBOTools = "0.10"
18+
ToQUBO = "0.1.9"
19+
julia = "1.9"

docs/Project.toml

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ MultiDocumenter = "87ed4bf0-c935-4a67-83c3-2a03bee4197c"
44
QUBODrivers = "a3f166f7-2cd3-47b6-9e1e-6fbfe0449eb0"
55
QUBOTools = "60eb5b62-0a39-4ddc-84c5-97d2adff9319"
66
ToQUBO = "9a412ddf-83fa-43b6-9748-7843c851aa65"
7+
8+
[compat]
9+
Documenter = "1"

docs/make.jl

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
using Documenter
2+
using QUBO
3+
4+
# Set up to run docstrings with jldoctest
5+
DocMeta.setdocmeta!(QUBO, :DocTestSetup, :(using QUBO); recursive = true)
26

37
makedocs(;
4-
doctest = true,
5-
clean = true,
6-
format = Documenter.HTML(
7-
assets = ["assets/extra_styles.css", "assets/favicon.ico"],
8+
doctest = true,
9+
clean = true,
10+
warnonly = [:missing_docs],
11+
format = Documenter.HTML( #
12+
assets = ["assets/extra_styles.css", "assets/favicon.ico"],
813
mathengine = Documenter.KaTeX(),
9-
sidebar_sitename = false,
14+
sidebar_sitename = false
1015
),
1116
sitename = "QUBO.jl",
12-
authors = "Pedro Xavier and Pedro Ripper and Tiago Andrade and Joaquim Garcia and David Bernal",
13-
pages = ["Home" => "index.md"],
14-
workdir = ".",
17+
authors = "Pedro Maciel Xavier and Pedro Ripper and Tiago Andrade and Joaquim Dias Garcia and David E. Bernal Neira",
18+
pages = ["Home" => "index.md"],
19+
workdir = @__DIR__
1520
)
1621

1722
if "--skip-deploy" ARGS
1823
@warn "Skipping deployment"
1924
else
20-
deploydocs(repo = raw"github.com/psrenergy/QUBO.jl.git", push_preview = true)
25+
deploydocs(repo = raw"github.com/JuliaQUBO/QUBO.jl.git", push_preview = true)
2126
end

docs/multimake.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ docs = [
88
upstream = joinpath(temp_dir, "QUBO.jl"),
99
path = "QUBO.jl",
1010
name = "QUBO.jl",
11-
giturl = "https://github.com/psrenergy/QUBO.jl.git",
11+
giturl = "https://github.com/JuliaQUBO/QUBO.jl.git",
1212
),
1313
MultiDocumenter.MultiDocRef(
1414
upstream = joinpath(temp_dir, "ToQUBO.jl"),
1515
path = "ToQUBO.jl",
1616
name = "ToQUBO.jl",
17-
giturl = "https://github.com/psrenergy/ToQUBO.jl.git",
17+
giturl = "https://github.com/JuliaQUBO/ToQUBO.jl.git",
1818
),
1919
MultiDocumenter.MultiDocRef(
2020
upstream = joinpath(temp_dir, "QUBODrivers.jl"),
2121
path = "QUBODrivers.jl",
2222
name = "QUBODrivers.jl",
23-
giturl = "https://github.com/psrenergy/QUBODrivers.jl.git",
23+
giturl = "https://github.com/JuliaQUBO/QUBODrivers.jl.git",
2424
),
2525
MultiDocumenter.MultiDocRef(
2626
upstream = joinpath(temp_dir, "QUBOTools.jl"),
2727
path = "QUBOTools.jl",
2828
name = "QUBOTools.jl",
29-
giturl = "https://github.com/psrenergy/QUBOTools.jl.git",
29+
giturl = "https://github.com/JuliaQUBO/QUBOTools.jl.git",
3030
),
3131
]
3232

src/QUBO.jl

+30-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,41 @@
11
module QUBO
22

33
import JuMP
4+
import MathOptInterface as MOI
45

5-
import QUBOTools, QUBODrivers, ToQUBO
6-
export QUBOTools, QUBODrivers, ToQUBO
6+
# QUBOTools
7+
import QUBOTools
8+
import QUBOTools: ,
9+
import QUBOTools: reads
710

11+
const QUBOTools_MOI = Base.get_extension(QUBOTools, :QUBOTools_MOI)
12+
const Spin = QUBOTools_MOI.Spin
13+
const NumberOfReads = QUBOTools_MOI.NumberOfReads
14+
15+
export QUBOTools
16+
export ,
17+
export reads
18+
export Spin, NumberOfReads
19+
20+
# QUBODrivers
21+
import QUBODrivers
822
import QUBODrivers: ExactSampler, IdentitySampler, RandomSampler
23+
24+
export QUBODrivers
925
export ExactSampler, IdentitySampler, RandomSampler
1026

11-
import QUBODrivers: Spin
12-
export Spin
27+
# ToQUBO
28+
import ToQUBO
29+
export ToQUBO
30+
31+
include("wrapper.jl")
32+
33+
function source_model(model::JuMP.Model)
34+
return JuMP.get_attribute(model, ToQUBO.Attributes.SourceModel())
35+
end
1336

14-
include("jump/wrapper.jl")
37+
function target_model(model::JuMP.Model)
38+
return JuMP.get_attribute(model, ToQUBO.Attributes.TargetModel())
39+
end
1540

1641
end # module QUBO

src/jump/wrapper.jl renamed to src/wrapper.jl

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function JuMP.build_variable(::Function, info::JuMP.VariableInfo, ::Type{Spin};
99
return SpinInfo(info)
1010
end
1111

12-
function JuMP.add_variable(model::JuMP.Model, info::SpinInfo, name::String)
13-
x = JuMP.add_variable(model, JuMP.ScalarVariable(info.info), name)
12+
function JuMP.add_variable(model::JuMP.Model, spin_info::SpinInfo, name::String)
13+
x = JuMP.add_variable(model, JuMP.ScalarVariable(spin_info.info), name)
1414

1515
JuMP.@constraint(model, x Spin())
1616

@@ -19,3 +19,13 @@ end
1919

2020
JuMP.in_set_string(::MIME"text/plain", ::Spin) = "spin"
2121
JuMP.in_set_string(::MIME"text/latex", ::Spin) = raw"\in \left\langle{-1, 1}\right\rangle"
22+
23+
# Number of Reads
24+
@doc raw"""
25+
reads(model::JuMP.Model; result::Integer = 1)
26+
27+
Returns the multiplicity of a given result.
28+
"""
29+
function QUBOTools.reads(model::JuMP.Model; result::Integer = 1)
30+
return JuMP.get_attribute(model, NumberOfReads(result))::Integer
31+
end

test/spin_model.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ function test_spin_model()
1414

1515
optimize!(model)
1616

17-
@test value.(s) [1, 1, -1] || value.(s) [1, -1, 1] || value.(s) [-1, 1, 1]
17+
@test value.(s) [, , ] || value.(s) [, , ] || value.(s) [, , ]
1818
@test objective_value(model) -3.0
19+
@test reads(model) == 1
1920
end
2021

2122
return nothing

0 commit comments

Comments
 (0)