Giter VIP home page Giter VIP logo

juliafirstorder / separableoptimization.jl Goto Github PK

View Code? Open in Web Editor NEW
23.0 3.0 4.0 225 KB

A Julia package that solves Linearly Constrained Separable Optimization Problems using ADMM.

Home Page: https://juliafirstorder.github.io/SeparableOptimization.jl/stable/

License: Apache License 2.0

Julia 100.00%
optimization julia julia-language separable-optimization admm admm-algorithm proximal-operators proximal-algorithms prox convex-optimization

separableoptimization.jl's Introduction

SeparableOptimization.jl

Build status codecov

SeparableOptimization.jl is a Julia package that solves Linearly Constrained Separable Optimization Problems.

The package currently supports quadratic-plus-separable problems of the form

 minimize    (1/2)x'Px + q'x + ∑ g_i(x_i)
    x
 subject to  Ax = b.

where:

  • A is a sparse m x n matrix.
  • b is an m-vector.
  • P is an n x n positive semidefinite matrix.
  • q is an n-vector.
  • x, the decision variable, is an n-vector.
  • g_i is a piecewise quadratic function, specified via PiecewiseQuadratics.jl.

The algorithm used is the alternating direction method of multipliers (ADMM). This method reaches moderate accuracy very quickly, but often requires some tuning, which may need to be done by hand. This package is therefore best used by someone looking to solve a family of similar optimization problems with excellent performance, even when the function g_i is very complicated.

Authors

This package and PiecewiseQuadratics.jl were originally developed by Nicholas Moehle, Ellis Brown, and Mykel Kochenderfer at BlackRock AI Labs. They were developed to produce the results in the following paper: arXiv:2103.05455.

Contents

Installation

Use Julia's builtin package manager Pkg to install. From a Julia REPL:

] add SeparableOptimization

Example

Let's use SeparableOptimization to solve an example problem.

using SeparableOptimization
using PiecewiseQuadratics
using LinearAlgebra

n = 4 # num features
m = 2 # num constraints

# construct problem data (ensuring the problem is feasible)
x0 = rand(n)
A = rand(m, n)
b = A * x0
X = rand(n,n)
P = X'X  # ensure P is positive definite
@assert isposdef(P)
q = rand(n)

# x1 has to be in union([-1, 2], [2.5, 3.5]) and has a quadratic penalty if
# it lies in [-1, 2] and a linear penalty if it lies in [2.5, 3.5]
g1 = PiecewiseQuadratic([BoundedQuadratic(-1, 2, 1, 0, 0),
                        BoundedQuadratic(2.5, 3.5, 0, 1, 0)])
# x2 has to be between -20 and 10
g2 = indicator(-20, 10)

# x3 has to be between -5 and 10
g3 = indicator(-5, 10)

# x4 has to be exactly 1.2318
g4 = indicator(1.2318, 1.2318);

g = [g1,g2,g3,g4]

# solve
params = AdmmParams(P, q, A, b, g)
settings = Settings(; ρ=ones(m), σ=ones(n), compute_stats=true)

vars, stats = optimize(params, settings)

print("optimal x: ", vars.x)
print("final obj: ", stats.obj[stats.iters])
print("final res: ", stats.res[stats.iters])

For more examples, see test/test_examples.jl.

Contribute

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate. See CONTRIBUTING.md for more detail.

separableoptimization.jl's People

Contributors

ellisbrown avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

separableoptimization.jl's Issues

Question on the implementation

Hi-
I noticed that the implementation of ADMM isn't exactly the same as what's in the paper. It seems you are using something along the lines of OSQP with a slight modification. Is there a reason you chose to do it this way (as opposed to making the objective fully linearly separable...) ? I tried implementing the procedure and have not been able to get it to work. I love the paper and believe it will be incredibly useful for my problem. Thank you in advance.

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.