<s> import SimPEG <EOL> from SimPEG import Utils , sp , np <EOL> from Optimization import Remember , IterationPrinters , StoppingCriteria <EOL> import Directives <EOL> class BaseInversion ( object ) : <EOL> """<STR_LIT>""" <EOL> __metaclass__ = Utils . SimPEGMetaClass <EOL> name = '<STR_LIT>' <EOL> debug = False <EOL> counter = None <EOL> @ property <EOL> def directiveList ( self ) : <EOL> if getattr ( self , '<STR_LIT>' , None ) is None : <EOL> self . _directiveList = Directives . DirectiveList ( inversion = self ) <EOL> return self . _directiveList <EOL> @ directiveList . setter <EOL> def directiveList ( self , value ) : <EOL> if type ( value ) is list : <EOL> value = Directives . DirectiveList ( * value ) <EOL> assert isinstance ( value , Directives . DirectiveList ) , '<STR_LIT>' <EOL> self . _directiveList = value <EOL> self . _directiveList . inversion = self <EOL> def __init__ ( self , invProb , directiveList = [ ] , ** kwargs ) : <EOL> self . directiveList = directiveList <EOL> Utils . setKwargs ( self , ** kwargs ) <EOL> self . invProb = invProb <EOL> self . opt = invProb . opt <EOL> self . opt . callback = self . _optCallback <EOL> self . stoppers = [ StoppingCriteria . iteration ] <EOL> if IterationPrinters . phi_d not in self . opt . printers : <EOL> self . opt . printers . insert ( <NUM_LIT:1> , IterationPrinters . beta ) <EOL> self . opt . printers . insert ( <NUM_LIT:2> , IterationPrinters . phi_d ) <EOL> self . opt . printers . insert ( <NUM_LIT:3> , IterationPrinters . phi_m ) <EOL> @ Utils . timeIt <EOL> def run ( self , m0 ) : <EOL> """<STR_LIT>""" <EOL> self . invProb . startup ( m0 ) <EOL> self . directiveList . call ( '<STR_LIT>' ) <EOL> self . m = self . opt . minimize ( self . invProb . evalFunction , self . invProb . curModel ) <EOL> self . directiveList . call ( '<STR_LIT>' ) <EOL> return self . m <EOL> def _optCallback ( self , xt ) : <EOL> self . directiveList . call ( '<STR_LIT>' ) </s>
