Skip to content

OSQP (Operator Splitting Quadratic Program) solver for Ruby

License

Notifications You must be signed in to change notification settings

ankane/osqp-ruby

Repository files navigation

OSQP Ruby

The OSQP (Operator Splitting Quadratic Program) solver for Ruby

Check out Opt for a high-level interface

Build Status

Installation

Add this line to your application’s Gemfile:

gem "osqp"

Getting Started

Prep the problem - here’s how it should be setup

p = OSQP::Matrix.from_dense([[4, 1], [0, 2]])
q = [1, 1]
a = OSQP::Matrix.from_dense([[1, 1], [1, 0], [0, 1]])
l = [1, 0, 0]
u = [1, 0.7, 0.7]

And solve it

solver = OSQP::Solver.new
solver.solve(p, q, a, l, u, alpha: 1.0)

All of these settings are supported.

Warm start

solver.warm_start(x, y)

Data

Matrices can be a sparse matrix

a = OSQP::Matrix.new(3, 2)
a[0, 0] = 1
a[1, 0] = 2
# or
OSQP::Matrix.from_dense([[1, 0], [2, 0], [0, 0]])

Arrays can be Ruby arrays

[1, 2, 3]

Or Numo arrays

Numo::NArray.cast([1, 2, 3])

Resources

Credits

This library is modeled after the OSQP Python API.

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/osqp-ruby.git
cd osqp-ruby
bundle install
bundle exec rake vendor:all
bundle exec rake test

About

OSQP (Operator Splitting Quadratic Program) solver for Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages