From 3a277d468a054d6e195156544013841895b3630b Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 25 Jun 2017 10:13:02 -0500 Subject: [PATCH 1/2] Relax signature of push!(::LineSearchResults, ...) --- src/interior.jl | 2 +- src/types.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interior.jl b/src/interior.jl index f0752e279..549c86293 100644 --- a/src/interior.jl +++ b/src/interior.jl @@ -332,7 +332,7 @@ function interior{T}(objective::Union{DifferentiableFunction, TwiceDifferentiabl return MultivariateOptimizationResults("Interior", initial_x, initial_x, - @compat(Float64(vo)), + Float64(vo), 0, false, false, diff --git a/src/types.jl b/src/types.jl index f3d1df737..7885b5f57 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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) From f308ed07f283c3323cc74cc71728914a43e0f1ef Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 23 Sep 2017 05:45:32 -0500 Subject: [PATCH 2/2] Get rid of deprecation warnings --- .travis.yml | 1 - REQUIRE | 2 +- src/constraints.jl | 10 +++++----- src/interior.jl | 10 +++++----- src/problems/constrained.jl | 4 ++-- src/problems/unconstrained.jl | 4 ++-- src/types.jl | 10 +++++----- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31e995163..215ca344b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ os: - linux - osx julia: - - 0.5 - 0.6 - nightly notifications: diff --git a/REQUIRE b/REQUIRE index 01c9f80aa..e13cb8e3c 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ -julia 0.4 +julia 0.6 Calculus DualNumbers Compat diff --git a/src/constraints.jl b/src/constraints.jl index 2167691e8..9824ae39f 100644 --- a/src/constraints.jl +++ b/src/constraints.jl @@ -1,4 +1,4 @@ -abstract AbstractConstraints +abstract type AbstractConstraints end immutable ConstraintsNone <: AbstractConstraints end @@ -6,7 +6,7 @@ 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") @@ -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") @@ -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") diff --git a/src/interior.jl b/src/interior.jl index 549c86293..41d908de8 100644 --- a/src/interior.jl +++ b/src/interior.jl @@ -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) @@ -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, @@ -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, - Float64(vo), + vo, 0, false, false, diff --git a/src/problems/constrained.jl b/src/problems/constrained.jl index 9be87587e..93d2987be 100644 --- a/src/problems/constrained.jl +++ b/src/problems/constrained.jl @@ -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 @@ -14,7 +14,7 @@ immutable ConstrainedProblem{C<:Optim.AbstractConstraints} istwicedifferentiable::Bool end -pexamples = Dict{Compat.ASCIIString, ConstrainedProblem}() +pexamples = Dict{String, ConstrainedProblem}() ##################################### ### diff --git a/src/problems/unconstrained.jl b/src/problems/unconstrained.jl index 3fda09228..8b6a4b985 100644 --- a/src/problems/unconstrained.jl +++ b/src/problems/unconstrained.jl @@ -3,7 +3,7 @@ module UnconstrainedProblems using Compat immutable OptimizationProblem - name::Compat.ASCIIString + name::String f::Function g!::Function h!::Function @@ -13,7 +13,7 @@ immutable OptimizationProblem istwicedifferentiable::Bool end -examples = Dict{Compat.ASCIIString, OptimizationProblem}() +examples = Dict{String, OptimizationProblem}() ########################################################################## ### diff --git a/src/types.jl b/src/types.jl index 7885b5f57..4bd05ce90 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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 @@ -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 @@ -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