Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ankane/osqp-ruby
OSQP (Operator Splitting Quadratic Program) solver for Ruby
https://github.com/ankane/osqp-ruby
Last synced: 8 days ago
JSON representation
OSQP (Operator Splitting Quadratic Program) solver for Ruby
- Host: GitHub
- URL: https://github.com/ankane/osqp-ruby
- Owner: ankane
- License: apache-2.0
- Created: 2019-11-16T22:53:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-27T04:02:50.000Z (3 months ago)
- Last Synced: 2024-10-04T15:56:38.027Z (about 1 month ago)
- Language: Ruby
- Size: 218 KB
- Stars: 14
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# OSQP Ruby
The [OSQP](https://osqp.org/) (Operator Splitting Quadratic Program) solver for Ruby
Check out [Opt](https://github.com/ankane/opt) for a high-level interface
[![Build Status](https://github.com/ankane/osqp-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/osqp-ruby/actions)
## Installation
Add this line to your application’s Gemfile:
```ruby
gem "osqp"
```## Getting Started
Prep the problem - here’s how it should be [setup](https://osqp.org/docs/examples/setup-and-solve.html)
```ruby
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
```ruby
solver = OSQP::Solver.new
solver.solve(p, q, a, l, u, alpha: 1.0)
```All of [these settings](https://osqp.org/docs/interfaces/solver_settings.html#solver-settings) are supported.
Warm start
```ruby
solver.warm_start(x, y)
```## Data
Matrices can be a sparse matrix
```ruby
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
```ruby
[1, 2, 3]
```Or Numo arrays
```ruby
Numo::NArray.cast([1, 2, 3])
```## Resources
- [OSQP: An Operator Splitting Solver for Quadratic Programs](https://arxiv.org/pdf/1711.08013.pdf)
- [Benchmarks](https://github.com/oxfordcontrol/osqp_benchmarks)
- [Status values and errors](https://osqp.org/docs/interfaces/status_values.html)## Credits
This library is modeled after the OSQP [Python API](https://osqp.org/docs/interfaces/python.html).
## History
View the [changelog](https://github.com/ankane/osqp-ruby/blob/master/CHANGELOG.md)
## Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- [Report bugs](https://github.com/ankane/osqp-ruby/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/osqp-ruby/pulls)
- Write, clarify, or fix documentation
- Suggest or add new featuresTo get started with development:
```sh
git clone https://github.com/ankane/osqp-ruby.git
cd osqp-ruby
bundle install
bundle exec rake vendor:all
bundle exec rake test
```