From 599aa908d55f7a97715f64ecc649174b4d0f630d Mon Sep 17 00:00:00 2001 From: Miles Lubin Date: Tue, 25 Aug 2015 12:54:53 -0600 Subject: [PATCH] update to ECOS 2.0.2 --- deps/build.jl | 7 ++----- src/ECOS.jl | 13 +++++++------ src/ECOSSolverInterface.jl | 2 +- src/types.jl | 12 +++++++++++- test/direct.jl | 2 +- test/options.jl | 2 +- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/deps/build.jl b/deps/build.jl index b29dba1..635e6ab 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -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") diff --git a/src/ECOS.jl b/src/ECOS.jl index bd3b873..5fb2a51 100644 --- a/src/ECOS.jl +++ b/src/ECOS.jl @@ -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 @@ -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...) @@ -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) @@ -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 @@ -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...) @@ -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 diff --git a/src/ECOSSolverInterface.jl b/src/ECOSSolverInterface.jl index 40cd02a..a6b51ed 100644 --- a/src/ECOSSolverInterface.jl +++ b/src/ECOSSolverInterface.jl @@ -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...) diff --git a/src/types.jl b/src/types.jl index d41fa0c..24cc158 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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 @@ -134,6 +135,9 @@ immutable Csettings nitref::Clong maxit::Clong verbose::Clong + max_bk_iter::Clong + bk_scale::Cdouble + centrality::Cdouble end immutable Cpwork @@ -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 @@ -213,4 +223,4 @@ immutable Cpwork # settings struct stgs::Ptr{Csettings} -end \ No newline at end of file +end diff --git a/test/direct.jl b/test/direct.jl index a47ac63..fcd5280 100644 --- a/test/direct.jl +++ b/test/direct.jl @@ -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) diff --git a/test/options.jl b/test/options.jl index bc61825..323a625 100644 --- a/test/options.jl +++ b/test/options.jl @@ -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