ALB::ALB Class Reference

List of all members.

Public Member Functions

def debug
def __init__
def doSave
def save
def load
def loading
def cycle
def adjMinMax_xxx_0928_xxxdef
def restart
def saveMultiperfect
def SearchBasedOnPower
def SearchBasedOnPowerAndDate
def SearchBasedOnLowCountAndFactorReduction
def SearchBasedOnLowCount
def SearchBasedOnFactorReduction
def search

Public Attributes

 first_cycle


Detailed Description

Definition at line 31 of file ALB.py.


Member Function Documentation

def ALB::ALB::__init__ (   self,
  filename = None 
)

Definition at line 39 of file ALB.py.

00039                                          :
00040         self.first_cycle = True
00041         self._mp_cnt = 0
00042         self._saver = Saver.Saver( self )
00043         self._starter = TripleStart.TripleStart( )
00044 
00045         if filename != None:
00046             self.load( filename )
00047 
    def doSave( self, force = False ):

def ALB::ALB::adjMinMax_xxx_0928_xxxdef (   self,
  seed 
)

Multiply by all large primes to get ballpark exponents for 2, 3, 5,and 7

Definition at line 196 of file ALB.py.

00196                                                :
00197         """
00198         Multiply by all large primes to get ballpark exponents for 2, 3, 5,and 7
00199         """
00200 
00201         ndm = NumDenMul.new( seed )
00202 
00203         # reduce large ndm.num primes (to less than 10)
00204         factors = ndm.reduceLargeFactors( 10 )
00205 
00206         # search results for 'two' and determine
00207         # starter exponent ranges
00208 
00209         self._starter.adjMinMax( seed, factors )
00210 
00211         return
00212 
    def restart( self ):

def ALB::ALB::cycle (   self,
  max,
  seed 
)

Answer the instance variable factorList.

Definition at line 161 of file ALB.py.

00161                                 :
00162         """
00163         Answer the instance variable factorList.
00164         """
00165 
00166         ndm = NumDenMul.new( seed )
00167 
00168         self._seed = seed
00169         self._ndm  = ndm
00170 
00171         if globals.printState:
00172             print "ALB.cycle:  %s" % seed
00173 
00174         beg = time.time( )
00175 
00176         mpng = MPNG.MPNG( self )
00177         ( beg_cnt, net_cnt, ndm_dup, ndm_con ) = mpng.search( max, seed, ndm )
00178 
00179         fin = time.time( )
00180 
00181         if globals.qvs_flag > 1 or globals.printCycle or verbose - globals.quiet > 0:
00182             print "%5d %s %s %s" % ( beg_cnt, ndm.mul( ), ndm.num( ), ndm.den( ) )
00183         elif True:
00184             pass
00185         elif beg_cnt > 1000 or fin - beg > 10 or \
00186              ndm_dup > 100  or ndm_con > 100:
00187             print "bg:%5d, tm:%7.2f," % ( beg_cnt, fin - beg ),
00188             print "nd:%4d, nc:%4d," % ( ndm_dup, ndm_con ),
00189             print "m: %s" % ndm.mul( )
00190 
00191         if globals.qvs_flag and beg_cnt > 1000:
00192             print "cy: %5d,  mp: %2d,  st: %s" % ( beg_cnt, fnd_cnt, ndm.num( ) )
00193 
00194         return beg_cnt
00195 
    def adjMinMax_xxx_0928_xxxdef( self, seed ):

def ALB::ALB::debug (   self  ) 

Definition at line 33 of file ALB.py.

00033                      :
00034         # Force a call to the debugger in running code here
00035 #       pydb.debugger( )
00036         # ...
00037         pass
00038 
    def __init__( self, filename = None ):

def ALB::ALB::doSave (   self,
  force = False 
)

Definition at line 48 of file ALB.py.

00048                                      :
00049 
00050         self._saver.doSave( force )
00051 
    def save( self, filename = RSLTS_tmp ):

def ALB::ALB::load (   self,
  filename = RSLTS_txt 
)

Definition at line 81 of file ALB.py.

00081                                           :
00082 
00083         if globals.quiet == 0:
00084             beg_read = time.time( )
00085             print "Reading %s" % filename
00086 
00087         file = open( filename, "r" )
00088 
00089         sig = "tri"
00090 
00091         # process prefix
00092         while True:
00093             line = file.readline( )
00094 
00095             if line == None or line[0] == "*":
00096                 break
00097             if line == "":
00098                 continue
00099 
00100             parts = re.split( " +", line )
00101             if parts[ 0 ] == sig:
00102                 self._starter.load( line )
00103 
00104         print "%s" % self._starter
00105 
00106         # process factors, sgmftr, and rslts
00107         while True:
00108             if line == None:
00109                 line = file.readline( )
00110             if line == '':
00111                 break
00112             if line == "" or line[0] != "*":
00113                 line = None
00114                 continue
00115             line = line.strip( )
00116             if verbose:
00117                 print line
00118             parts = re.split( " +", line )
00119             line = None
00120             if len( parts ) != 3:
00121                 continue
00122 
00123             beg = time.time( )
00124 
00125             if parts[ 1 ] == "factors":
00126                 self.loading( parts[ 1 ] )
00127                 globals.FactorCache.load( file )
00128                 if verbose > 1:
00129                     print "%s" % fc
00130 
00131             if parts[ 1 ] == "sgmftr":
00132                 self.loading( parts[ 1 ] )
00133                 globals.SigmaFactorCache.load( file )
00134                 if verbose > 1:
00135                     print "%s" % sfc
00136 
00137             if parts[ 1 ] == "rslts":
00138                 self.loading( parts[ 1 ] )
00139                 globals.ResultCache.load( file )
00140                 if verbose > 1:
00141                     print "%s" % rc
00142 
00143             fin = time.time( )
00144             if verbose:
00145                 print "time: %4.2f" % ( fin - beg )
00146             sys.stdout.flush()
00147 
00148         file.close( )
00149 
00150         if globals.quiet == 0:
00151             fin_read = time.time( )
00152             print "  %4.2fs" % ( fin_read - beg_read )
00153             sys.stdout.flush()
00154             print
00155 
00156         return
00157 
    def loading( self, tag ):

def ALB::ALB::loading (   self,
  tag 
)

Definition at line 158 of file ALB.py.

00158                             :
00159         print "%s loading %s" % ( TimeStamp.TimeStamp( ), tag )
00160 
    def cycle( self, max, seed ):

def ALB::ALB::restart (   self  ) 

Definition at line 213 of file ALB.py.

00213                        :
00214         if self.first_cycle:
00215             self.first_cycle = False
00216             Factors.restart( )
00217 
    def saveMultiperfect( self, ndm ):

def ALB::ALB::save (   self,
  filename = RSLTS_tmp 
)

Definition at line 52 of file ALB.py.

00052                                           :
00053 
00054         if globals.save == False:
00055             return
00056 
00057         if filename == None:
00058             file = sys.stdout
00059         else:
00060             t = TimeStamp.TimeStamp( )
00061             print "%s " % t,
00062             file = open( filename, "w" )
00063             print "Writing %s" % filename
00064 
00065         file.write( "%s\n" % self._starter )
00066         file.write( "%s\n" % globals.ResultCache.counts( ) )
00067 
00068         fmt = "\n*** %s ***\n%s\n**************\n"
00069 
00070         file.write( fmt % ( "factors", globals.FactorCache ) )
00071         file.write( fmt % ( "sgmftr",  globals.SigmaFactorCache ) )
00072         file.write( fmt % ( "rslts",   globals.ResultCache ) )
00073 
00074         if file != sys.stdout:
00075             file.close( )
00076             print "... done"
00077             sys.stdout.flush()
00078 
00079         return
00080 
    def load( self, filename = RSLTS_txt ):

def ALB::ALB::saveMultiperfect (   self,
  ndm 
)

Save multiperfects.

Definition at line 218 of file ALB.py.

00218                                      :
00219         """
00220         Save multiperfects.
00221         """
00222 
00223         mag = ndm.num( ).magnitude( )
00224         mul = ndm.mul( )
00225 
00226         result = Result.Result( mag, mul )
00227         result = globals.ResultCache.add( result, self._seed )
00228 
00229         state = result.state( )
00230         if state == "dup":
00231             return
00232 
00233         if globals.printDate:
00234             print "%s" % TimeStamp.TimeStamp( ),
00235         if globals.printDate or globals.printResult:
00236             print "%s 1 %s" % ( mag, mul )
00237 
00238         self._mp_cnt += 1
00239         print "#### %3d" % self._mp_cnt,
00240 
00241         if globals.quiet > 1:
00242             print "%s %s -> %s" % ( state, self._seed, result )
00243         else:
00244             if state != "new":
00245                 tag = "####"
00246             else:
00247                 tag = "####" * 5
00248             print tag
00249             print "#### %s %s -> %s" % ( result.state( ), self._seed, result )
00250             print tag
00251 
00252         result.state( "dup" )
00253 
00254         sys.stdout.flush()
00255 
00256         if state == "new":
00257             self.doSave( )
00258 
00259     # 1 - SearchBasedOnPower
00260     #  for results matching seed(2^N), 
00261     #      find min/max powers of 3,5,7,11,13,17,19
00262     #      extend max by 2
00263     #      with each prime/power combo as seed, search
00264 
    def SearchBasedOnPower( self, cnt, min, max ):

def ALB::ALB::search (   self,
  cnt,
  min,
  max 
)

Definition at line 358 of file ALB.py.

00358                                      :
00359         "Search for multiperfects."
00360 
00361         global printCycle
00362 
00363         self.restart( )
00364         sys.stdout.flush()
00365 
00366         total = 0
00367         cycle = min
00368 
00369         max += self._starter.count( )
00370 
00371         if globals.test_search == True:
00372 #            seed = Factors.FromNumber( "2^2" )
00373 #            self._starter.findResultMinMax( seed )
00374 
00375             pydb.debugger( )
00376             starter = Number.Number( 2, 2 )
00377             starter = Factors.FromNumber( starter )
00378             self._starter.findResultMinMax( starter )
00379 
00380 #       print "cy: %d, mx: %d" % ( cycle, max )
00381 #       sys.stdout.flush()
00382 
00383         self._starter.initialize( )
00384 
00385         while cycle < max or max == 0:
00386 
00387             beg = time.time( )
00388 
00389             try:
00390                 ( test_count, seed ) = self._starter.next( )
00391 #               print "n: %s" % seed
00392             except:
00393                 pydb.debugger( )
00394                 break
00395 
00396             if globals.qvs_flag > 1:
00397                 print "s %3d %s" % ( cycle, seed )
00398 
00399             if globals.printCycle:
00400                 print " "
00401                 print "search %d %s" % ( cycle, seed )
00402 
00403             if seed == None:
00404                 print "seed is None"
00405                 break
00406 
00407             # new seed ...
00408             if cycle != 0 and len( seed ) == 1:
00409                 break
00410 
00411             cycle += 1
00412             
00413             if globals.test_search == True:
00414                 print "%4d %s" % ( cycle, seed )
00415                 continue
00416 
00417             if globals.printCycle:
00418                 print "%s" % ndm.asUString( )
00419 
00420             globals.quiet = 2
00421             count = self.cycle( cnt, seed )
00422             total += count
00423 
00424             fin = time.time( )
00425             secs = fin - beg
00426 
00427             if globals.qvs_flag or secs >= 100 or count > 10000:
00428                 t = TimeStamp.TimeStamp( fin )
00429                 print "%s %5d %5d %4ds  %s" % ( t, test_count, count, secs, seed )
00430                 sys.stdout.flush()
00431 
00432             # save results (as needed)
00433             self.doSave( )
00434 
00435         print "count: %5d" % total
00436         sys.stdout.flush()
00437 
00438         return ( total, seed )
00439 
def Test( ):

def ALB::ALB::SearchBasedOnFactorReduction (   self,
  two,
  seed 
)

Definition at line 341 of file ALB.py.

00341                                                        :
00342 
00343         print "SearchBasedOnFactorReduction"
00344 
00345         self._starter = TripleStart.TripleStart( "fr", two, seed )
00346 
00347 #        triples = self._starter.findResultAndFactorReduce( seed )
00348 #        triples.widen( 0, 2 )
00349 #        self._starter.set_triples( two, triples )
00350 #        self._starter.setRange( two.prime( ), two.power( ) )
00351 
00352         print "%s" % self._starter
00353 
00354         self.search( 1, 0, 0 )
00355 
00356         return None
00357 
    def search( self, cnt, min, max ):

def ALB::ALB::SearchBasedOnLowCount (   self,
  two,
  results_set 
)

Definition at line 320 of file ALB.py.

00320                                                        :
00321 
00322 #       print "SearchBasedOnLowCount"
00323 
00324 #       self._starter = TripleStart.TripleStart( "lc", two, seed )
00325         self._starter = TripleStart.TripleStart( )
00326 
00327         prime = two.prime( )
00328         power = two.power( )
00329         self._starter[ prime ].power( power )
00330 
00331         self._starter.mergeResults( power, results_set )
00332 #       print self._starter.ranges_as_string( )
00333         self._starter.widen( 0, 3 )
00334 #       print self._starter.ranges_as_string( )
00335 
00336         self.search( 0, 0, 0 )
00337 #       self.search( 1, 0, 0 )
00338 
00339         return None
00340 
    def SearchBasedOnFactorReduction( self, two, seed ):

def ALB::ALB::SearchBasedOnLowCountAndFactorReduction (   self,
  min,
  max 
)

Definition at line 298 of file ALB.py.

00298                                                                  :
00299 
00300         powers = range( min, max )
00301 
00302         for power in powers:
00303 #            print "SearchBasedOnLowCountAndFactorReduction( %s )" % power
00304             two = Number.Number( 2, power )
00305             print "########## %s ##########" % two
00306 
00307             seed = Factors.FromNumber( two )
00308             results_set = globals.ResultCache.matchFactors( seed )
00309 
00310             if len( results_set ) == 0:
00311                 pydb.debugger( )
00312                 self.SearchBasedOnFactorReduction( two, seed )
00313             else:
00314                self.SearchBasedOnLowCount( two, results_set )
00315 
00316             print ""
00317 
00318         return
00319 
    def SearchBasedOnLowCount( self, two, results_set ):

def ALB::ALB::SearchBasedOnPower (   self,
  cnt,
  min,
  max 
)

Definition at line 265 of file ALB.py.

00265                                                  :
00266 
00267         while True:
00268             #self.search( cnt, min, max )
00269             ( min, seed ) = self.search( cnt, min, max )
00270             pydb.debugger( )
00271             if seed == None:
00272                 break
00273 
00274         return
00275 
00276     # 2 - SearchBasedOnPowerAndDate
00277     #  for results matching seed(2^N),
00278     #      if 1 or more newer than 03/30,
00279     #    find min/max powers of 3,5,7,11,13,17,19
00280     #    extend max by 2
00281     #    with each prime/power combo as seed, search
00282 
    def SearchBasedOnPowerAndDate( self, cnt, min, max ):

def ALB::ALB::SearchBasedOnPowerAndDate (   self,
  cnt,
  min,
  max 
)

Definition at line 283 of file ALB.py.

00283                                                         :
00284 
00285         pydb.debugger( )
00286 
00287         return ALB.SearchBasedOnPowerAndDate
00288 
00289     # 3 - SearchBasedOnLowCountAndFactorReduction
00290     #  for each N, find results matching seed(2^N)
00291     #      if count is 0 or 1,
00292     #            for p in 19,17,13,11,7,5,
00293     #        reduce primes greater than p
00294     #        find min/max powers of 3,5,7,11,13,17,19
00295     #         extend max by 2
00296     #    with each prime/power combo as seed, search
00297 
    def SearchBasedOnLowCountAndFactorReduction( self, min, max ):


Member Data Documentation

Definition at line 40 of file ALB.py.


The documentation for this class was generated from the following file:

Generated on Sun Mar 22 09:59:14 2009 for Multiperfect Number Generator by  doxygen 1.5.8