Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pending changes #9

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.6'
version: '1.10'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(path=@__DIR__); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
run: julia --project=docs/ docs/make.jl
run: julia --project=docs/ docs/make.jl
4 changes: 2 additions & 2 deletions .github/workflows/multidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.6'
version: '1.10'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.instantiate()'
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(path=@__DIR__); Pkg.instantiate()'
- name: Aggregate and deploy
run: |
git config user.name github-actions
Expand Down
16 changes: 9 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name = "QUBO"
uuid = "ce8c2e91-a970-4681-856b-16178c24a30c"
authors = ["pedromxavier <[email protected]>", "pedroripper <[email protected]>", "joaquimg <[email protected]>", "AndradeTiago <[email protected]>", "bernalde <dbernalneira@usra.edu>"]
version = "0.3.1"
authors = ["pedromxavier <[email protected]>", "pedroripper <[email protected]>", "joaquimg <[email protected]>", "AndradeTiago <[email protected]>", "bernalde <dbernaln@purdue.edu>"]
version = "0.3.2"

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

[compat]
JuMP = "1"
QUBODrivers = "0.3.2"
QUBOTools = "0.9.3"
ToQUBO = "0.1.8"
julia = "1.6"
JuMP = "1"
MathOptInterface = "1"
QUBODrivers = "0.3.3"
QUBOTools = "0.10"
ToQUBO = "0.1.9"
julia = "1.9"
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ MultiDocumenter = "87ed4bf0-c935-4a67-83c3-2a03bee4197c"
QUBODrivers = "a3f166f7-2cd3-47b6-9e1e-6fbfe0449eb0"
QUBOTools = "60eb5b62-0a39-4ddc-84c5-97d2adff9319"
ToQUBO = "9a412ddf-83fa-43b6-9748-7843c851aa65"

[compat]
Documenter = "1"
23 changes: 14 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
using Documenter
using QUBO

# Set up to run docstrings with jldoctest
DocMeta.setdocmeta!(QUBO, :DocTestSetup, :(using QUBO); recursive = true)

makedocs(;
doctest = true,
clean = true,
format = Documenter.HTML(
assets = ["assets/extra_styles.css", "assets/favicon.ico"],
doctest = true,
clean = true,
warnonly = [:missing_docs],
format = Documenter.HTML( #
assets = ["assets/extra_styles.css", "assets/favicon.ico"],
mathengine = Documenter.KaTeX(),
sidebar_sitename = false,
sidebar_sitename = false
),
sitename = "QUBO.jl",
authors = "Pedro Xavier and Pedro Ripper and Tiago Andrade and Joaquim Garcia and David Bernal",
pages = ["Home" => "index.md"],
workdir = ".",
authors = "Pedro Maciel Xavier and Pedro Ripper and Tiago Andrade and Joaquim Dias Garcia and David E. Bernal Neira",
pages = ["Home" => "index.md"],
workdir = @__DIR__
)

if "--skip-deploy" ∈ ARGS
@warn "Skipping deployment"
else
deploydocs(repo = raw"github.com/psrenergy/QUBO.jl.git", push_preview = true)
deploydocs(repo = raw"github.com/JuliaQUBO/QUBO.jl.git", push_preview = true)
end
8 changes: 4 additions & 4 deletions docs/multimake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ docs = [
upstream = joinpath(temp_dir, "QUBO.jl"),
path = "QUBO.jl",
name = "QUBO.jl",
giturl = "https://github.com/psrenergy/QUBO.jl.git",
giturl = "https://github.com/JuliaQUBO/QUBO.jl.git",
),
MultiDocumenter.MultiDocRef(
upstream = joinpath(temp_dir, "ToQUBO.jl"),
path = "ToQUBO.jl",
name = "ToQUBO.jl",
giturl = "https://github.com/psrenergy/ToQUBO.jl.git",
giturl = "https://github.com/JuliaQUBO/ToQUBO.jl.git",
),
MultiDocumenter.MultiDocRef(
upstream = joinpath(temp_dir, "QUBODrivers.jl"),
path = "QUBODrivers.jl",
name = "QUBODrivers.jl",
giturl = "https://github.com/psrenergy/QUBODrivers.jl.git",
giturl = "https://github.com/JuliaQUBO/QUBODrivers.jl.git",
),
MultiDocumenter.MultiDocRef(
upstream = joinpath(temp_dir, "QUBOTools.jl"),
path = "QUBOTools.jl",
name = "QUBOTools.jl",
giturl = "https://github.com/psrenergy/QUBOTools.jl.git",
giturl = "https://github.com/JuliaQUBO/QUBOTools.jl.git",
),
]

Expand Down
35 changes: 30 additions & 5 deletions src/QUBO.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
module QUBO

import JuMP
import MathOptInterface as MOI

import QUBOTools, QUBODrivers, ToQUBO
export QUBOTools, QUBODrivers, ToQUBO
# QUBOTools
import QUBOTools
import QUBOTools: ↑, ↓
import QUBOTools: reads

const QUBOTools_MOI = Base.get_extension(QUBOTools, :QUBOTools_MOI)
const Spin = QUBOTools_MOI.Spin
const NumberOfReads = QUBOTools_MOI.NumberOfReads

export QUBOTools
export ↑, ↓
export reads
export Spin, NumberOfReads

# QUBODrivers
import QUBODrivers
import QUBODrivers: ExactSampler, IdentitySampler, RandomSampler

export QUBODrivers
export ExactSampler, IdentitySampler, RandomSampler

import QUBODrivers: Spin
export Spin
# ToQUBO
import ToQUBO
export ToQUBO

include("wrapper.jl")

function source_model(model::JuMP.Model)
return JuMP.get_attribute(model, ToQUBO.Attributes.SourceModel())
end

include("jump/wrapper.jl")
function target_model(model::JuMP.Model)
return JuMP.get_attribute(model, ToQUBO.Attributes.TargetModel())
end

end # module QUBO
14 changes: 12 additions & 2 deletions src/jump/wrapper.jl → src/wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function JuMP.build_variable(::Function, info::JuMP.VariableInfo, ::Type{Spin};
return SpinInfo(info)
end

function JuMP.add_variable(model::JuMP.Model, info::SpinInfo, name::String)
x = JuMP.add_variable(model, JuMP.ScalarVariable(info.info), name)
function JuMP.add_variable(model::JuMP.Model, spin_info::SpinInfo, name::String)
x = JuMP.add_variable(model, JuMP.ScalarVariable(spin_info.info), name)

JuMP.@constraint(model, x ∈ Spin())

Expand All @@ -19,3 +19,13 @@ end

JuMP.in_set_string(::MIME"text/plain", ::Spin) = "spin"
JuMP.in_set_string(::MIME"text/latex", ::Spin) = raw"\in \left\langle{-1, 1}\right\rangle"

# Number of Reads
@doc raw"""
reads(model::JuMP.Model; result::Integer = 1)

Returns the multiplicity of a given result.
"""
function QUBOTools.reads(model::JuMP.Model; result::Integer = 1)
return JuMP.get_attribute(model, NumberOfReads(result))::Integer
end
3 changes: 2 additions & 1 deletion test/spin_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ function test_spin_model()

optimize!(model)

@test value.(s) ≈ [1, 1, -1] || value.(s) ≈ [1, -1, 1] || value.(s) ≈ [-1, 1, 1]
@test value.(s) ≈ [↑, ↑, ↓] || value.(s) ≈ [↑, ↓, ↑] || value.(s) ≈ [↓, ↑, ↑]
@test objective_value(model) ≈ -3.0
@test reads(model) == 1
end

return nothing
Expand Down
Loading