Project

osqp

0.01
A long-lived project that still receives updates
OSQP (Operator Splitting Quadratic Program) solver for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

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