Safe Haskell | None |
---|---|
Language | Haskell2010 |
- optimize :: forall f. Traversable f => Parameters -> Double -> f Double -> (forall s. Reifies s Tape => f (Reverse s Double) -> Reverse s Double) -> IO (f Double, Result, Statistics)
- data Simple :: *
- data Mutable :: *
- data Result :: *
- data Statistics :: * = Statistics {
- finalValue :: Double
- gradNorm :: Double
- totalIters :: CInt
- funcEvals :: CInt
- gradEvals :: CInt
- defaultParameters :: Parameters
- data Parameters :: * = Parameters {
- printFinal :: Bool
- printParams :: Bool
- verbose :: Verbose
- lineSearch :: LineSearch
- qdecay :: Double
- stopRules :: StopRules
- estimateError :: EstimateError
- quadraticStep :: Maybe Double
- debugTol :: Maybe Double
- initialStep :: Maybe Double
- maxItersFac :: Double
- nexpand :: CInt
- nsecant :: CInt
- restartFac :: Double
- funcEpsilon :: Double
- nanRho :: Double
- techParameters :: TechParameters
- data Verbose :: *
- = Quiet
- | Verbose
- | VeryVerbose
- data LineSearch :: *
- data StopRules :: *
- data EstimateError :: *
- data TechParameters :: * = TechParameters {}
Main function
:: forall f . Traversable f | |
=> Parameters | How should we optimize. |
-> Double |
|
-> f Double | Initial guess. |
-> (forall s. Reifies s Tape => f (Reverse s Double) -> Reverse s Double) | Function to be minimized. |
-> IO (f Double, Result, Statistics) |
Run the CG_DESCENT
optimizer and try to minimize the function.
It uses reverse mode automatic differentiation to compute the gradient.
Kinds of function types
data Simple :: *
Phantom type for simple pure functions.
data Mutable :: *
Phantom type for functions using mutable data.
Result and statistics
data Result :: *
ToleranceStatisfied | Convergence tolerance was satisfied. |
FunctionChange | Change in function value was less than |
MaxTotalIter | Total iterations exceeded |
NegativeSlope | Slope was always negative in line search. |
MaxSecantIter | Number of secant iterations exceed nsecant. |
NotDescent | Search direction not a descent direction. |
LineSearchFailsInitial | Line search fails in initial interval. |
LineSearchFailsBisection | Line search fails during bisection. |
LineSearchFailsUpdate | Line search fails during interval update. |
DebugTol | Debug tolerance was on and the test failed (see |
FunctionValueNaN | Function value became |
StartFunctionValueNaN | Initial function value was |
data Statistics :: *
Statistics given after the process finishes.
Statistics | |
|
Options
defaultParameters :: Parameters
Default parameters. See the documentation for Parameters
and TechParameters
to see what are the defaults.
data Parameters :: *
Parameters given to the optimizer.
Parameters | |
|
data Verbose :: *
How verbose we should be.
Quiet | Do not output anything to |
Verbose | Print what work is being done on each iteraction. |
VeryVerbose | Print information about every step, may be useful for troubleshooting. |
data LineSearch :: *
Line search methods that may be used.
ApproximateWolfe | Use approximate Wolfe line search. |
AutoSwitch Double | Use ordinary Wolfe line search, switch to approximate Wolfe when |f_{k+1} - f_k| < AWolfeFac * C_k where |
data StopRules :: *
Stop rules used to decided when to stop iterating.
DefaultStopRule Double |
|g_k|_infty <= max(grad_tol, |g_0|_infty * stop_fac) where |
AlternativeStopRule |
|g_k|_infty <= grad_tol * (1 + |f_k|) |
data EstimateError :: *
How to calculate the estimated error in the function value.
AbsoluteEpsilon Double |
|
RelativeEpsilon Double |
|
Technical parameters
data TechParameters :: *
Technical parameters which you probably should not touch.
You should read the papers of CG_DESCENT
to understand how
you can tune these parameters.
TechParameters | |
|