Project

nlopt

0.0
The project is in a healthy, maintained state
Nonlinear optimization for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0
 Project Readme

NLopt Ruby

NLopt - nonlinear optimization - for Ruby

Build Status

Installation

First, install NLopt. For Homebrew, use:

brew install nlopt

And for Ubuntu, use:

sudo apt-get install libnlopt0

Then add this line to your application’s Gemfile:

gem "nlopt"

Getting Started

Create an optimization

opt = NLopt::Opt.new("LN_COBYLA", 2)

Set the objective function

f = lambda do |x, grad|
  x[0] + x[1]
end
opt.set_min_objective(f)

Set constraints

opt.set_lower_bounds([1, 2])
opt.set_upper_bounds([3, 4])

Perform the optimization

xopt = opt.optimize([2, 3])

API

This library follows the NLopt Python API. You can follow Python tutorials and convert the code to Ruby in many cases. Feel free to open an issue if you run into problems.

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/nlopt-ruby.git
cd nlopt-ruby
bundle install
bundle exec rake test