Skip to content
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
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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())'
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ BinDeps
MathProgBase 0.5 0.8
MathOptInterface 0.5.1 0.6
@osx Homebrew
Compat 0.63
Compat 0.68
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ environment:
matrix:
- julia_version: 0.6
- julia_version: 0.7
- julia_version: 1.0

platform:
- x86 # 32-bit
Expand Down
19 changes: 12 additions & 7 deletions src/MOIWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ 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...)
new(ConeData(), false, nothing, Solution(), kwargs)
end
end

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
end
Expand Down Expand Up @@ -214,12 +219,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
Expand Down Expand Up @@ -343,7 +348,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]
Expand All @@ -360,7 +365,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)
Expand Down Expand Up @@ -390,7 +395,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
Expand Down
2 changes: 1 addition & 1 deletion src/MPBWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions test/MPBWrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -25,6 +33,6 @@ import ECOS
conicEXPtest(ECOS.ECOSSolver(), duals=true)
end

include(joinpath(Pkg.dir("MathProgBase"),"test","quadprog.jl"))
include(joinpath(MPB_test_path, "quadprog.jl"))
socptest(ECOS.ECOSSolver())
end