Skip to content

Commit

Permalink
Bump Version + Exchange varcmp -> varlt
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromxavier committed Jan 6, 2023
1 parent b91af05 commit 8486167
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"joaquimg <[email protected]>",
"bernalde <[email protected]>"
]
version = "0.5.4"
version = "0.6.0"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ QUBOTools.backend

### Variable System
```@docs
QUBOTools.varcmp
QUBOTools.varlt
```

### Variable Domains
Expand Down
8 changes: 4 additions & 4 deletions src/QUBOTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ using InteractiveUtils: subtypes

# ~*~ Variable comparison ~*~ #
@doc raw"""
varcmp(x::V, y::V) where {V}
varlt(x::V, y::V) where {V}
This function exists to define an arbitrary ordering for a given type and was created to address [1].
There is no predefined comparison between instances MOI's `VariableIndex` type.
[1] https://github.com/jump-dev/MathOptInterface.jl/issues/1985
""" function varcmp end
""" function varlt end

varcmp(x::V, y::V) where {V} = isless(x, y)
varlt(x::V, y::V) where {V} = isless(x, y)

const = varcmp # \prec[tab]
const = varlt # \prec[tab]
const = -1 # \uparrow[tab]
const = +1 # \downarrow[tab]

Expand Down
1 change: 1 addition & 0 deletions src/formats/qubo/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function read_model(io::IO, fmt::QUBO)
data[:quadratic_terms];
scale = data[:scale],
offset = data[:offset],
domain = domain(fmt),
id = data[:id],
description = data[:description],
metadata = data[:metadata],
Expand Down
6 changes: 6 additions & 0 deletions src/interface/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ function format(
end

# -* Sense *- #
Base.show(io::IO, ::MinSense) = print(io, "Min")
Base.show(io::IO, ::MaxSense) = print(io, "Max")

swap_sense(::Nothing) = nothing

swap_sense(::MaxSense) = Min
Expand Down Expand Up @@ -222,6 +225,9 @@ end


# -* Domain *- #
Base.show(io::IO, ::BoolDomain) = print(io, "𝔹")
Base.show(io::IO, ::SpinDomain) = print(io, "𝕊")

function domain_name(::BoolDomain)
return "Bool"
end
Expand Down
2 changes: 1 addition & 1 deletion src/library/tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function _build_mapping(variable_set::Set{V}) where {V}
variable_map = sizehint!(Dict{V,Int}(), length(variable_set))
variable_inv = sizehint!(Dict{Int,V}(), length(variable_map))

for (k, v) in enumerate(sort!(collect(variable_set); lt = varcmp))
for (k, v) in enumerate(sort!(collect(variable_set); lt = varlt))
variable_map[v] = k
variable_inv[k] = v
end
Expand Down

0 comments on commit 8486167

Please sign in to comment.