Skip to content

Commit

Permalink
Merge pull request #9 from JuliaQUBO/px/checkpoint
Browse files Browse the repository at this point in the history
Merge pending changes
  • Loading branch information
pedromxavier authored Sep 26, 2024
2 parents fbddd39 + 04eebbc commit 4aab7cd
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 33 deletions.
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 <pedroxavier@psr-inc.com>", "pedroripper <pedroripper@psr-inc.com>", "joaquimg <joaquim@psr-inc.com>", "AndradeTiago <tiago.andrade@psr-inc.com>", "bernalde <dbernalneira@usra.edu>"]
version = "0.3.1"
authors = ["pedromxavier <pedroxavier@psr-inc.com>", "pedroripper <pedroripper@psr-inc.com>", "joaquimg <joaquim@psr-inc.com>", "AndradeTiago <tiago.andrade@psr-inc.com>", "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

2 comments on commit 4aab7cd

@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/116026

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.3.2 -m "<description of version>" 4aab7cde2723b25c936913318d7097c2a20afc72
git push origin v0.3.2

Please sign in to comment.