Skip to content

Latest commit

 

History

History
248 lines (207 loc) · 13.2 KB

File metadata and controls

248 lines (207 loc) · 13.2 KB




class Engine( object )[source]

Engine defines common properties of all Engines.

An Engine moves around a walker in a random way such that its likelood remain above the low-likelihood-limit.

Attributes

  • walkers : WalkerList
         list of walkers to be diffused
  • errdis : ErrorDistribution
         error distribution to be used
  • slow : int
         If slow > 0, run this engine every slow-th iteration.
  • phantoms : PhantomCollection
         Collection of valid walker positions collected during engine execution
  • maxtrials : int
         maximum number of trials for various operations
  • rng : numpy.random.RandomState
         random number generator
  • verbose : int
         if verbose > 4 report about the engines. (mostly for debugging)
  • report : list of int (read only)
         reports number of succes, accepted, rejected, failed calls. Plus the total.
  • unitRange : array_like (read only)
         present max size of the parameter cloud (in unitspace: [0,1])
  • unitMin : array_like (read only)
         present minimum values of the parameter cloud (in unitspace: [0,1])

Author Do Kester.

Engine( walkers, errdis, slow=None, nstep=None, phancol=None, copy=None, seed=4213, verbose=0 ) [source]

Constructor.

Only one PhantomCollection should be present for all Engines.

Parameters

  • walkers : list of Walker
         walkers to be diffused
  • errdis : ErrorDistribution
         error distribution to be used
  • slow : None or int > 0
         Run this engine every slow-th iteration. None for all.
  • phantoms : None or PhantomCollection
         Container for all valid walkers, that have been tried. But were not kept.
         To calculate the spread of the parameters vs likelihood.
  • nstep : None or int
         None automatically determine the number of steps
         int use this number of steps
  • seed : int
         for random number generator
  • verbose : int
         report about the engines when verbose > 4
  • copy : Engine
         engine to be copied

copy( ) [source]

Return a copy of this engine.

setWalker( kw, problem, allpars, logL, walker=None, fitIndex=None ) [source]
Update the walker with problem, allpars, LogL and logW.

Parameters

  • kw : int
         index in walkerlist, of the walker to be replaced
  • problem : Problem
         the problem in the walker
  • allpars : array_like
         list of all parameters
  • logL : float
         log Likelihood
  • walker : Walker or None
         Copy this walker or create new one
  • fitIndex : array_like
         (new) fitIndex

domain2Unit( problem, dval, kpar=None ) [source]
Return value in [0,1] for the selected parameter.

Parameters

  • problem : Problem
         the problem involved
  • dval : float
         domain value for the selected parameter
  • kpar : None or array_like
         selected parameter index, where kp is index in [parameters, hyperparams]
         None means all

unit2Domain( problem, uval, kpar=None ) [source]
Return domain value for the selected parameter.

Parameters

  • problem : Problem
         the problem involved
  • uval : array_like
         unit value for the selected parameter
  • kpar : None or array_like
         selected parameter indices, where kp is index in [parameters, hyperparams]
         None means all.

startJourney( unitStart ) [source]
Calculate the starting position and reset

Parameters

  • unitStart : array_like
         start position in npars-dimensions in unit space

calcJourney( unitDistance ) [source]
Calculate the distance travelled since reset

Parameters

  • unitDistance : array_like
         step size in npars-dimensions in unit space

reportJourney( ) [source]

makeIndex( np, val ) [source]

reportCall( ) [source]

Store a call to engine

reportSuccess( ) [source]
Add 1 to the number of succesfull steps: logL < lowLhood.

reportReject( ) [source]
Add 1 to the number of rejected steps: logL > lowLhood.

reportFailed( ) [source]
Add 1 to the number of failed steps: could not construct a step.

reportBest( ) [source]
Add 1 to the number of best likelihoods found upto now.

printReport( best=False ) [source]

successRate( ) [source]
Return percentage of success.

getUnitMinmax( problem, lowLhood, nap ) [source]
Calculate unit minimum and maximum from the Phantoms

Parameters

  • problem : Problem
         To extract the unit range for
  • lowLhood : float
         low likelihood boundary

getUnitRange( problem, lowLhood, nap ) [source]
Calculate unit range and minimum from PhantomCollection

Parameters

  • problem : Problem
         To extract the unit range for
  • lowLhood : float
         low likelihood boundary

execute( kw, lowLhood ) [source]
Execute the engine for difusing the parameters

Parameters

  • kw : walker-id
         walker to diffuse
  • lowLhood : float
         low limit on the loglikelihood

Returns

  • int : number of succesfull moves

printIter( iteration=0, repiter=1000 ) [source]
Return True when to print this iteration

Parameters

  • iteration : int
         iteration number
  • repiter : int
         if verbose == 4 print every repiter