From f9ad0c419f8910de88afef0ef0b5d747707a375a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 28 Aug 2018 14:27:27 +0200 Subject: [PATCH 1/3] Fixes for Julia v1.0 --- .travis.yml | 4 +--- REQUIRE | 2 +- appveyor.yml | 1 + src/MOIWrapper.jl | 17 ++++++++++------- src/MPBWrapper.jl | 2 +- test/MPBWrapper.jl | 17 ++++++++++++++--- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 519c8c6..b64752b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,9 @@ os: julia: - 0.6 - 0.7 + - 1.0 notifications: email: false -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'Pkg.clone(pwd()); Pkg.build("ECOS"); Pkg.test("ECOS"; coverage=true)' after_success: - julia -e 'cd(Pkg.dir("ECOS")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' - julia -e 'cd(Pkg.dir("ECOS")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' diff --git a/REQUIRE b/REQUIRE index 5a87f4b..88ee95f 100644 --- a/REQUIRE +++ b/REQUIRE @@ -3,4 +3,4 @@ BinDeps MathProgBase 0.5 0.8 MathOptInterface 0.5.1 0.6 @osx Homebrew -Compat 0.63 +Compat 0.68 diff --git a/appveyor.yml b/appveyor.yml index eea8529..1deff5c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,7 @@ environment: matrix: - julia_version: 0.6 - julia_version: 0.7 + - julia_version: 1.0 platform: - x86 # 32-bit diff --git a/src/MOIWrapper.jl b/src/MOIWrapper.jl index 9b77ba9..0835d3d 100644 --- a/src/MOIWrapper.jl +++ b/src/MOIWrapper.jl @@ -61,7 +61,7 @@ end mutable struct Optimizer <: MOI.AbstractOptimizer cone::ConeData maxsense::Bool - data::Union{Void, ModelData} # only non-Void between MOI.copy! and MOI.optimize! + data::Union{Nothing, ModelData} # only non-Nothing between MOI.copy! and MOI.optimize! sol::Solution options function Optimizer(; kwargs...) @@ -69,6 +69,9 @@ mutable struct Optimizer <: MOI.AbstractOptimizer end end +# TODO remove when updating to MOI v0.6 +Base.broadcastable(optimizer::Optimizer) = Ref(optimizer) + function MOI.isempty(instance::Optimizer) !instance.maxsense && instance.data === nothing end @@ -214,12 +217,12 @@ function MOIU.loadconstraint!(instance::Optimizer, ci, f::MOI.VectorAffineFuncti else instance.cone.ineqnrows[offset] = length(rows) end - i = offset + rows + i = offset .+ rows # The ECOS format is b - Ax ∈ cone # so minus=false for b and minus=true for A b, Is, Js, Vs = matrix(instance, s) - b[i] = scalecoef(rows, orderval(f.constants, s), false, s) - append!(Is, offset + orderidx(I, s)) + b[i] .= scalecoef(rows, orderval(f.constants, s), false, s) + append!(Is, offset .+ orderidx(I, s)) append!(Js, J) append!(Vs, scalecoef(I, V, true, s)) end @@ -343,7 +346,7 @@ end function MOI.get(instance::Optimizer, ::MOI.VariablePrimal, vi::VI) instance.sol.primal[vi.value] end -MOI.get(instance::Optimizer, a::MOI.VariablePrimal, vi::Vector{VI}) = MOI.get.(instance, a, vi) +MOI.get(instance::Optimizer, a::MOI.VariablePrimal, vi::Vector{VI}) = MOI.get.(instance, Ref(a), vi) # setconstant: Retrieve set constant stored in `ConeData` during `copy!` setconstant(instance::Optimizer, offset, ::CI{<:MOI.AbstractFunction, <:MOI.EqualTo}) = instance.cone.eqsetconstant[offset] setconstant(instance::Optimizer, offset, ::CI) = instance.cone.ineqsetconstant[offset] @@ -360,7 +363,7 @@ end function MOI.get(instance::Optimizer, ::MOI.ConstraintPrimal, ci::CI{<:MOI.AbstractFunction, S}) where S <: MOI.AbstractSet offset = constroffset(instance, ci) rows = constrrows(instance, ci) - _unshift(instance, offset, scalecoef(rows, reorderval(instance.sol.slack[offset + rows], S), false, S), ci) + _unshift(instance, offset, scalecoef(rows, reorderval(instance.sol.slack[offset .+ rows], S), false, S), ci) end function MOI.canget(instance::Optimizer, ::MOI.DualStatus) @@ -390,7 +393,7 @@ _dual(instance, ci::CI) = instance.sol.dual_ineq function MOI.get(instance::Optimizer, ::MOI.ConstraintDual, ci::CI{<:MOI.AbstractFunction, S}) where S <: MOI.AbstractSet offset = constroffset(instance, ci) rows = constrrows(instance, ci) - scalecoef(rows, reorderval(_dual(instance, ci)[offset + rows], S), false, S) + scalecoef(rows, reorderval(_dual(instance, ci)[offset .+ rows], S), false, S) end MOI.canget(instance::Optimizer, ::MOI.ResultCount) = true diff --git a/src/MPBWrapper.jl b/src/MPBWrapper.jl index d81bb4a..ebae706 100644 --- a/src/MPBWrapper.jl +++ b/src/MPBWrapper.jl @@ -375,7 +375,7 @@ function MPB.loadproblem!(m::ECOSMathProgModel, c, A, b, constr_cones, var_cones append!(exp_rows, [idxs[1],idxs[3],idxs[2]]) # override update_row_map to handle the permutation - m.row_map_type[idxs] = :ExpPrimal + m.row_map_type[idxs] .= :ExpPrimal m.row_map_ind[idxs[1]] = neq_cur_ind m.row_map_ind[idxs[3]] = neq_cur_ind+1 m.row_map_ind[idxs[2]] = neq_cur_ind+2 diff --git a/test/MPBWrapper.jl b/test/MPBWrapper.jl index 2d17803..f93e00e 100644 --- a/test/MPBWrapper.jl +++ b/test/MPBWrapper.jl @@ -12,8 +12,16 @@ end import ECOS + +import MathProgBase +@static if VERSION >= v"0.7-" + const MPB_test_path = joinpath(dirname(pathof(MathProgBase)), "..", "test") +else + const MPB_test_path = joinpath(Pkg.dir("MathProgBase"), "test") +end + @testset "Run the conic interface test from MathProgBase.jl" begin - include(joinpath(Pkg.dir("MathProgBase"),"test","conicinterface.jl")) + include(joinpath(MPB_test_path, "conicinterface.jl")) coniclineartest(ECOS.ECOSSolver(), duals=true) conicSOCtest(ECOS.ECOSSolver(), duals=true) @static if !Compat.Sys.iswindows() @@ -25,6 +33,9 @@ import ECOS conicEXPtest(ECOS.ECOSSolver(), duals=true) end - include(joinpath(Pkg.dir("MathProgBase"),"test","quadprog.jl")) - socptest(ECOS.ECOSSolver()) + # See https://github.com/JuliaOpt/MathProgBase.jl/pull/218 + if VERSION < v"0.7-" + include(joinpath(MPB_test_path, "quadprog.jl")) + socptest(ECOS.ECOSSolver()) + end end From 7f414b6a4109bfb4e8ef3bea51acb72e65c336db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 28 Aug 2018 14:38:52 +0200 Subject: [PATCH 2/3] Fix --- src/MOIWrapper.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MOIWrapper.jl b/src/MOIWrapper.jl index 0835d3d..7acd396 100644 --- a/src/MOIWrapper.jl +++ b/src/MOIWrapper.jl @@ -69,8 +69,10 @@ mutable struct Optimizer <: MOI.AbstractOptimizer end end -# TODO remove when updating to MOI v0.6 -Base.broadcastable(optimizer::Optimizer) = Ref(optimizer) +if VERSION >= v"0.7-" + # TODO remove when updating to MOI v0.6 + Base.broadcastable(optimizer::Optimizer) = Ref(optimizer) +end function MOI.isempty(instance::Optimizer) !instance.maxsense && instance.data === nothing From 321e695c0f892a8aefbbc38ab811dbc86cdc3f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 28 Aug 2018 21:20:30 +0200 Subject: [PATCH 3/3] Reenable test --- test/MPBWrapper.jl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/MPBWrapper.jl b/test/MPBWrapper.jl index f93e00e..ccf449c 100644 --- a/test/MPBWrapper.jl +++ b/test/MPBWrapper.jl @@ -33,9 +33,6 @@ end conicEXPtest(ECOS.ECOSSolver(), duals=true) end - # See https://github.com/JuliaOpt/MathProgBase.jl/pull/218 - if VERSION < v"0.7-" - include(joinpath(MPB_test_path, "quadprog.jl")) - socptest(ECOS.ECOSSolver()) - end + include(joinpath(MPB_test_path, "quadprog.jl")) + socptest(ECOS.ECOSSolver()) end