0.0
No release in over 3 years
Numo::Optimize provides functions for minimizing objective functions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

Numo::Optimize

Gem Version Build Status BSD 3-Clause License Documentation

Numo::Optimize (numo-optimize) provides functions for minimizing objective functions. This gem is based on Lbfgsb.rb and mopti by the same author.

Please note that numo-optimize depends on numo-narray-alt, not Numo::NArray.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add numo-optimize

If bundler is not being used to manage dependencies, install the gem by executing:

gem install numo-optimize

Usage

example.rb:

require 'numo/narray'
require 'numo/optimize'

# Define the objective function.
obj_func = proc do |x|
  (x - 3)**2 + 2
end

# Define the gradient (Jacobian) of the objective function.
gradient_func = proc do |x|
  2 * (x - 3)
end

# Initial guess
x_init = Numo::DFloat[0.0]

# Perform optimization
result = Numo::Optimize.minimize(x_init: x_init, fnc: obj_func, jcb: gradient_func)

# Output the result
puts "Optimized parameters: #{result[:x][0]}"
$ ruby example.rb
Optimized parameters: 3.0

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/numo-optimize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the BSD-3-Clause License. In addition, L-BFGS-B carries the following condition for use:

This software is freely available, but we expect that all publications describing work using this software , or all commercial products using it, quote at least one of the references given below. This software is released under the "New BSD License" (aka "Modified BSD License" or "3-clause license").

Code of Conduct

Everyone interacting in the Numo::Optimize project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.