Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
femtocleaner[bot] committed Aug 14, 2017
1 parent e5a1de3 commit ead6bfc
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 60 deletions.
12 changes: 6 additions & 6 deletions src/lp.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MathProgBase
importall MathProgBase.SolverInterface

type Cdd_LPSolutionData{T<:MyType}
mutable struct Cdd_LPSolutionData{T<:MyType}
filename::Cdd_DataFileType
objective::Cdd_LPObjectiveType
solver::Cdd_LPSolverType
Expand Down Expand Up @@ -40,7 +40,7 @@ function dd_freelpsolution(lp::Ptr{Cdd_LPSolutionData{GMPRational}})
@dd_ccall FreeLPSolution Void (Ptr{Cdd_LPSolutionData{GMPRational}},) lp
end

type CDDLPSolution{T<:MyType}
mutable struct CDDLPSolution{T<:MyType}
sol::Ptr{Cdd_LPSolutionData{T}}

function CDDLPSolution{T}(sol::Ptr{Cdd_LPSolutionData{T}}) where {T <: MyType}
Expand All @@ -50,7 +50,7 @@ type CDDLPSolution{T<:MyType}
end
end

CDDLPSolution{T<:MyType}(sol::Ptr{Cdd_LPSolutionData{T}}) = CDDLPSolution{T}(sol)
CDDLPSolution(sol::Ptr{Cdd_LPSolutionData{T}}) where {T<:MyType} = CDDLPSolution{T}(sol)

function myfree(sol::CDDLPSolution)
dd_freelpsolution(sol.sol)
Expand Down Expand Up @@ -115,7 +115,7 @@ function getconstrduals(sol::CDDLPSolution{Cdouble})
dual
end

type Cdd_LPData{T<:MyType}
mutable struct Cdd_LPData{T<:MyType}
filename::Cdd_DataFileType
objective::Cdd_LPObjectiveType
solver::Cdd_LPSolverType
Expand Down Expand Up @@ -187,7 +187,7 @@ function dd_freelpdata(lp::Ptr{Cdd_LPData{GMPRational}})
@dd_ccall FreeLPData Void (Ptr{Cdd_LPData{GMPRational}},) lp
end

type CDDLP{T<:MyType}
mutable struct CDDLP{T<:MyType}
lp::Ptr{Cdd_LPData{T}}

function CDDLP{T}(lp::Ptr{Cdd_LPData{T}}) where {T <: MyType}
Expand All @@ -197,7 +197,7 @@ type CDDLP{T<:MyType}
end
end

CDDLP{T<:MyType}(lp::Ptr{Cdd_LPData{T}}) = CDDLP{T}(lp)
CDDLP(lp::Ptr{Cdd_LPData{T}}) where {T<:MyType} = CDDLP{T}(lp)

function myfree(lp::CDDLP)
dd_freelpdata(lp.lp)
Expand Down
6 changes: 3 additions & 3 deletions src/mathprogbase.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export CDDPolyhedraModel, CDDSolver

type CDDPolyhedraModel <: AbstractPolyhedraModel
mutable struct CDDPolyhedraModel <: AbstractPolyhedraModel
solver_type::Symbol
exact::Bool

Expand All @@ -14,7 +14,7 @@ type CDDPolyhedraModel <: AbstractPolyhedraModel
infeasibilityray
end

type CDDSolver <: AbstractMathProgSolver
mutable struct CDDSolver <: AbstractMathProgSolver
solver_type::Symbol
exact::Bool

Expand All @@ -31,7 +31,7 @@ function PolyhedraModel(s::CDDSolver)
end
LinearQuadraticModel(s::CDDSolver) = PolyhedraToLPQPBridge(PolyhedraModel(s))

function loadproblem!{N}(lpm::CDDPolyhedraModel, rep::HRep{N}, obj, sense)
function loadproblem!(lpm::CDDPolyhedraModel, rep::HRep{N}, obj, sense) where N
T = lpm.exact ? Rational{BigInt} : Float64
prob = CDDInequalityMatrix{N, T, mytype(T)}(rep)
setobjective(prob, obj, sense)
Expand Down
32 changes: 16 additions & 16 deletions src/matrix.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Cdd_MatrixData{T <: MyType}
mutable struct Cdd_MatrixData{T <: MyType}
rowsize::Cdd_rowrange
linset::Cdd_rowset
colsize::Cdd_colrange
Expand Down Expand Up @@ -60,7 +60,7 @@ function dd_matrixcopy(matrix::Ptr{Cdd_MatrixData{GMPRational}})
@dd_ccall MatrixCopy Ptr{Cdd_MatrixData{GMPRational}} (Ptr{Cdd_MatrixData{GMPRational}},) matrix
end

function fillmatrix{T}(inequality::Bool, matrix::Ptr{Ptr{T}}, itr1, linset=IntSet(), offset=0)
function fillmatrix(inequality::Bool, matrix::Ptr{Ptr{T}}, itr1, linset=IntSet(), offset=0) where T
for (i, item) in enumerate(itr1)
row = unsafe_load(matrix, offset+i)
if islin(item)
Expand All @@ -73,7 +73,7 @@ function fillmatrix{T}(inequality::Bool, matrix::Ptr{Ptr{T}}, itr1, linset=IntSe
linset
end

function initmatrix{N, T}(inequality::Bool, itr1::AbstractRepIterator{N, T}, itr2=nothing)
function initmatrix(inequality::Bool, itr1::AbstractRepIterator{N, T}, itr2=nothing) where {N, T}
n = N+1
m = length(itr1)
if !(itr2 === nothing)
Expand All @@ -93,7 +93,7 @@ end

# Representation

type CDDInequalityMatrix{N, T <: PolyType, S <: MyType} <: HRepresentation{N, T}
mutable struct CDDInequalityMatrix{N, T <: PolyType, S <: MyType} <: HRepresentation{N, T}
matrix::Ptr{Cdd_MatrixData{S}}

function CDDInequalityMatrix{N, T, S}(matrix::Ptr{Cdd_MatrixData{S}}) where {N, T <: PolyType, S <: MyType}
Expand All @@ -109,7 +109,7 @@ changefulldim{N, T, S}(::Type{CDDInequalityMatrix{N, T, S}}, NewN) = CDDInequali
changeboth{N, T, S, NewT}(::Type{CDDInequalityMatrix{N, T, S}}, NewN, ::Type{NewT}) = CDDInequalityMatrix{NewN, NewT, mytype(NewT)}
decomposedfast(ine::CDDInequalityMatrix) = false

type CDDGeneratorMatrix{N, T <: PolyType, S <: MyType} <: VRepresentation{N, T}
mutable struct CDDGeneratorMatrix{N, T <: PolyType, S <: MyType} <: VRepresentation{N, T}
matrix::Ptr{Cdd_MatrixData{S}}

function CDDGeneratorMatrix{N, T, S}(matrix::Ptr{Cdd_MatrixData{S}}) where {N, T <: PolyType, S <: MyType}
Expand Down Expand Up @@ -142,7 +142,7 @@ cddmatrix{N,T}(::Type{T}, vrep::VRepresentation{N}) = CDDGeneratorMatrix{N,T,myt
# Does not work
#Base.convert{N,T,S}(::Type{CDDMatrix{N,T,S}}, vrep::VRepresentation{N}) = CDDGeneratorMatrix{N,T,S}(vrep)

function Base.length{N}(matrix::CDDMatrix{N})
function Base.length(matrix::CDDMatrix{N}) where N
mat = unsafe_load(matrix.matrix)
@assert Int(mat.colsize) == N+1
Int(mat.rowsize)
Expand All @@ -160,9 +160,9 @@ end

# H-representation

CDDInequalityMatrix{N,T}(rep::Rep{N,T}) = CDDInequalityMatrix{N,polytypefor(T), mytypefor(T)}(rep)
CDDInequalityMatrix(rep::Rep{N,T}) where {N,T} = CDDInequalityMatrix{N,polytypefor(T), mytypefor(T)}(rep)

CDDInequalityMatrix{T}(matrix::Ptr{Cdd_MatrixData{T}}) = CDDInequalityMatrix{unsafe_load(matrix).colsize-1, polytype(T), T}(matrix)
CDDInequalityMatrix(matrix::Ptr{Cdd_MatrixData{T}}) where {T} = CDDInequalityMatrix{unsafe_load(matrix).colsize-1, polytype(T), T}(matrix)

function CDDInequalityMatrix{N, T, S}(it::HRepIterator{N, T}) where {N, T, S}
CDDInequalityMatrix(initmatrix(true, it))
Expand All @@ -175,7 +175,7 @@ nhreps(matrix::CDDInequalityMatrix) = length(matrix)
neqs(matrix::CDDInequalityMatrix) = dd_set_card(unsafe_load(matrix.matrix).linset)
nineqs(matrix::CDDInequalityMatrix) = length(matrix) - neqs(matrix)

function Base.copy{N, T, S}(matrix::CDDInequalityMatrix{N, T, S})
function Base.copy(matrix::CDDInequalityMatrix{N, T, S}) where {N, T, S}
CDDInequalityMatrix{N, T, S}(dd_matrixcopy(matrix.matrix))
end

Expand Down Expand Up @@ -213,7 +213,7 @@ function extractrow(ine::CDDInequalityMatrix, i)
HalfSpace(a, β)
end
end
function extractrow{N,T}(ext::CDDGeneratorMatrix{N,T}, i)
function extractrow(ext::CDDGeneratorMatrix{N,T}, i) where {N,T}
mat = unsafe_load(ext.matrix)
b = extractrow(mat, i)
ispoint = b[1]
Expand All @@ -233,7 +233,7 @@ function extractrow{N,T}(ext::CDDGeneratorMatrix{N,T}, i)
end
end
end
function isrowpoint{N,T}(ext::CDDGeneratorMatrix{N,T}, i)
function isrowpoint(ext::CDDGeneratorMatrix{N,T}, i) where {N,T}
mat = unsafe_load(ext.matrix)
b = extractrow(unsafe_load(ext.matrix), i)
ispoint = b[1]
Expand Down Expand Up @@ -269,19 +269,19 @@ function isaninequalityrepresentation(matrix::CDDInequalityMatrix)
true
end

function setobjective{N, T}(matrix::CDDInequalityMatrix{N, T}, c, sense)
function setobjective(matrix::CDDInequalityMatrix{N, T}, c, sense) where {N, T}
dd_setmatrixobjective(matrix.matrix, sense == :Max ? dd_LPmax : dd_LPmin)
obj = [zero(T); Vector{T}(c)]
dd_copyArow(unsafe_load(matrix.matrix).rowvec, obj)
end

# V-representation

CDDGeneratorMatrix{N,T}(rep::Rep{N,T}) = CDDGeneratorMatrix{N,polytypefor(T), mytypefor(T)}(rep)
CDDGeneratorMatrix(rep::Rep{N,T}) where {N,T} = CDDGeneratorMatrix{N,polytypefor(T), mytypefor(T)}(rep)

CDDGeneratorMatrix{T}(matrix::Ptr{Cdd_MatrixData{T}}) = CDDGeneratorMatrix{unsafe_load(matrix).colsize-1, polytype(T), T}(matrix)
CDDGeneratorMatrix(matrix::Ptr{Cdd_MatrixData{T}}) where {T} = CDDGeneratorMatrix{unsafe_load(matrix).colsize-1, polytype(T), T}(matrix)

function Base.copy{N, T, S}(matrix::CDDGeneratorMatrix{N, T, S})
function Base.copy(matrix::CDDGeneratorMatrix{N, T, S}) where {N, T, S}
CDDGeneratorMatrix{N, T, S}(dd_matrixcopy(matrix.matrix))
end

Expand Down Expand Up @@ -360,7 +360,7 @@ function extractA(mat::Cdd_MatrixData{GMPRational})
Array{GMPRational}(A)
end

function Base.show{T}(io::IO, matrix::Cdd_MatrixData{T})
function Base.show(io::IO, matrix::Cdd_MatrixData{T}) where T
if matrix.representation == dd_Inequality
println(io, "H-representation")
else
Expand Down
8 changes: 4 additions & 4 deletions src/mytype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Base.+, Base.-, Base.*, Base.promote_rule, Base.==, Base.zero, Base.zeros

# It is immutable so that it is stored by value in the structures
# GMPRational and GMPRationalMut and not by reference
immutable GMPInteger
struct GMPInteger
alloc::Cint
size::Cint
data::Ptr{UInt32}
end

type GMPRationalMut
mutable struct GMPRationalMut
num::GMPInteger
den::GMPInteger

Expand Down Expand Up @@ -51,7 +51,7 @@ Base.zero(::Type{GMPRationalMut}) = GMPRationalMut(0)

# I cannot have a finalizer for an immutable so you are responsibe to free it
# if you use it using e.g. myfree define below
immutable GMPRational <: Real
struct GMPRational <: Real
num::GMPInteger
den::GMPInteger
function GMPRational(m::GMPRationalMut)
Expand All @@ -73,7 +73,7 @@ Base.convert(::Type{GMPRational}, x::GMPRationalMut) = GMPRational(x)

GMPRational() = GMPRational(GMPRationalMut())

GMPRational{T<:Integer,S<:Integer}(a::S, b::T) = GMPRational(GMPRationalMut(a, b))
GMPRational(a::S, b::T) where {T<:Integer,S<:Integer} = GMPRational(GMPRationalMut(a, b))
Base.convert{T<:Real}(::Type{GMPRational}, a::T) = GMPRational(GMPRationalMut(a))
Base.convert(::Type{GMPRational}, a::GMPRational) = a

Expand Down
16 changes: 8 additions & 8 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ function dd_inputappend(poly::Ptr{Cdd_PolyhedraData{GMPRational}}, matrix::Ptr{C
polyptr[]
end

function Base.push!{N, T<:PolyType}(poly::CDDPolyhedra{N, T}, ine::CDDInequalityMatrix{N, T})
function Base.push!(poly::CDDPolyhedra{N, T}, ine::CDDInequalityMatrix{N, T}) where {N, T<:PolyType}
if !poly.inequality
switchinputtype!(poly)
end
poly.poly = dd_inputappend(poly.poly, ine.matrix)
end

function Base.push!{N, T<:PolyType}(poly::CDDPolyhedra{N, T}, ext::CDDGeneratorMatrix{N, T})
function Base.push!(poly::CDDPolyhedra{N, T}, ext::CDDGeneratorMatrix{N, T}) where {N, T<:PolyType}
if poly.inequality
switchinputtype!(poly)
end
poly.poly = dd_inputappend(poly.poly, ext.matrix)
end

function Base.push!{N,T,S}(poly::CDDPolyhedra{N,T}, rep::Representation{N,S})
function Base.push!(poly::CDDPolyhedra{N,T}, rep::Representation{N,S}) where {N,T,S}
Base.push!(poly, cddmatrix(T, rep))
end

Expand All @@ -44,13 +44,13 @@ end
function dd_matrixappend(matrix1::Ptr{Cdd_MatrixData{GMPRational}}, matrix2::Ptr{Cdd_MatrixData{GMPRational}})
@dd_ccall MatrixAppend Ptr{Cdd_MatrixData{GMPRational}} (Ptr{Cdd_MatrixData{GMPRational}}, Ptr{Cdd_MatrixData{GMPRational}}) matrix1 matrix2
end
function matrixappend{N, T, S}(matrix1::CDDInequalityMatrix{N, T, S}, matrix2::CDDInequalityMatrix{N, T, S})
function matrixappend(matrix1::CDDInequalityMatrix{N, T, S}, matrix2::CDDInequalityMatrix{N, T, S}) where {N, T, S}
CDDInequalityMatrix{N, T, S}(dd_matrixappend(matrix1.matrix, matrix2.matrix))
end
function matrixappend{N, T, S}(matrix1::CDDGeneratorMatrix{N, T, S}, matrix2::CDDGeneratorMatrix{N, T, S})
function matrixappend(matrix1::CDDGeneratorMatrix{N, T, S}, matrix2::CDDGeneratorMatrix{N, T, S}) where {N, T, S}
CDDGeneratorMatrix{N, T, S}(dd_matrixappend(matrix1.matrix, matrix2.matrix))
end
function matrixappend{N, S, T}(matrix::CDDMatrix{N, T}, repr::Representation{N, S})
function matrixappend(matrix::CDDMatrix{N, T}, repr::Representation{N, S}) where {N, S, T}
matrixappend(matrix, cddmatrix(T, repr))
end

Expand Down Expand Up @@ -231,7 +231,7 @@ function dd_fourierelimination(matrix::Ptr{Cdd_MatrixData{GMPRational}})
myerror(err[])
newmatrix
end
function fourierelimination{N, T, S}(matrix::CDDInequalityMatrix{N, T, S})
function fourierelimination(matrix::CDDInequalityMatrix{N, T, S}) where {N, T, S}
CDDInequalityMatrix{N-1, T, S}(dd_fourierelimination(matrix.matrix))
end
function fourierelimination(ine::HRepresentation)
Expand All @@ -252,7 +252,7 @@ function dd_blockelimination(matrix::Ptr{Cdd_MatrixData{GMPRational}}, delset::C
myerror(err[])
newmatrix
end
function blockelimination{N, T, S}(matrix::CDDInequalityMatrix{N, T, S}, delset=IntSet([N]))
function blockelimination(matrix::CDDInequalityMatrix{N, T, S}, delset=IntSet([N])) where {N, T, S}
if last(delset) > N
error("Invalid variable to eliminate")
end
Expand Down
10 changes: 5 additions & 5 deletions src/polyhedra.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Cdd_PolyhedraData{T<:MyType}
mutable struct Cdd_PolyhedraData{T<:MyType}
representation::Cdd_RepresentationType
# given representation
homogeneous::Cdd_boolean
Expand Down Expand Up @@ -60,7 +60,7 @@ function dd_matrix2poly(matrix::Ptr{Cdd_MatrixData{GMPRational}})
poly
end

type CDDPolyhedra{N, T<:PolyType, S}
mutable struct CDDPolyhedra{N, T<:PolyType, S}
poly::Ptr{Cdd_PolyhedraData{S}}
inequality::Bool # The input type is inequality

Expand All @@ -73,14 +73,14 @@ type CDDPolyhedra{N, T<:PolyType, S}

end

function myfree{N}(poly::CDDPolyhedra{N, Cdouble})
function myfree(poly::CDDPolyhedra{N, Cdouble}) where N
@ddf_ccall FreePolyhedra Void (Ptr{Cdd_PolyhedraData{Cdouble}},) poly.poly
end
function myfree{N}(poly::CDDPolyhedra{N, Rational{BigInt}})
function myfree(poly::CDDPolyhedra{N, Rational{BigInt}}) where N
@dd_ccall FreePolyhedra Void (Ptr{Cdd_PolyhedraData{GMPRational}},) poly.poly
end

CDDPolyhedra{N, T, S}(matrix::CDDMatrix{N, T, S}) = CDDPolyhedra{N, T, S}(matrix)
CDDPolyhedra(matrix::CDDMatrix{N, T, S}) where {N, T, S} = CDDPolyhedra{N, T, S}(matrix)
CDDPolyhedra(rep::Representation) = CDDPolyhedra(CDDMatrix(rep))

function Base.convert{N, T, S}(::Type{CDDPolyhedra{N, T, S}}, matrix::CDDMatrix{N, T, S})
Expand Down
Loading

0 comments on commit ead6bfc

Please sign in to comment.