Skip to content

Commit

Permalink
update to ECOS 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Aug 25, 2015
1 parent 99b224a commit 599aa90
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
7 changes: 2 additions & 5 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ ecos = library_dependency("ecos", aliases=["libecos"])
provides( Homebrew.HB, "ecos", ecos, os = :Darwin )
end

# This is the git commit that includes our merged patches as of 08/05/2014
# This is safer than unpacking from master which may cause ECOS.jl to
# not work properly
version = "e05a605588c38ad72e843f36af17f8f84e4e2ccb"
provides(Sources, URI("https://github.com/ifa-ethz/ecos/archive/$version.tar.gz"),
version = "2.0.2"
provides(Sources, URI("https://github.com/ifa-ethz/ecos/archive/v$version.tar.gz"),
[ecos], os = :Unix, unpacked_dir="ecos-$version")

prefix = joinpath(BinDeps.depsdir(ecos),"usr")
Expand Down
13 changes: 7 additions & 6 deletions src/ECOS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export setup, solve, cleanup
# q ncones-long vector of the length of the index sets of the SOCs
# e.g. cone 1 is indices 4:6, cone 2 is indices 7:10
# -> q = [3, 4]
# e Number of exponential cones present in problem
# Gpr, Gjc, Gir
# Non-zeros, column indices, and the row index arrays, respectively,
# for the matrix G represented in column compressed storage (CCS) format
Expand All @@ -74,7 +75,7 @@ export setup, solve, cleanup
# b RHS for equality constraints, length(b) == b (can be nothing)
# Returns a pointer to the ECOS pwork structure (Cpwork in ECOS.jl). See
# types.jl for more information.
function setup(n::Int, m::Int, p::Int, l::Int, ncones::Int, q::Union(Vector{Int},Nothing),
function setup(n::Int, m::Int, p::Int, l::Int, ncones::Int, q::Union(Vector{Int},Nothing), e::Int,
Gpr::Vector{Float64}, Gjc::Vector{Int}, Gir::Vector{Int},
Apr::Union(Vector{Float64},Nothing), Ajc::Union(Vector{Int},Nothing), Air::Union(Vector{Int},Nothing),
c::Vector{Float64}, h::Vector{Float64}, b::Union(Vector{Float64},Nothing); kwargs...)
Expand All @@ -85,11 +86,11 @@ function setup(n::Int, m::Int, p::Int, l::Int, ncones::Int, q::Union(Vector{Int}
Air = (Air == nothing) ? convert(Ptr{Cdouble}, C_NULL) : convert(Vector{Clong},Air)
b = (b == nothing) ? convert(Ptr{Cdouble}, C_NULL) : b
problem_ptr = ccall((:ECOS_setup, ECOS.ecos), Ptr{Cpwork},
(Clong, Clong, Clong, Clong, Clong, Ptr{Clong},
(Clong, Clong, Clong, Clong, Clong, Ptr{Clong}, Clong,
Ptr{Cdouble}, Ptr{Clong}, Ptr{Clong},
Ptr{Cdouble}, Ptr{Clong}, Ptr{Clong},
Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}),
n, m, p, l, ncones, q,
n, m, p, l, ncones, q, e,
Gpr, convert(Vector{Clong},Gjc), convert(Vector{Clong},Gir),
Apr, Ajc, Air,
c, h, b)
Expand Down Expand Up @@ -122,7 +123,7 @@ end
# A more tolerant version of the above method that doesn't require
# user to fiddle with internals of the sparse matrix format
# User can pass nothing as argument for A, b, and q
function setup(n, m, p, l, ncones, q, G, A, c, h, b; options...)
function setup(n, m, p, l, ncones, q, e, G, A, c, h, b; options...)
if A == nothing
if b != nothing
@assert length(b) == 0
Expand All @@ -147,7 +148,7 @@ function setup(n, m, p, l, ncones, q, G, A, c, h, b; options...)
Gjc = sparseG.colptr - 1 # C is 0-based
Gir = sparseG.rowval - 1

setup( n, m, p, l, ncones, q,
setup( n, m, p, l, ncones, q, e,
Gpr, Gjc, Gir,
Apr, Ajc, Air,
c, h, b; options...)
Expand All @@ -172,7 +173,7 @@ end
# Returns the version of ECOS in use
function ver()
ver_ptr = ccall((:ECOS_ver, ECOS.ecos), Ptr{Uint8}, ())
return bytestring(pointer_to_array(ver_ptr, 7))
return bytestring(ver_ptr)
end

end # module
2 changes: 1 addition & 1 deletion src/ECOSSolverInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ end
function optimize!(m::ECOSMathProgModel)
ecos_prob_ptr = setup(
m.nvar, m.nineq, m.neq,
m.npos, m.ncones, m.conedims,
m.npos, m.ncones, m.conedims, 0,
m.G, m.A,
m.c[:], # Seems to modify this
m.h, m.b; m.options...)
Expand Down
12 changes: 11 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ECOS_INACC_OFFSET = 10 # Offset exitflag at inaccurate results
const ECOS_MAXIT = -1 # Maximum number of iterations reached
const ECOS_NUMERICS = -2 # Search direction unreliable
const ECOS_OUTCONE = -3 # s or z got outside the cone, numerics?
const ECOS_SIGINT = -4 # solver interrupted by a signal/ctrl-c
const ECOS_FATAL = -7 # Unknown problem in solver


Expand Down Expand Up @@ -134,6 +135,9 @@ immutable Csettings
nitref::Clong
maxit::Clong
verbose::Clong
max_bk_iter::Clong
bk_scale::Cdouble
centrality::Cdouble
end

immutable Cpwork
Expand Down Expand Up @@ -199,6 +203,12 @@ immutable Cpwork
hresy::Cdouble
hresz::Cdouble

# norm iterates
nx::Cdouble
ny::Cdouble
nz::Cdouble
ns::Cdouble

# temporary storage
cx::Cdouble
by::Cdouble
Expand All @@ -213,4 +223,4 @@ immutable Cpwork

# settings struct
stgs::Ptr{Csettings}
end
end
2 changes: 1 addition & 1 deletion test/direct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ K0pr = [9.999999999999999500e-008, -6.748099080141577400e-001, 9.587587238674218

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, -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, -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, -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, -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, -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, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, -0.5]

mywork = ECOS.setup(n, m, p, l, ncones, q, Gpr, Gjc, Gir, Apr, Ajc, Air, c, h, b)
mywork = ECOS.setup(n, m, p, l, ncones, q, 0, Gpr, Gjc, Gir, Apr, Ajc, Air, c, h, b)

exitflag = ECOS.solve(mywork)

Expand Down
2 changes: 1 addition & 1 deletion test/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ K0pr = [9.999999999999999500e-008, -6.748099080141577400e-001, 9.587587238674218

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, -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, -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, -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, -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, -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, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, -0.5]

mywork = ECOS.setup(n, m, p, l, ncones, q, Gpr, Gjc, Gir, Apr, Ajc, Air, c, h, b; maxit=1)
mywork = ECOS.setup(n, m, p, l, ncones, q, 0, Gpr, Gjc, Gir, Apr, Ajc, Air, c, h, b; maxit=1)

exitflag = ECOS.solve(mywork)
@test exitflag == ECOS.ECOS_MAXIT
Expand Down

0 comments on commit 599aa90

Please sign in to comment.