numeric-optimization: Unified interface to various numerical optimization algorithms

[ algorithms, bsd3, library, math, numeric, numerical, optimisation, optimization ] [ Propose Tags ]

Flags

Manual Flags

NameDescriptionDefault
build-examples

Build example programs

Disabled
with-cg-descent

Enable CGDescent optimization algorithm provided by nonlinear-optimization package and CG_DESCENT-C library. Since they are licensed under GPL, setting this flag True implies that resulting binary is also under GPL.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.1.0
Change log CHANGELOG.md
Dependencies base (>=4.12 && <5), constraints, data-default-class (>=0.1.2.0 && <0.2), hmatrix (>=0.20.0.0), lbfgs (>=0.1 && <0.2), numeric-optimization, primitive (>=0.6.4.0), vector (>=0.12.0.2 && <0.14) [details]
License BSD-3-Clause
Copyright Copyright (c) 2023 Masahiro Sakai
Author Masahiro Sakai
Maintainer masahiro.sakai@gmail.com
Category Math, Algorithms, Optimisation, Optimization
Home page https://github.com/msakai/nonlinear-optimization-ad#readme
Bug tracker https://github.com/msakai/nonlinear-optimization-ad/issues
Source repo head: git clone https://github.com/msakai/nonlinear-optimization-ad
Uploaded by MasahiroSakai at 2023-06-03T08:33:36Z
Distributions NixOS:0.1.1.0
Reverse Dependencies 2 direct, 0 indirect [details]
Executables rosenbrock
Downloads 122 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-06-03 [all 1 reports]

Readme for numeric-optimization-0.1.0.1

[back to package description]

numeric-optimization

Hackage Hackage Deps License

Unified interface to various numerical optimization algorithms.

Note that the package name is numeric-optimization and not numerical-optimization. The name numeric-optimization comes from the module name Numeric.Optimization.

Example Usage

{-# LANGUAGE OverloadedLists #-}
import Data.Vector.Storable (Vector)
import Numeric.Optimization

main :: IO ()
main = do
  result <- minimize LBFGS def (WithGrad rosenbrock rosenbrock') [-3,-4]
  print (resultSuccess result)  -- True
  print (resultSolution result)  -- [0.999999999009131,0.9999999981094296]
  print (resultValue result)  -- 1.8129771632403013e-18

-- https://en.wikipedia.org/wiki/Rosenbrock_function
rosenbrock :: Vector Double -> Double
rosenbrock [x,y] = sq (1 - x) + 100 * sq (y - sq x)

rosenbrock' :: Vector Double -> Vector Double
rosenbrock' [x,y] =
  [ 2 * (1 - x) * (-1) + 100 * 2 * (y - sq x) * (-2) * x
  , 100 * 2 * (y - sq x)
  ]

sq :: Floating a => a -> a
sq x = x ** 2

Supported Algorithms

Algorithm Solver implemention Haskell binding
CG_DESCENT CG_DESCENT-C nonlinear-optimization Requires with-cg-descent flag
Limited memory BFGS (L-BFGS) liblbfgs lbfgs
Newton's method Pure Haskell implementation using HMatrix -

LICENSE

The code in thie packaged is licensed under BSD-3-Clause.

If you enable with-cg-descent flag, it uses GPL-licensed packages and the resulting binary should be distributed under GPL.