spsa- Simultaneous Perturbation Stochastic Approximation Optimization Algorithm

Safe HaskellNone




defaultSPSA :: SPSASource

Make a default SPSA instance

checkSPSA :: Vector Double -> StateSPSA ()Source

Check to make sure all required fields are filled

getLoss :: StateSPSA LossFnSource

Get the loss function out of StateSPSA

getConstraint :: StateSPSA ConstraintFnSource

Get the constraint function out of StateSPSA

getStop :: StateSPSA [StoppingCriteria]Source

Get the stopping functions out of StateSPSA

peelAll :: StateSPSA (Double, Double, Vector Double)Source

Peel the next value from the two gain sequences and the perturbation vectors

getIterations :: StateSPSA IntSource

Get the iteration count

setLoss :: LossFn -> StateSPSA ()Source

Set the loss function

setConstraint :: ConstraintFn -> StateSPSA ()Source

Set the constraint function

pushStopCrit :: StoppingCriteria -> StateSPSA ()Source

Push a stopping criteria onto SPSA

setGainA :: [Double] -> StateSPSA ()Source

Set the gainA sequence

setGainC :: [Double] -> StateSPSA ()Source

Set the gainC sequence

setPerturbation :: [Vector Double] -> StateSPSA ()Source

Set the perturbation sequence

incrementIteration :: StateSPSA IntSource

Increment the iteration count

data StoppingCriteria Source

A stopping criteria is a function of current iteration number, last iteration theta, and current theta


Iterations Int 
NormDiff Double 


shouldStop :: StoppingCriteria -> Int -> Vector Double -> Vector Double -> BoolSource

Check to see if we should stop based on the critieria, iteration count, last and current iteration

type LossFn = Vector Double -> DoubleSource

Loss Function

type ConstraintFn = Vector Double -> Vector DoubleSource

Constraint Function

runSPSA :: StateSPSA a -> Vector Double -> Vector DoubleSource

Exported runSPSA function to extract the SPSA type

standardGainAk :: Double -> Int -> Double -> [Double]Source

Standard gain sequence for a_k = a / (k + 1 + A) ^ alpha | a is the most important and variable tuning parameter. Start with it set to get desired change in first iteration. | A is usually set to 10% of expected iterations | alpha is usually set to 0.602, but is valid up to 1.0 (the optimal for infinite iterations)

standardGainCk :: Double -> Double -> [Double]Source

Standard gain sequence for c_k

semiautomaticTuning :: Int -> Double -> Double -> StateSPSA ()Source

Set semiautomatic tuning for the gain sequences | c should be about the standard deviation of a measurement | a is set how much you want the first iteration to move | A is set to be 10% of expected iterations | alpha and gamma are set to the lowest values for best finite iteration performance (not infinitely optimal)

bernoulli :: Int -> Int -> [Vector Double]Source

Create a bernoulli +1 / -1 distributed infinite series of perturbation vectors based on seed and dimension