@hackage / numeric-optimization-ad

Wrapper of numeric-optimization package for using with AD package

Latest0.1.0.1

About

Metadata

  • Last updated , by MasahiroSakai
  • License BSD-3-Clause
  • Categories Algorithms, Mathematics
  • Maintained by: masahiro.sakai@gmail.com

  • Lottery factor: 0

Links

Installation

Tested Compilers

  1. 9.4.5
  2. 9.2.7
  3. 9.0.2
  4. 8.10.7
  5. 8.8.4
  6. 8.6.5

Package Flags

Use the -f option with cabal commands to enable flags

    build-examples (off by default)

    Build example programs

Readme

numeric-optimization-ad

Hackage Hackage Deps License

Wrapper of numeric-optimization package for using with ad package

Example Usage

{-# LANGUAGE FlexibleContexts #-}
import Numeric.Optimization.AD

main :: IO ()
main = do
  result <- minimize LBFGS def rosenbrock Nothing [] [-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 :: Floating a => [a] -> a
-- rosenbrock :: Reifies s Tape => [Reverse s Double] -> Reverse s Double
rosenbrock [x,y] = sq (1 - x) + 100 * sq (y - sq x)

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