ipopt-hs-0.4.0.1: haskell binding to ipopt and nlopt including automatic differentiation

Safe HaskellNone

Ipopt.Sparsity

Contents

Description

gradients and hessians tend to be sparse. This can be probed by calculating these with NaNs as inputs. http:www.gpops2.com/ uses this strategy, but perhaps there are relatively common cases (calls to blas/lapack for example) that do not propagate NaNs correctly: perhaps Ipopt.NLP provides some information about the structure of the problem, provided that all variables used are lexically scoped?

All functions provide indices that are affected (and should thus be included)

functions ending in 1 set one variable at a time to NaN, and additionally provide a hint as to which variable to change.

functions not ending in 1 set all input variables to NaN

it seems that adding a 1 achieves the same thing as doing one more derivative. In other words, nanPropagateG1 tells the same thing as nanPropagateH.

Synopsis

Documentation

>>> let g x = x!0 + x!1 * x!1 * x!2

nanPropagate1Source

Arguments

:: Int

size of input vector

-> (forall a. AnyRFCxt a => Vector a -> a) 
-> [Int]

inputs that don't become NaN

>>> nanPropagate1 4 g
[0,1,2]

variable 3 isn't even used.

nanPropagateGSource

Arguments

:: Int

size of input vector

-> (forall a. AnyRFCxt a => Vector a -> a) 
-> Vector Int 
>>> nanPropagateG 4 g
fromList [0,1,2]

jacobian

nanPropagateJ :: Int -> (forall a. AnyRFCxt a => Vector a -> Vector a) -> Vector (Int, Int)Source

hessian sparsity

nanPropagateHSource

Arguments

:: Int 
-> (forall a. AnyRFCxt a => Vector a -> a) 
-> Vector (Int, Int)

(i,j) indexes

>>> nanPropagateH 4 g
fromList [(1,1),(1,2),(2,1)]

nanPropagateG1Source

Arguments

:: Int

size of input vector

-> (forall a. AnyRFCxt a => Vector a -> a) 
-> [(Int, Vector Int)]

(i,js) shows that a NaN at index i produces NaNs in gradient indexes js... so the hessians only need to include i and js

a nonzero gradient when inputs are NaN ==> no need to include that row/column in the hessian, since it will be zero

>>> nanPropagateG1 4 g
[(1,fromList [1,2]),(2,fromList [1])]

nanPropagateHF :: Int -> (forall a. AnyRFCxt a => Vector a -> Vector a) -> Vector (Vector (Int, Int))Source

sparse derivatives (faked for now)

jacobianSS :: AnyRFCxt a => Vector (Int, Int) -> (forall a. AnyRFCxt a => Vector a -> Vector a) -> Vector a -> Vector aSource