Giter VIP home page Giter VIP logo

sdpa.jl's Introduction

SDPA.jl

Build Status codecov

SDPA.jl is a wrapper for the SDPA semidefinite programming solver in double precision floating point arithmetic.

Affiliation

This wrapper is maintained by the JuMP community and is not a product of the SDPA developers.

License

SDPA.jl is licensed under the MIT License.

The underlying solver, SDPA is licensed under the GPL v2 license.

Installation

Install SDPA using Pkg.add:

import Pkg
Pkg.add("SDPA")

In addition to installing the SDPA.jl package, this will also download and install the SDPA binaries. (You do not need to install SDPA separately.)

If you see an error similar to:

INFO: Precompiling module GZip.
ERROR: LoadError: LoadError: error compiling anonymous: could not load library "libz"

please see GZip.jl#54 or Flux.jl#343. In particular, in Ubuntu this issue may be resolved by running

sudo apt-get install zlib1g-dev

See SDPAFamily for the other solvers, SDPA-GMP, SDPA-DD, and SDPA-QD of the family.

Use with JuMP

using JuMP, SDPA
model = Model(SDPA.Optimizer)
set_attribute(model, "Mode", SDPA.PARAMETER_DEFAULT)

MathOptInterface API

The SDPA optimizer supports the following constraints and attributes.

List of supported objective functions:

List of supported variable types:

List of supported constraint types:

List of supported model attributes:

Options

SDPA has three modes that give default value to all ten parameters.

The following table gives the default values for each parameter and mode.

Parameter PARAMETER_DEFAULT PARAMETER_UNSTABLE_BUT_FAST PARAMETER_STABLE_BUT_SLOW
MaxIteration 100 100 1000
EpsilonStar 1.0e-7 1.0e-7 1.0e-7
LambdaStar 1.0e+2 1.0e+2 1.0e+4
OmegaStar 2.0 2.0 2.0
LowerBound 1.0e+5 1.0e+5 1.0e+5
UpperBound 1.0e+5 1.0e+5 1.0e+5
BetaStar 0.1 0.01 0.1
BetaBar 0.2 0.02 0.3
GammaStar 0.9 0.95 0.8
EpsilonDash 1.0e-7 1.0e-7 1.0e-7

By default, we put SDPA in the SDPA.PARAMETER_DEFAULT mode.

Change the mode using the "Mode" option:

using JuMP, SDPA
model = Model(SDPA.Optimizer)
set_attribute(model, "Mode", SDPA.PARAMETER_STABLE_BUT_SLOW)

Note that the parameters are set in the order they are given, so you can set a mode and then modify parameters from this mode.

using JuMP, SDPA
model = Model(SDPA.Optimizer)
set_attribute(model, "Mode", SDPA.PARAMETER_STABLE_BUT_SLOW)
set_attribute(model, "MaxIteration", 100)

The choice of parameter mode has a large impact on the performance and stability of SDPA, and not necessarily in the way implied by the names of the modes; for example, PARAMETER_UNSTABLE_BUT_FAST can be more stable than the other modes for some problems. You should try each mode to see how it performs on your specific problem. See SDPA.jl#17 for more details.

sdpa.jl's People

Contributors

blegat avatar ericphanson avatar juan-pablo-vielma avatar juliatagbot avatar mlubin avatar odow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sdpa.jl's Issues

Can't pass mode attribute

julia> opt = SDPA.Optimizer()
SDPA.Optimizer

julia> MOI.set(opt, MOI.RawOptimizerAttribute("Mode"), PARAMETER_DEFAULT)
ERROR: MathOptInterface.UnsupportedAttribute{MathOptInterface.RawOptimizerAttribute}: Attribute MathOptInterface.RawOptimizerAttribute("Mode") is not supported by the model.
Stacktrace:
 [1] set(optimizer::SDPA.Optimizer, param::MathOptInterface.RawOptimizerAttribute, value::SDPA.ParameterType)
   @ SDPA ~/.julia/packages/SDPA/kOkci/src/MOI_wrapper.jl:47
 [2] top-level scope
   @ REPL[10]:1

I think this is because they keys here are symbols:

const SET_PARAM = Dict(:Mode => setParameterType,

and are checked here:

function MOI.supports(optimizer::Optimizer, param::MOI.RawOptimizerAttribute)
return param.name in keys(SET_PARAM)
end

but MOI.RawOptimizerAttribute's have to be strings.

Rebuild JLL for Julia 1.10

This package currently fails to load on Julia 1.10:

Failed to precompile SDPA [b9a10b5b-afa4-512f-a053-bb3d8080febc] to "/home/pkgeval/.julia/compiled/v1.10/SDPA/jl_GDpYuF".
julia: /opt/x86_64-linux-gnu/x86_64-linux-gnu/sys-root/usr/local/include/jlcxx/module.hpp:1251: void jlcxx::Module::add_bits(const string&, JLSuperT*) [with T = SDPA::ConeType; JLSuperT = _jl_value_t; std::__cxx11::string = std::__cxx11::basic_string<char>]: Assertion `(((jl_value_t*)(((jl_taggedvalue_t*)((char*)(super) - sizeof(jl_taggedvalue_t)))->header & ~(uintptr_t)15))==(jl_value_t*)(jl_datatype_type))' failed.

[9] signal (6.-6): Aborted
in expression starting at /home/pkgeval/.julia/packages/SDPA/ROHtf/src/SDPA.jl:13
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f724051740e)
__assert_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_ZN5jlcxx6Module8add_bitsIN4SDPA8ConeTypeE11_jl_value_tEEvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPT0_ at /home/pkgeval/.julia/artifacts/789898d25da6a16dca4a11dfb4bda8ffab5aabc5/lib/libsdpawrap.so (unknown line)
define_julia_module at /home/pkgeval/.julia/artifacts/789898d25da6a16dca4a11dfb4bda8ffab5aabc5/lib/libsdpawrap.so (unknown line)
register_julia_module at /home/pkgeval/.julia/artifacts/0b9e71d0529d5f5890463d4f9efb7171c279cfd0/lib/libcxxwrap_julia.so (unknown line)

Apparently rebuilding the JLL against the latest libcxxwrap should fix this: JuliaInterop/CxxWrap.jl#362 (comment)

MOI wrapper doesn't implement full SemidefiniteOptInterface interface?

Context: @JiazhengZhu and I are trying to translate (automatically) some problems from a Julia formulation to SDPA-format file in an effort to debug #17. It seems like some of the problem is a choice of parameters (and a SOC problem that snuck in), but I want to check that directly going to the binary (well, Convex -> MOI -> SDPA-formatted file -> binary) gives the same answers as Convex -> MBP -> SDPA.jl (or now Convex -> MOI -> SDPA.jl via https://github.com/ericphanson/Convex.jl/tree/MathOptInterface), to see if the "bad" parameters giving very wrong results is due to something in SDPA.jl or in the binary itself (I'm thinking it's not a bug in Convex.jl because the other solvers are fine). Being able to write SDPA-formatted files will help us later too, because we want to wrap SDPA-GMP, so we can use that for tests there too.

The problem: Trying to use the MOI.write method provided by SemiOptInterface gives MethodError: no method matching getnumberofconstraints(::SDPA.SDOptimizer) and suggests only getnumberofconstraints(::SemidefiniteOptInterface.MockSDOptimizer). Looking through the code, I don't think SDPA provides a method for getnumberofconstraints, which I guess is the problem.

So I think one way for us to resolve this is to write the methods to fill our the SemidefiniteOptInterface interface (from its src/interface.jl). But looking at JuliaOpt/SemidefiniteOptInterface.jl#30, it sounds like maybe the plan is to move SDPA to not depend on SemidefiniteOptInterface anyway, and to move the SDPA-format stuff to MathOptFormat.jl. In that case, what can we do to help? I think we'll want to follow whatever's done for SDPA anyway in our wrapping of SDPA-GMP, so if we can push that forward first, it'll probably be easier for us anyway.

Problem building SDPA

Trying to install SDPA on Ubuntu 18.04.4 LTS with Julia 1.4.1

              _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.1 (2020-04-14)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(sdpa-test) pkg> st
Status `~/julia/sdpa-test/Project.toml`
  (empty environment)

(sdpa-test) pkg> add SDPA

(sdpa-test) pkg> build SDPA
   Building CxxWrap → `~/.julia/packages/CxxWrap/KcmSi/deps/build.log`
   Building SDPA ───→ `~/.julia/packages/SDPA/d3tZm/deps/build.log`
┌ Error: Error building `SDPA`: 
│ ERROR: LoadError: LibraryProduct(nothing, ["libsdpawrap"], :libsdpawrap, "Prefix(/home/tweisser/.julia/packages/SDPA/d3tZm/deps/usr)") is not satisfied, cannot generate deps.jl!
│ Stacktrace:
│  [1] error(::String) at ./error.jl:33
│  [2] write_deps_file(::String, ::Array{Product,1}; verbose::Bool, isolate::Bool) at /home/tweisser/.julia/packages/BinaryProvider/GeAtj/src/Products.jl:419
│  [3] top-level scope at /home/tweisser/.julia/packages/SDPA/d3tZm/deps/build.jl:61
│  [4] include(::String) at ./client.jl:439
│  [5] top-level scope at none:5
│ in expression starting at /home/tweisser/.julia/packages/SDPA/d3tZm/deps/build.jl:61
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892

So I installed SDPA via apt-get

> apt-get install sdpa
> which sdpa
/usr/bin/sdpa

and set the environmental variable

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.1 (2020-04-14)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(sdpa-test) pkg> st
Status `~/julia/sdpa-test/Project.toml`
  (empty environment)
(sdpa-test) pkg> add SDPA

julia> ENV["JULIA_SDPA_LIBRARY_PATH"] = "/usr/bin"
"/usr/bin"

(sdpa-test) pkg> build SDPA
   Building CxxWrap → `~/.julia/packages/CxxWrap/KcmSi/deps/build.log`
   Building SDPA ───→ `~/.julia/packages/SDPA/d3tZm/deps/build.log`
┌ Error: Error building `SDPA`: 
│ ERROR: LoadError: type ExecutableProduct has no field libnames
│ Stacktrace:
│  [1] getproperty(::ExecutableProduct, ::Symbol) at ./Base.jl:33
│  [2] (::var"#5#7")(::ExecutableProduct) at ./none:0
│  [3] iterate at ./generator.jl:47 [inlined]
│  [4] collect(::Base.Generator{Array{Product,1},var"#5#7"}) at ./array.jl:665
│  [5] top-level scope at /home/tweisser/.julia/packages/SDPA/d3tZm/deps/build.jl:26
│  [6] include(::String) at ./client.jl:439
│  [7] top-level scope at none:5
│ in expression starting at /home/tweisser/.julia/packages/SDPA/d3tZm/deps/build.jl:25
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892

Any ideas where the problem could be?
Thanks,
Tillmann

Build failing on macOS

I am unable to build SDPA with Julia 0.6 running on macOS Sierra

Here is the output from the build:

julia> Pkg.build("SDPA")
INFO: Building CxxWrap
INFO: Changing directory to /path/to/homedir/.julia/v0.6/CxxWrap/deps/builds/jlcxx
INFO: Building SDPA
INFO: Any[((System Paths, Dict{Any,Any}()), "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib")]
INFO: Using libBLAS at /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib : -L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A -lBLAS
INFO: Any[((System Paths, Dict{Any,Any}()), "/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib")]
INFO: Using libLAPACK at /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib : -L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A -lLAPACK
INFO: Attempting to create directory /path/to/homedir/.julia/v0.6/SDPA/deps/downloads
INFO: Directory /path/to/homedir/.julia/v0.6/SDPA/deps/downloads already exists
INFO: Downloading file http://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_7.3.8.tar.gz?r=&ts=1479039688&use_mirror=vorboss
INFO: Done downloading file http://downloads.sourceforge.net/project/sdpa/sdpa/sdpa_7.3.8.tar.gz?r=&ts=1479039688&use_mirror=vorboss
INFO: Attempting to create directory /path/to/homedir/.julia/v0.6/SDPA/deps/src
INFO: Directory /path/to/homedir/.julia/v0.6/SDPA/deps/src already exists
INFO: Attempting to create directory /path/to/homedir/.julia/v0.6/SDPA/deps
INFO: Directory /path/to/homedir/.julia/v0.6/SDPA/deps already exists
INFO: Path /path/to/homedir/.julia/v0.6/SDPA/deps/src/sdpa-7.3.8 already exists
INFO: Attempting to create directory /path/to/homedir/.julia/v0.6/SDPA/deps/usr
INFO: Directory /path/to/homedir/.julia/v0.6/SDPA/deps/usr already exists
INFO: Attempting to create directory /path/to/homedir/.julia/v0.6/SDPA/deps/usr/lib
INFO: Directory /path/to/homedir/.julia/v0.6/SDPA/deps/usr/lib already exists
INFO: Changing directory to /path/to/homedir/.julia/v0.6/SDPA/deps/src/sdpa-7.3.8
================================[ ERROR: SDPA ]=================================

LoadError: failed process: Process(`patch -p1`, ProcessExited(1)) [1]
while loading /path/to/homedir/.julia/v0.6/SDPA/deps/build.jl, in expression starting on line 13

================================================================================

version info

julia> versioninfo()
Julia Version 0.6.0
Commit 903644385b (2017-06-19 13:05 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

Any help would be greatly appreciated.

Convex.jl tests very slow with SDPA (also some failures)

I (and a summer student) are interested in getting SDPA-GMP working with Convex.jl, and I thought the place to start would be with SDPA. I tried running Convex.jl's tests with the solver set to SDPA under each of the three modes. Each test run had access to four processors on the same SLURM cluster (you can see the submit scripts and everything here: https://github.com/ericphanson/HP_SDPs_fawcett/tree/master/testing-SDPA). These are the results:

Mode Time to finish tests Tests failed (of 375) Log
PARAMETER_DEFAULT 8h 39 13 test1
PARAMETER_UNSTABLE_BUT_FAST 6h 25 2 test2
PARAMETER_STABLE_BUT_SLOW 5h 22 73 test3

I haven't had time to check each failure, but all the ones I scanned through were tolerance failures (the optimal values or values for the variables were not close enough to the true ones or to those obtained by solving the problem another way).

These results seemed pretty strange to me. PARAMETER_UNSTABLE_BUT_FAST had the fewest failures, but from the name I assumed it would have the most. And PARAMETER_STABLE_BUT_SLOW had the most failures and ran the fastest (and some of the failures looked quite bad: Evaluated: -265.0031579792031 ≈ 0 (atol=0.001)).

I'm worried about both the test failures and the run time (in comparison, ECOS and SCS pass the tests, and the complete test run finishes in ~4 minutes on travis: https://travis-ci.org/JuliaOpt/Convex.jl/builds/543652452). One thing I noticed is that SDPA seemed to be running single-threaded, no matter how I set the environmental variable OMP_NUM_THREADS that the SDPA manual suggested using. The manual also mentioned that linking against different BLAS versions could speed it up by a lot.

Do you know why I would be getting these failures and slow run times? Are there things I can do to try to improve it?

Installation failed on Julia-1.8.0-DEV

Hello! I tried to install SDPA.jl on this version of Julia:

julia> versioninfo()
Julia Version 1.8.0-DEV.438
Commit 88a6376e99 (2021-08-28 11:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

The installation failed, and output the following error:

1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
[ Info: Precompiling SDPA [b9a10b5b-afa4-512f-a053-bb3d8080febc]
C++ exception while wrapping module SDPA: invalid subtyping in definition of SDPAProblem with supertype Any
ERROR:
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x142a5d7 -- jl_wakeup_thread at /cygdrive/c/buildbot/worker/package_win64/build/src\partr.c:356
in expression starting at none:0
jl_wakeup_thread at /cygdrive/c/buildbot/worker/package_win64/build/src\partr.c:356
enq_work at .\task.jl:646
#schedule#585 at .\task.jl:693
schedule at .\task.jl:684 [inlined]
uv_writecb_task at .\stream.jl:1160
jfptr_uv_writecb_task_20464.clone_1 at C:\Users\guberger\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
jlcapi_uv_writecb_task_21280.clone_1 at C:\Users\guberger\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
uv_process_tty_write_req at /workspace/srcdir/libuv\src/win\tty.c:2214
uv_process_reqs at /workspace/srcdir/libuv\src/win\req-inl.h:158
uv_run at /workspace/srcdir/libuv\src/win\core.c:478
jl_process_events at /cygdrive/c/buildbot/worker/package_win64/build/src\jl_uv.c:214
jl_task_get_next at /cygdrive/c/buildbot/worker/package_win64/build/src\partr.c:523
poptask at .\task.jl:814
wait at .\task.jl:823
uv_write at .\stream.jl:1042
unsafe_write at .\stream.jl:1114
write at .\strings\io.jl:242 [inlined]
print at .\strings\io.jl:244 [inlined]
#with_output_color#872 at .\util.jl:106
with_output_color##kw at .\util.jl:73 [inlined]
#printstyled#873 at .\util.jl:125 [inlined]
printstyled##kw at .\util.jl:125
jfptr_printstyledYY.YY.kw_37295.clone_1 at C:\Users\guberger\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
display_error at .\client.jl:102
unknown function (ip: 000000003ab612aa)
display_error at .\client.jl:107
unknown function (ip: 000000003ab60576)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1771 [inlined]
jl_f__call_latest at /cygdrive/c/buildbot/worker/package_win64/build/src\builtins.c:757
#invokelatest#2 at .\essentials.jl:718 [inlined]
invokelatest at .\essentials.jl:716 [inlined]
_start at .\client.jl:497
jfptr__start_34280.clone_1 at C:\Users\guberger\AppData\Local\Programs\Julia-1.8.0-DEV\lib\julia\sys.dll (unknown line)
jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1771 [inlined]
true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:548
jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:690
mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:58
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.dll (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 3254531 (Pool: 3253334; Big: 1197); GC: 3

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.