Skip to content
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

Fix some deprecation warnings #465

Merged
merged 2 commits into from
Sep 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ os:
- linux
- osx
julia:
- 0.5
- 0.6
- nightly
notifications:
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.4
julia 0.6
Calculus
DualNumbers
Compat
Expand Down
10 changes: 5 additions & 5 deletions src/constraints.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
abstract AbstractConstraints
abstract type AbstractConstraints end

immutable ConstraintsNone <: AbstractConstraints end

immutable ConstraintsBox{T,N} <: AbstractConstraints
lower::Array{T,N}
upper::Array{T,N}

function ConstraintsBox(l::AbstractArray{T}, u::AbstractArray{T})
function ConstraintsBox{T,N}(l::AbstractArray{T,N}, u::AbstractArray{T,N}) where {T,N}
size(l) == size(u) || error("The sizes of the bounds must match")
for i = 1:length(l)
l[i] <= u[i] || error("The lower bound must be smaller than the upper bound")
Expand All @@ -26,8 +26,8 @@ immutable ConstraintsL{T,M<:AbstractMatrix,N} <: AbstractConstraints
scratch2::Array{T,N}
scratch3::Array{T,N}

function ConstraintsL(A, l::Array{T,N}, u::Array{T,N},
scratch1 = similar(l), scratch2 = similar(l), scratch3 = Array{T}(ndims(l) == 1 ? size(A, 2) : (size(A,2),size(l,2))))
function ConstraintsL{T,M,N}(A, l::Array{T,N}, u::Array{T,N},
scratch1 = similar(l), scratch2 = similar(l), scratch3 = Array{T}(ndims(l) == 1 ? size(A, 2) : (size(A,2),size(l,2)))) where {T,M,N}
size(A, 1) == size(l,1) == size(u,1) || error("The sizes of the bounds must match the size of A")
for i = 1:length(l)
l[i] <= u[i] || error("The lower bound must be smaller than the upper bound")
Expand All @@ -45,7 +45,7 @@ immutable ConstraintsNL{T,F<:Union{Function,DifferentiableFunction,TwiceDifferen
lower::Vector{T}
upper::Vector{T}

function ConstraintsNL(funcs::Vector, l::AbstractVector{T}, u::AbstractVector{T})
function ConstraintsNL{T,F}(funcs::Vector, l::AbstractVector{T}, u::AbstractVector{T}) where {T,F}
size(A, 1) == length(l) == length(u) || error("The sizes of the bounds must match the ")
for i = 1:length(l)
l[i] <= u[i] || error("The lower bound must be smaller than the upper bound")
Expand Down
10 changes: 5 additions & 5 deletions src/interior.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function interior_newton{T}(objective::TwiceDifferentiableFunction,
f_x /= t
@newtontrace
alphamax = toedge(x, s, constraints)
alpha = alphamax < 1 ? 0.9*alphamax : 1.0
alpha = alphamax < 1 ? T(0.9*alphamax) : T(1.0)
alpha, _f_calls, _g_calls =
hz_linesearch!(df, x, s, xtmp, gr, lsr, alpha, true, constraints, alphamax)
copy!(x_previous, x)
Expand Down Expand Up @@ -297,10 +297,10 @@ function interior_newton{T}(objective::TwiceDifferentiableFunction,
(x,gr) -> combined_fg!(x, gr, objective.fg!, constraints, t))
end
end
MultivariateOptimizationResults("Interior/Newton",
MultivariateOptimizationResults{T,1}("Interior/Newton",
initial_x,
x,
@compat(Float64(f_x)),
f_x,
iteration,
iteration == iterations,
x_converged,
Expand Down Expand Up @@ -329,10 +329,10 @@ function interior{T}(objective::Union{DifferentiableFunction, TwiceDifferentiabl
if isnan(t)
vo, vc, gogo, gogc = gnorm(objective, constraints, initial_x)
if isfinite(vo) && isfinite(vc) && sqrt(gogo) < grtol
return MultivariateOptimizationResults("Interior",
return MultivariateOptimizationResults{T,ndims(initial_x)}("Interior",
initial_x,
initial_x,
@compat(Float64(vo)),
vo,
0,
false,
false,
Expand Down
4 changes: 2 additions & 2 deletions src/problems/constrained.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ConstrainedProblems
using Optim, Compat

immutable ConstrainedProblem{C<:Optim.AbstractConstraints}
name::Compat.ASCIIString
name::String
f::Function
g!::Function
h!::Function
Expand All @@ -14,7 +14,7 @@ immutable ConstrainedProblem{C<:Optim.AbstractConstraints}
istwicedifferentiable::Bool
end

pexamples = Dict{Compat.ASCIIString, ConstrainedProblem}()
pexamples = Dict{String, ConstrainedProblem}()

#####################################
###
Expand Down
4 changes: 2 additions & 2 deletions src/problems/unconstrained.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module UnconstrainedProblems
using Compat

immutable OptimizationProblem
name::Compat.ASCIIString
name::String
f::Function
g!::Function
h!::Function
Expand All @@ -13,7 +13,7 @@ immutable OptimizationProblem
istwicedifferentiable::Bool
end

examples = Dict{Compat.ASCIIString, OptimizationProblem}()
examples = Dict{String, OptimizationProblem}()

##########################################################################
###
Expand Down
12 changes: 6 additions & 6 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ immutable OptimizationState
end

function OptimizationState(i::Integer, f::Real)
OptimizationState(int(i), @compat(Float64(f)), NaN, Dict())
OptimizationState(int(i), Float64(f), NaN, Dict())
end

function OptimizationState(i::Integer, f::Real, g::Real)
OptimizationState(int(i), @compat(Float64(f)), @compat(Float64(g)), Dict())
OptimizationState(int(i), Float64(f), Float64(g), Dict())
end

immutable OptimizationTrace
Expand All @@ -19,10 +19,10 @@ end

OptimizationTrace() = OptimizationTrace(Vector{OptimizationState}(0))

abstract OptimizationResults
abstract type OptimizationResults end

type MultivariateOptimizationResults{T,N} <: OptimizationResults
method::Compat.ASCIIString
method::String
initial_x::Array{T,N}
minimum::Array{T,N}
f_minimum::Float64
Expand All @@ -40,7 +40,7 @@ type MultivariateOptimizationResults{T,N} <: OptimizationResults
end

type UnivariateOptimizationResults{T} <: OptimizationResults
method::Compat.ASCIIString
method::String
initial_lower::T
initial_upper::T
minimum::T
Expand Down Expand Up @@ -204,7 +204,7 @@ LineSearchResults{T}(::Type{T}) = LineSearchResults(T[], T[], T[], 0)

Base.length(lsr::LineSearchResults) = length(lsr.alpha)

function Base.push!{T}(lsr::LineSearchResults{T}, a::T, v::T, d::T)
function Base.push!(lsr::LineSearchResults, a, v, d)
push!(lsr.alpha, a)
push!(lsr.value, v)
push!(lsr.slope, d)
Expand Down