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
56 changes: 56 additions & 0 deletions src/c_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,59 @@ function _unsafe_scs_solve(model::_ScsDataWrapper{S,T}) where {S,T}
Base.Libc.flush_cstdio()
return Solution(model.primal, model.dual, model.slack, scs_info, status)
end

# The following is a backward compatible method that does not have the `cs`
# argument that was introduced in SCS.jl v2.2.0. The underlying C API had a
# breaking change, but we don't need to expose it to the users of SCS.jl.
#
# It is important the function signature of this method matches the function
# signature of the full `scs_solve` exactly to avoid ambiguity errors.
function scs_solve(
linear_solver::Type{<:LinearSolver},
m::Integer,
n::Integer,
A,
P,
b::Vector{Float64},
c::Vector{Float64},
z::Integer,
l::Integer,
bu::Vector{Float64},
bl::Vector{Float64},
q::Vector{<:Integer},
s::Vector{<:Integer},
# cs::Vector{<:Integer}, # Skip this argument
ep::Integer,
ed::Integer,
p::Vector{Float64},
primal_sol::Vector{Float64} = zeros(n),
dual_sol::Vector{Float64} = zeros(m),
slack::Vector{Float64} = zeros(m);
warm_start::Bool = false,
options...,
)
return scs_solve(
linear_solver,
m,
n,
A,
P,
b,
c,
z,
l,
bu,
bl,
q,
s,
Int[], # Default cs argument
ep,
ed,
p,
primal_sol,
dual_sol,
slack;
warm_start,
options...,
)
end
17 changes: 4 additions & 13 deletions test/test_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function feasible_basic_conic(T)
ed = 0
q = [12]
s = Int[]
cs = Int[]

b = [
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
Expand Down Expand Up @@ -441,7 +440,7 @@ function feasible_basic_conic(T)
A = SparseMatrixCSC(m, n, colptr .+ 1, rowval .+ 1, vec(values))
P = spzeros(n, n)

sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, cs, ep, ed, Float64[])
sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, ep, ed, Float64[])
@test sol.ret_val == 1
@test SCS.raw_status(sol.info) == "solved"
end
Expand All @@ -459,7 +458,6 @@ function feasible_exponential_conic(T)
ed = 5
q = [0,1,0,2,3]
s = Int[]
cs = Int[]

b = [
-0.883995908378185202, 0.247092008779755457, 0.000000000000000000,
Expand Down Expand Up @@ -569,7 +567,7 @@ function feasible_exponential_conic(T)
A = SparseMatrixCSC(m, n, colptr .+ 1, rowval .+ 1, vec(values))
P = spzeros(n, n)

sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, cs, ep, ed, Float64[])
sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, ep, ed, Float64[])
@assert sol.ret_val == 1
@test SCS.raw_status(sol.info) == "solved"
end
Expand All @@ -588,7 +586,6 @@ function feasible_sdp_conic(T)
ed = 2
q = [2,3,4]
s = [2,3,4]
cs = Int[]

b = [
-0.757244022903780567, 0.000000000000000000, -1.892151461056349238,
Expand Down Expand Up @@ -645,7 +642,7 @@ function feasible_sdp_conic(T)
-0.444627816446985402, 0.443421912904091331, 0.182452167505983420]
A = SparseMatrixCSC(m, n, colptr .+ 1, rowval .+ 1, vec(values))
P = spzeros(n, n)
sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, cs, ep, ed, Float64[])
sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, ep, ed, Float64[])
@test sol.ret_val == 1
@test SCS.raw_status(sol.info) == "solved"
end
Expand Down Expand Up @@ -689,7 +686,6 @@ function feasible_pow_conic(T)
ed = 0
q = Int[]
s = Int[]
cs = Int[]
p = [-3.0e-01, 2.5e-01, 7.5e-01, -4.0e-01, 8.7e-01, -1.2e-01]
b = [
-0.887386390749058451, 1.868842541924223610, -0.755288651776904296,
Expand Down Expand Up @@ -720,7 +716,7 @@ function feasible_pow_conic(T)
0.147891351014747152]
A = SparseMatrixCSC(m, n, colptr .+ 1, rowval .+ 1, vec(values))
P = spzeros(n, n)
sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, cs, ep, ed, p)
sol = scs_solve(T, m, n, A, P, b, c, z, l, bu, bl, q, s, ep, ed, p)
@test sol.ret_val == 1
@test SCS.raw_status(sol.info) == "solved"
return
Expand All @@ -743,7 +739,6 @@ function feasible_basic_problems(solver)
Float64[],
Int[],
Int[],
Int[],
0,
0,
Float64[],
Expand Down Expand Up @@ -782,7 +777,6 @@ function test_options(T)
bl = Float64[],
q = Int64[],
s = Int64[],
cs = Int64[],
ep = 0,
ed = 0,
p = Float64[],
Expand Down Expand Up @@ -839,7 +833,6 @@ function test_scs_solve_solution_vectors(solver)
Float64[], # bl
Int[], # q
Int[], # s
Int[], # cs
0, # ep
0, # ed
Float64[], # p
Expand All @@ -862,7 +855,6 @@ function test_scs_solve_solution_vectors(solver)
Float64[], # bl
Int[], # q
Int[], # s
Int[], # cs
0, # ep
0, # ed
Float64[], # p
Expand All @@ -887,7 +879,6 @@ function test_scs_solve_solution_vectors(solver)
Float64[], # bl
Int[], # q
Int[], # s
Int[], # cs
0, # ep
0, # ed
Float64[], # p
Expand Down
Loading