packages feed

nonlinear-optimization-ad 0.2.3 → 0.2.4

raw patch · 4 files changed

+49/−96 lines, 4 filesdep +bytestringdep +cassavadep −csvdep ~addep ~vectorPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring, cassava

Dependencies removed: csv

Dependency ranges changed: ad, vector

API changes (from Hackage documentation)

Files

− .travis.yml
@@ -1,82 +0,0 @@-language: c-sudo: false--cache:-  directories:-    - $HOME/.cabsnap-    - $HOME/.cabal/packages--before_cache:-  - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log-  - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar--matrix:-  include:-    - env: CABALVER=1.18 GHCVER=7.6.3-      compiler: ": #GHC 7.6.3"-      addons: {apt: {packages: [cabal-install-1.18,ghc-7.6.3], sources: [hvr-ghc]}}-    - env: CABALVER=1.18 GHCVER=7.8.3 COVERAGE=1-      compiler: ": #GHC 7.8.3"-      addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.3], sources: [hvr-ghc]}}-    - env: CABALVER=1.22 GHCVER=7.10.3-      compiler: ": #GHC 7.10.3"-      addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=8.0.1-      compiler: ": #GHC 8.0.1"-      addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}--before_install:- - unset CC- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:~/.cabal/bin:$PATH--install:- - cabal --version- - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"- - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];-   then-     zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >-          $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;-   fi- - travis_retry cabal update -v- - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config- - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt- - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt--# check whether current requested install-plan matches cached package-db snapshot- - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;-   then-     echo "cabal build-cache HIT";-     rm -rfv .ghc;-     cp -a $HOME/.cabsnap/ghc $HOME/.ghc;-     cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;-   else-     echo "cabal build-cache MISS";-     rm -rf $HOME/.cabsnap;-     mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;-     cabal install --only-dependencies --enable-tests --enable-benchmarks;-   fi--# snapshot package-db on cache miss- - if [ ! -d $HOME/.cabsnap ];-   then-      echo "snapshotting package-db to build-cache";-      mkdir $HOME/.cabsnap;-      cp -a $HOME/.ghc $HOME/.cabsnap/ghc;-      cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;-   fi--# Here starts the actual work to be performed for the package under test;-# any command which exits with a non-zero exit code causes the build to fail.-script:- - if [ -f configure.ac ]; then autoreconf -i; fi- - cabal configure --enable-tests --enable-benchmarks -v2 $([ "$COVERAGE" = "1" ] && echo "--enable-library-coverage") # -v2 provides useful information for debugging- - cabal build   # this builds all libraries and executables (including tests/benchmarks)- - cabal test- - cabal check- - cabal sdist   # tests that a source-distribution can be generated--# Check that the resulting source distribution can be built & installed.-# If there are no other `.tar.gz` files in `dist`, this can be even simpler:-# `cabal install --force-reinstalls dist/*-*.tar.gz`- - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&-   (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
nonlinear-optimization-ad.cabal view
@@ -2,9 +2,15 @@ -- further documentation, see http://haskell.org/cabal/users-guide/  name:                nonlinear-optimization-ad-version:             0.2.3+version:             0.2.4 synopsis:            Wrapper of nonlinear-optimization package for using with AD package-description:         Wrapper of nonlinear-optimization package for using with AD package+description:         This package enhance+                     [nonlinear-optimization](https://hackage.haskell.org/package/nonlinear-optimization)'s+                     usability by using+                     [ad](https://hackage.haskell.org/package/ad)'s+                     automatic differentiaion. You only need to+                     specify a function to minimize and don't need to+                     specify its gradient explicitly. homepage:            https://github.com/msakai/nonlinear-optimization-ad bug-reports:         https://github.com/msakai/nonlinear-optimization-ad/issues license:             GPL-3@@ -18,10 +24,16 @@ extra-source-files:    README.md    CHANGELOG.markdown-   .travis.yml-   samples/LinearRegression.hs    samples/galton.csv +tested-with: GHC==8.8.2+tested-with: GHC==8.6.4+tested-with: GHC==8.4.4+tested-with: GHC==8.2.2+tested-with: GHC==8.0.2+tested-with: GHC==7.10.3+tested-with: GHC==7.8.4+ source-repository head   type:     git   location: git://github.com/msakai/nonlinear-optimization-ad.git@@ -57,8 +69,10 @@   HS-Source-Dirs: samples   Build-Depends:     base,-    csv,-    nonlinear-optimization-ad+    bytestring,+    cassava,+    nonlinear-optimization-ad,+    vector   Default-Language: Haskell2010   Other-extensions:     TypeFamilies
samples/LinearRegression.hs view
@@ -1,16 +1,19 @@-{-# LANGUAGE GADTs #-}+{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -Wall #-} module Main where  import qualified Numeric.Optimization.Algorithms.HagerZhang05.AD as CG import Text.Printf-import qualified Text.CSV as CSV+import qualified Data.ByteString.Lazy as BS+import qualified Data.Csv as Csv+import qualified Data.Vector as V  main :: IO () main = do-  Right csv <- CSV.parseCSVFromFile "samples/galton.csv"-  let samples :: [(Double, Double)]-      samples = [(read parent, read child) | [child,parent] <- tail csv]      +  s <- BS.readFile "samples/galton.csv"+  let Right rows = Csv.decode Csv.HasHeader s+      samples :: [(Double, Double)]+      samples = V.toList rows       -- hypothesis       h [theta0,theta1] x = theta0 + theta1 * x       -- cost function
src/Numeric/Optimization/Algorithms/HagerZhang05/AD.hs view
@@ -1,5 +1,23 @@ {-# LANGUAGE ScopedTypeVariables, Rank2Types, FlexibleContexts, CPP #-} {-# OPTIONS_GHC -Wall #-}+-- +-----------------------------------------------------------------------------+-- |+-- Module      :  Numeric.Optimization.Algorithms.HagerZhang05.AD+-- Copyright   :  (c) Masahiro Sakai 2013+-- License     :  GPL+--+-- Maintainer  :  masahiro.sakai@gmail.com+-- Stability   :  experimental+-- Portability :  non-portable+--+-- This package enhance+-- [nonlinear-optimization](https://hackage.haskell.org/package/nonlinear-optimization)'s+-- usability by using+-- [ad](https://hackage.haskell.org/package/nonlinear-optimization)'s+-- automatic differentiaion.  You only need to specify a function to+-- minimize and don't need to specify its gradient explicitly.+----------------------------------------------------------------------------- module Numeric.Optimization.Algorithms.HagerZhang05.AD   ( -- * Main function     optimize@@ -68,7 +86,7 @@       readFromVec :: S.Vector Double -> f Double       readFromVec x = fmap (x S.!) template -      mf :: forall m. (PrimMonad m, Functor m) => PointMVector m -> m Double+      mf :: forall m. PrimMonad m => PointMVector m -> m Double       mf mx = do         x <- readFromMVec mx #if MIN_VERSION_ad(4,0,0)@@ -77,12 +95,12 @@         return $ lowerFU f x #endif -      mg :: forall m. (PrimMonad m, Functor m) => PointMVector m -> GradientMVector m -> m ()+      mg :: forall m. PrimMonad m => PointMVector m -> GradientMVector m -> m ()       mg mx mret = do         x <- readFromMVec mx         writeToMVec (grad f x) mret -      mc :: (forall m. (PrimMonad m, Functor m) => PointMVector m -> GradientMVector m -> m Double)+      mc :: (forall m. PrimMonad m => PointMVector m -> GradientMVector m -> m Double)       mc mx mret = do         x <- readFromMVec mx         let (y,g) = grad' f x