The OSQP (Operator Splitting Quadratic Program) solver for Ruby
Check out Opt for a high-level interface
Add this line to your application’s Gemfile:
gem "osqp"
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)
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])
This library is modeled after the OSQP Python API.
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
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