-
Notifications
You must be signed in to change notification settings - Fork 8
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
Support BitArrays #232
Comments
Do you have a reproducible example? Did you mean |
I'll try to boil it down |
vertices = [
falses(4),
trues(4),
]
m = Model()
n = length(vertices[1])
nv = length(vertices)
@variable(m, x[1:n])
@variable(m, α[1:nv] >= 0)
@constraint(m, sum(α[i] * vertices[i] for i in 1:nv) .== x) |
So this worked: julia> using JuMP
julia> data = [falses(4), trues(4)]
2-element Vector{BitVector}:
[0, 0, 0, 0]
[1, 1, 1, 1]
julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
julia> @variable(model, x[1:4])
4-element Vector{VariableRef}:
x[1]
x[2]
x[3]
x[4]
julia> @variable(model, y[1:2])
2-element Vector{VariableRef}:
y[1]
y[2]
julia> @constraint(model, sum(y[i] .* data[i] for i in 1:2) .== x)
4-element Vector{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}, ScalarShape}}:
-x[1] + y[2] = 0
-x[2] + y[2] = 0
-x[3] + y[2] = 0
-x[4] + y[2] = 0 But the other error message is bad. |
julia> import MutableArithmetics as MA
julia> x = zeros(BigInt, 2)
2-element Vector{BigInt}:
0
0
julia> MA.operate!!(MA.add_mul, x, big(1), trues(2))
ERROR: MethodError: no method matching similar_array_type(::Type{BitVector}, ::Type{BigInt})
Closest candidates are:
similar_array_type(::Type{LinearAlgebra.Symmetric{T, MT}}, ::Type{S}) where {S, T, MT}
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/implementations/LinearAlgebra.jl:151
similar_array_type(::Type{Array{T, N}}, ::Type{S}) where {S, T, N}
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/implementations/LinearAlgebra.jl:158
similar_array_type(::Type{<:Union{LinearAlgebra.Adjoint{T, A}, LinearAlgebra.Transpose{T, A}}}, ::Type{S}) where {S, T, A}
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/implementations/LinearAlgebra.jl:442
...
Stacktrace:
[1] promote_operation(op::typeof(*), #unused#::Type{BigInt}, A::Type{BitVector})
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/implementations/LinearAlgebra.jl:173
[2] promote_operation_fallback(op::typeof(MutableArithmetics.add_mul), #unused#::Type{Vector{BigInt}}, #unused#::Type{BigInt}, #unused#::Type{BitVector})
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:82
[3] promote_operation(::typeof(MutableArithmetics.add_mul), ::Type, ::Type, ::Type)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:113
[4] mutability(::Type, ::Function, ::Type, ::Type, ::Type)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:266
[5] mutability(::Vector{BigInt}, ::Function, ::Vector{BigInt}, ::BigInt, ::BitVector)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/interface.jl:274
[6] operate!!(::typeof(MutableArithmetics.add_mul), ::Vector{BigInt}, ::BigInt, ::BitVector)
@ MutableArithmetics ~/.julia/dev/MutableArithmetics/src/rewrite.jl:93
[7] top-level scope
@ REPL[8]:1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue came up when using JuMP with bitarrays, the top of the stack was:
from an expression:
with alpha a vector of variables and vertices a vector of BitVectors
The text was updated successfully, but these errors were encountered: