Git Product home page Git Product logo

juliafirstorder / piecewisequadratics.jl Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 1.0 273 KB

A Julia package for manipulation of univariate piecewise quadratic functions.

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

License: Apache License 2.0

Julia 100.00%
piecewise quadratic optimization julia julia-language prox proximal-operators convex convex-hull convex-optimization

piecewisequadratics.jl's Introduction

PiecewiseQuadratics.jl

CI codecov

PiecewiseQuadratics.jl is a Julia package for manipulation of univariate piecewise quadratic functions of the form

f(x) = p x² + q x + r, ∀ x ∈ [lb, ub]

where:

  • p, q, r are scalar
  • x is the decision variable
  • lb is the lower bound of x
  • ub is the upper bound of x

There is a particular focus on convex analysis and optimization. The following operations are supported:

  • Addition
  • Convex envelope
  • Proximal operator
  • Minimization
  • Others, such as scalar multiplication, shifting, perspective transformation.

Authors

This package and SeparableOptimization.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 PiecewiseQuadratics

Example

Bounded Quadratics

We specify a bounded quadratic g(x) = x² + 2x + 4, ∀x ∈ [0,5] by

# (lb, ub, p, q, r)
g = BoundedQuadratic(0, 5, 1, 2, 4)

Piecewise Quadratics

We specify a piecewise quadratic function by providing a list of bounded quadratics in order. Where the pieces overlap, we take the function value to be the minimum over all possible values.

We specify

as follows:

f = PiecewiseQuadratic([
  BoundedQuadratic(-Inf, 3.0, 1.0, -3.0, 3.0),
  BoundedQuadratic(3.0, 4.0, 0.0, -1.0, 3.0),
  BoundedQuadratic(4.0, 6.0, 2.0, -20.0, 47.0),
  BoundedQuadratic(6.0, 7.5, 0.0, 1.0, -7.0),
  BoundedQuadratic(7.5, Inf, 0.0, 4.0, -29.0)
])

Plot

Below is a plot of the above piece-wise quadratic and its convex envelope, and the code to generate it.

using Plots
plot(get_plot(f); grid=false, linestyle=:dash, color=:black, label="piece-wise quadratic")
plot!(get_plot(simplify(envelope(f))); color=:blue, la=0.5, label="envelope")

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.

piecewisequadratics.jl's People

Contributors

ellisbrown avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

moehle

piecewisequadratics.jl's Issues

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.