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 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 {}
- class (Num t, Num (Scalar t)) => Mode t where
Main function
:: 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.
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 | |
|
Re-export
class (Num t, Num (Scalar t)) => Mode t where
type Scalar t :: *
Mode Double | |
Mode Float | |
Mode Int | |
Mode Int8 | |
Mode Int16 | |
Mode Int32 | |
Mode Int64 | |
Mode Integer | |
Mode Word | |
Mode Word8 | |
Mode Word16 | |
Mode Word32 | |
Mode Word64 | |
Mode Natural | |
Integral a => Mode (Ratio a) | |
Num a => Mode (Forward a) | |
Num a => Mode (Kahn a) | |
(Mode t, Mode (Scalar t)) => Mode (On t) | |
Num a => Mode (Sparse a) | |
Num a => Mode (Tower a) | |
Num a => Mode (Id a) | |
RealFloat a => Mode (Complex a) | |
(Reifies * s Tape, Num a) => Mode (Reverse s a) | |
Mode a => Mode (AD s a) | |
(Mode a, Mode b, Chosen s, (~) * (Scalar a) (Scalar b)) => Mode (Or s a b) |