#NEWLINE# def findAllMinima( self ) : #NEWLINE# #INDENT# self . minimaTol = 0.001 #NEWLINE# self . bestIndex = nm . argmin ( self . allCosts ) #NEWLINE# self . bestParams = self . allParams [ self . bestIndex ] #NEWLINE# self . bestCost = self . allCosts [ self . bestIndex ] #NEWLINE# self . allMinima = [ ] #NEWLINE# self . allMinCosts = [ ] #NEWLINE# self . allMinReps = [ ] #NEWLINE# self . bestMinima = None #NEWLINE# self . bestJacobian = None #NEWLINE# self . bestMinCost = float ( 'inf' ) #NEWLINE# self . learnerMatDict #NEWLINE# for p in reversed ( self . allParams ) : #NEWLINE# #INDENT# res = so . minimize ( self . predictJustCost , p , bounds = self . optBounds ) #NEWLINE# currMinima = res . x #NEWLINE# currMinCost = res . fun #NEWLINE# distArray = nm . array ( [ nl . norm ( ( currMinima - t ) ) for t in self . allMinima ] ) #NEWLINE# boolArray = ( distArray < self . minimaTol ) #NEWLINE# if nm . any ( boolArray ) : #NEWLINE# #INDENT# minInd = int ( nm . flatnonzero ( boolArray ) [ 0 ] ) #NEWLINE# if ( currMinCost < self . allMinCosts [ minInd ] ) : #NEWLINE# #INDENT# self . allMinima [ minInd ] = currMinima #NEWLINE# self . allMinCosts [ minInd ] = currMinCost #NEWLINE# self . allMinReps [ minInd ] += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . allMinima . append ( currMinima ) #NEWLINE# self . allMinCosts . append ( currMinCost ) #NEWLINE# self . allMinReps . append ( 1 ) #NEWLINE# #UNINDENT# if ( currMinCost < self . bestMinCost ) : #NEWLINE# #INDENT# self . bestMinima = currMinima #NEWLINE# self . bestMinCost = currMinCost #NEWLINE# self . bestJacobian = res . jac #NEWLINE# #UNINDENT# #UNINDENT# self . numMinima = len ( self . allMinCosts ) #NEWLINE# self . realBest = self . realParamsFunc ( self . bestParams ) #NEWLINE# self . allRealMinima = [ self . realParamsFunc ( _ ) for t in self . allMinima ] #NEWLINE# self . bestRealMinima = self . realParamsFunc ( self . bestMinima ) #NEWLINE# self . realJacobian = ( self . bestJacobian * nm . array ( [ [ self . realDerivFunc ( ind ) for ind in range ( self . numParams ) ] for _ in range ( self . numParams ) ] ) )