Skip to content

Commit

Permalink
Workaround for julia#22225
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 6, 2017
1 parent 81cabeb commit 962fea8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/cutstore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ type CutStore{S}
storecuts::Symbol

function (::Type{CutStore{S}}){S}(nvars)
new{S}(spzeros(S, 0, nvars), spzeros(S, 0), NLDS{S}[], spzeros(S, 0, nvars), spzeros(S, 0), NLDS{S}[], Vector{Tuple{NLDS{S},Tuple{Symbol,Int64}}}(0), Vector{Bool}(0), :IfNeededElseDelete)
# spzeros(S, 0) -> S[] : See julia#22225
new{S}(spzeros(S, 0, nvars), S[], NLDS{S}[], spzeros(S, 0, nvars), S[], NLDS{S}[], Vector{Tuple{NLDS{S},Tuple{Symbol,Int64}}}(0), Vector{Bool}(0), :IfNeededElseDelete)
end
end

function checksparseness(a::Vector)
function checksparseness(a::AbstractVector)
if true || countnz(a) * 2 < length(a)
sparse(a)
else
a
end
end

function addcut{S}(store::CutStore{S}, a::Vector{S}, β::S, author)
function addcut{S}(store::CutStore{S}, a::AbstractVector{S}, β::S, author)
a = checksparseness(a)
store.Anew = mymatcat(store.Anew, a)
store.bnew = myveccat(store.bnew, β)
Expand All @@ -66,7 +67,7 @@ function apply!{S}(store::CutStore{S})
end

store.Anew = spzeros(S, 0, size(store.A, 2))
store.bnew = spzeros(S, 0)
store.bnew = S[] # See julia#22225
store.authorsnew = NLDS{S}[]
end
end
Expand All @@ -83,7 +84,7 @@ function noneedstored!{S}(store::CutStore{S}, nlds)
store.needstored[findfirst(f->f[1] === nlds, store.followers)] = false
if store.storecuts == :IfNeededElseDelete && !reduce(|, false, store.needstored)
store.A = spzeros(S, 0, size(store.A, 2))
store.b = spzeros(S, 0)
store.b = S[] # See julia#22225
store.authors = NLDS{S}[]
end
end

0 comments on commit 962fea8

Please sign in to comment.