Skip to content

Latest commit

 

History

History

numeric-optimization-ad-delcont

numeric-optimization-ad-delcont

Hackage Hackage Deps License

Wrapper of numeric-optimization package for using with ad-delcont package

Example Usage

import Numeric.Optimization
import Numeric.Optimization.AD.DelCont

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

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