https://github.com/yoshoku/numo-optimize
Numo::Optimize provides functions for minimizing objective functions.
https://github.com/yoshoku/numo-optimize
gem lbfgsb numo optimization ruby
Last synced: 2 days ago
JSON representation
Numo::Optimize provides functions for minimizing objective functions.
- Host: GitHub
- URL: https://github.com/yoshoku/numo-optimize
- Owner: yoshoku
- License: bsd-3-clause
- Created: 2025-09-30T05:17:54.000Z (9 days ago)
- Default Branch: main
- Last Pushed: 2025-10-03T05:39:03.000Z (6 days ago)
- Last Synced: 2025-10-04T19:53:54.317Z (5 days ago)
- Topics: gem, lbfgsb, numo, optimization, ruby
- Language: C
- Homepage:
- Size: 96.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Numo::Optimize
[](https://badge.fury.io/rb/numo-optimize)
[](https://github.com/yoshoku/numo-optimize/actions/workflows/main.yml)
[](https://github.com/yoshoku/numo-optimize/blob/main/LICENSE.txt)
[](https://gemdocs.org/gems/numo-optimize/)Numo::Optimize (numo-optimize) provides functions for minimizing objective functions.
This gem is based on [Lbfgsb.rb](https://github.com/yoshoku/lbfgsb.rb) and
[mopti](https://github.com/yoshoku/mopti) by the same author.Please note that numo-optimize depends on [numo-narray-alt](https://github.com/yoshoku/numo-narray-alt), not Numo::NArray.
## Installation
Install the gem and add to the application's Gemfile by executing:
```bash
bundle add numo-optimize
```If bundler is not being used to manage dependencies, install the gem by executing:
```bash
gem install numo-optimize
```## Usage
example.rb:
```ruby
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]}"
``````sh
$ 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](https://github.com/yoshoku/numo-optimize/blob/main/CODE_OF_CONDUCT.md).## License
The gem is available as open source under the terms of the [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause).
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](https://github.com/yoshoku/numo-optimize/blob/main/CODE_OF_CONDUCT.md).