Skip to content

Commit

Permalink
relax type constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
matbesancon committed Feb 14, 2021
1 parent 6e0b712 commit 7941882
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ but it this *does returns* the actual jacobians.
For theoretical background, refer Section 3 of Differentiating Through a Cone Program, https://arxiv.org/abs/1904.09043
"""
function backward_conic!(model::Optimizer, dA::Matrix{Float64}, db::Vector{Float64}, dc::Vector{Float64})
function backward_conic!(model::Optimizer, dA::AbstractMatrix{<:Real}, db::AbstractVector{<:Real}, dc::AbstractVector{<:Real})
if !in(
MOI.get(model, MOI.TerminationStatus()), (MOI.LOCALLY_SOLVED, MOI.OPTIMAL)
)
Expand Down
10 changes: 5 additions & 5 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -799,16 +799,16 @@ end
] atol=ATOL rtol=RTOL

# test c_extra
dA = zeros(12, 9)
db = zeros(12)
db[3] = 1.0
dc = zeros(9)
dA = spzeros(12, 9)
db = spzeros(12)
db[3] = 1
dc = spzeros(9)

dx, dy, ds = backward_conic!(model, dA, db, dc)

# a small change in the constant in c_extra should not affect any other variable or constraint other than c_extra itself
@test dx zeros(9) atol=1e-2
@test dy zeros(12) atol=0.015
@test dy zeros(12) atol=0.012
@test [ds[1:2]; ds[4:end]] zeros(11) atol=1e-2
@test ds[3] 1.0 atol=1e-2 # except c_extra itself
end
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ using LinearAlgebra
using DelimitedFiles
using GLPK

using SparseArrays: spzeros

import MathOptInterface
const MOI = MathOptInterface
const MOIU = MathOptInterface.Utilities
Expand Down

0 comments on commit 7941882

Please sign in to comment.