Classes | |
class | MPNG_STAGE |
class | MPNG |
Functions | |
def | do_letter_arg |
def | do_arg_with_incr |
def | main |
def | profile_2_52_3_20_5_12_7_8 |
def | profile_2_3 |
def | profile_2_23 |
def | hotshot_stats |
def | profile |
def | control_is_repeated_state |
def | assert_cur |
def | assert_lst |
def | assert_ndm |
def | assert_pwr |
def | assert_rdr |
def | assert_sum |
Variables | |
string | RSLTS_txt = "RSLTS.txt" |
int | verbose = 0 |
isr = True | |
t600 = False | |
a600 = False |
def MPNG::assert_cur | ( | n, | ||
o | ||||
) |
Definition at line 816 of file MPNG.py.
00816 : 00817 global a600 00818 if a600 and o.magnitude( ) != n.magnitude( ): 00819 print "assert_cur: %s %s" % ( o.magnitude( ), n.magnitude( ) ) 00820 pydb.debugger( ) 00821 00822 return 00823 def assert_lst( n, o ):
def MPNG::assert_lst | ( | n, | ||
o | ||||
) |
Definition at line 824 of file MPNG.py.
00824 : 00825 global a600 00826 if a600 and n != o: 00827 print "assert_lst: %s %s" % ( n, o ) 00828 pydb.debugger( ) 00829 00830 return 00831 def assert_ndm( n, o ):
def MPNG::assert_ndm | ( | n, | ||
o | ||||
) |
Definition at line 832 of file MPNG.py.
00832 : 00833 global a600 00834 if a600: 00835 ns = "%s" % n 00836 os = "%s" % o 00837 eq = ns == os 00838 if not eq: 00839 print "assert_ndm: %s %s" % ( n, o ) 00840 pydb.debugger( ) 00841 ni = n.isInteger( ) 00842 oi = o.isInteger( ) 00843 if ni != oi: 00844 print "assert_ndm: %s %s" % ( n, o ) 00845 pydb.debugger( ) 00846 00847 return 00848 def assert_pwr( n, o ):
def MPNG::assert_pwr | ( | n, | ||
o | ||||
) |
Definition at line 849 of file MPNG.py.
00849 : 00850 global a600 00851 if a600 and n != o: 00852 print "assert_pwr: %s %s" % ( n, o ) 00853 pydb.debugger( ) 00854 00855 return 00856 def assert_rdr( n, o ):
def MPNG::assert_rdr | ( | n, | ||
o | ||||
) |
Definition at line 857 of file MPNG.py.
00857 : 00858 global a600 00859 if a600 and n != o: 00860 print "assert_rdr: %s %s" % ( n, o ) 00861 pydb.debugger( ) 00862 00863 return 00864 def assert_sum( n, o ):
def MPNG::assert_sum | ( | n, | ||
o | ||||
) |
Definition at line 865 of file MPNG.py.
00865 : 00866 global a600 00867 if not a600: 00868 return 00869 00870 ns = n.sum( ) 00871 os = o.sum( ) 00872 if ns != os: 00873 print "assert_sum: %s %s, %s %s" % ( n.sum( ), n, o.sum( ), o ) 00874 pydb.debugger( ) 00875 00876 return 00877 if __name__ == '__main__':
def MPNG::control_is_repeated_state | ( | arg | ) |
Definition at line 799 of file MPNG.py.
00799 : 00800 00801 # 02/17/08 16:14 - control is_repeated_state 00802 # 00803 # isr:t - True 00804 # isr:f - False 00805 # 00806 # isr:f - uses less memory 00807 # - slightly faster 00808 # f - 36.706s 00809 # t - 37.898s 00810 # 00811 00812 global isr 00813 isr = arg[ 4: ] == 't' 00814 print "2 - isr: %s %s" % ( arg[ 4: ], isr ) 00815 def assert_cur( n, o ):
def MPNG::do_arg_with_incr | ( | label, | ||
var, | ||||
arg | ||||
) |
def MPNG::do_letter_arg | ( | arg, | ||
mpng, | ||||
factors | ||||
) |
Definition at line 432 of file MPNG.py.
00432 : 00433 00434 global verbose 00435 00436 if arg == "i": 00437 factors = Factors.Factors( None ) 00438 00439 if arg == "l": 00440 mpng.load( ) 00441 00442 if arg == "m": 00443 testMode ^= True 00444 00445 if arg == "d": 00446 testDebug += 1 00447 00448 if arg == "q": 00449 globals.quiet += 1 00450 00451 if arg == "v": 00452 verbose += 1 00453 00454 if arg == "r": 00455 ndm = NumDenMul.new( factors ) 00456 globals.printCycle = False 00457 globals.quiet += 2 00458 00459 ( count, beg_cnt_n, net_cnt_n, ndm_dup_n ) = mpng.search( ndm, factors ) 00460 00461 if count > 100: 00462 print "%d cycles" % count 00463 00464 factors = Factors.Factors( None ) 00465 00466 return factors 00467 def do_arg_with_incr( label, var, arg ):
def MPNG::hotshot_stats | ( | ) |
Definition at line 741 of file MPNG.py.
00741 : 00742 import hotshot, hotshot.stats, test.pystone 00743 00744 prof = hotshot.Profile("stones.prof") 00745 benchtime, stones = prof.runcall(test.pystone.pystones) 00746 prof.close() 00747 00748 stats = hotshot.stats.load("stones.prof") 00749 stats.strip_dirs() 00750 stats.sort_stats('time', 'calls') 00751 stats.print_stats(20) 00752 def profile( arg ):
def MPNG::main | ( | ) |
Definition at line 477 of file MPNG.py.
00477 : 00478 00479 beg = time.time( ) 00480 00481 globals.quiet = 0 00482 00483 globals.verbose = 0 00484 globals.ndm_flag = 1 # NZ if state_seen set used to trim search tree 00485 globals.qvs_flag = 0 00486 00487 global filename 00488 filename = RSLTS_txt 00489 00490 globals.printDate = False # True 00491 globals.printResult = False # True 00492 globals.printState = False # True 00493 globals.testMode = False # True if comparing old/new tree traversal 00494 00495 globals.printCycle = False # True 00496 globals.testConflict= True # False # True if ndm.conflict() used to trim search tree 00497 globals.testDebug = False # True 00498 00499 mpng = MPNG( None ) 00500 00501 global isr, t600, a600 00502 00503 if len( sys.argv ) == 1: 00504 00505 PrintVersion( ) 00506 00507 globals.quiet += 2 00508 00509 mpng.load( ) 00510 factor = Number.Number( 2, 1 ) 00511 seed = Factors.Factors( factor ) 00512 00513 mpng.search( 0, seed) 00514 00515 else: 00516 00517 factors = Factors.Factors( None ) 00518 for arg in sys.argv[1:]: 00519 00520 if arg == "new": continue 00521 if arg == "old": continue 00522 00523 if len( arg ) == 1: 00524 factors = do_letter_arg( arg, mpng, factors ) 00525 continue 00526 00527 if arg[ 0:4 ] == "isr:": 00528 isr = arg[ 4: ] == 't' 00529 continue 00530 00531 if arg[ 0:5 ] == "a600:": 00532 a600 = arg[ 5: ] == 't' 00533 print "a600 = %s" % a600 00534 continue 00535 00536 if arg[ 0:5 ] == "t600:": 00537 t600 = arg[ 5: ] == 't' 00538 print "t600 = %s" % t600 00539 continue 00540 00541 if arg[ 0:7 ] == "profile" or arg[ 0:6 ] == "pstats": 00542 profile( arg ) 00543 continue 00544 00545 arg12 = arg[ 0:2 ] 00546 00547 if arg[ 0 ] == "f": 00548 # fq - q is 2's exponent 00549 q = arg[ 1: ] 00550 two = Number.Number( 2, q ) 00551 verbose = 2 00552 triples = mpng.generate_start_triples( two ) 00553 keys = triples.keys( ) 00554 keys.sort( ) 00555 for key in keys: 00556 print triples[ key ], 00557 print 00558 continue 00559 00560 if arg[ 0 ].isdigit( ): 00561 # "p" or "p^q" 00562 num = Number.FromString( arg ) 00563 factors.add( num ) 00564 continue 00565 00566 if arg12 == "pd": 00567 printDate = do_arg_with_incr( "printDate", printDate, arg ) 00568 continue 00569 00570 if arg12 == "pr": 00571 00572 if arg == "pro": 00573 # PrintResultsByOrder 00574 globals.PrintResultsByOrder = True 00575 continue 00576 00577 if arg == "prv": 00578 # PrintResultsByValue 00579 globals.PrintResultsByOrder = False 00580 continue 00581 00582 printResult = do_arg_with_incr( "printResult", printResult, arg ) 00583 continue 00584 00585 if arg12 == "ps": 00586 printState = do_arg_with_incr( None, printState, arg ) 00587 continue 00588 00589 if arg12 == "pc": 00590 printCycle = do_arg_with_incr( "printCycle", printCycle, arg ) 00591 continue 00592 00593 if arg12 == "tc": 00594 testConflict ^= True 00595 continue 00596 00597 if arg12 == "td": 00598 testDebug = do_arg_with_incr( "testDebug", testDebug, arg ) 00599 continue 00600 00601 if arg[0] == "r" or arg[0] == "R": 00602 if len( arg ) == 1: 00603 arg = RSLTS_txt 00604 00605 if len( arg ) != 2: 00606 filename = arg 00607 continue 00608 00609 if arg[0:4] == "rslts" or arg[0:4] == "RSLTS": 00610 continue 00611 00612 if arg == "rd1": 00613 PrintVersion( ) 00614 00615 arg = "r1" 00616 # ndm_flag = 1 00617 globals.quiet += 2 00618 # printCycle = False 00619 # testConflict = True 00620 # testDebug = False 00621 00622 if arg == "rw": 00623 mpng.load( filename ) 00624 mpng.save( filename + ".new" ) 00625 return 00626 00627 if arg[0] == "c": 00628 print " %s" % MPNG.instance 00629 print "MPNG.fc: %s" % MPNG.instance._fc #FactorCache( ) 00630 print "MPNG.sfc: %s" % MPNG.instance._sfc #SigmaFactorCache( ) 00631 00632 print "MPNG.FC: %s" % FactorCache.instance( ) 00633 print "MPNG.SFC: %s" % SigmaFactorCache.instance( ) 00634 print "MPNG.RC: %s" % ResultCache.instance( ) 00635 continue 00636 00637 if arg == "ndm": 00638 ndm_flag += 1 00639 continue 00640 00641 if arg == "qvs": 00642 qvs_flag += 1 00643 continue 00644 00645 if arg[ 0 ] == "p": 00646 profile( arg ) 00647 continue 00648 00649 if arg == "x": 00650 # print results cache 00651 break 00652 00653 if arg == "X": 00654 return 00655 00656 print "unknown option - %s" % arg 00657 continue 00658 00659 if len( factors.factors( ) ) != 0: 00660 ndm = NumDenMul.new( factors ) 00661 printCycle = False 00662 globals.quiet += 2 00663 # testDebug = True 00664 ( count, net_cnt, ndm_dup, ndm_con ) = mpng.search( 0, factors, ndm ) 00665 print "%d cycles" % count 00666 00667 fin = time.time( ) 00668 tim = fin - beg 00669 print "time: %4.2f" % tim 00670 00671 print 00672 print globals.ResultCache.counts( ) 00673 print 00674 def profile_2_52_3_20_5_12_7_8( ):
def MPNG::profile | ( | arg | ) |
Definition at line 753 of file MPNG.py.
00753 : 00754 00755 import profile 00756 00757 globals.quiet = 1 00758 00759 method = profile_2_3 00760 method = profile_2_52_3_20_5_12_7_8 00761 method = profile_2_23 00762 name = method.__name__ 00763 00764 if arg == "pr": 00765 profile.run( method ) 00766 return 00767 00768 if arg[ 0:7 ] == "profile": 00769 if len(arg) > 7 and arg[ 7 ] == "_": 00770 name = arg 00771 00772 # profile.run( method, 'profile.prof') 00773 00774 import hotshot 00775 00776 filename = method.__name__ + ".prof" 00777 prof = hotshot.Profile( filename ) 00778 prof.runcall(method) 00779 prof.close() 00780 00781 return 00782 00783 if arg[ 0:6 ] == "pstats": 00784 if len(arg) > 6 and arg[ 6 ] == "_": 00785 name = arg 00786 00787 # p = pstats.Stats('profile.prof') 00788 00789 import hotshot.stats 00790 00791 filename = method.__name__ + ".prof" 00792 stats = hotshot.stats.load( filename ) 00793 stats.strip_dirs() 00794 stats.sort_stats('time', 'calls') 00795 stats.print_stats(20) 00796 00797 return 00798 def control_is_repeated_state( arg ):
def MPNG::profile_2_23 | ( | ) |
Definition at line 721 of file MPNG.py.
00721 : 00722 00723 mpng = MPNG( None ) 00724 factors = Factors.Factors( None ) 00725 00726 num = Number.FromString( "2^23" ) 00727 factors.add( num ) 00728 00729 ndm = NumDenMul.new( factors ) 00730 00731 printCycle = False 00732 globals.quiet += 2 00733 00734 cycleMax = 0 00735 count = mpng.cycle( ndm, cycleMax ) 00736 00737 print "%d cycles" % count 00738 00739 return 00740 def hotshot_stats( ):
def MPNG::profile_2_3 | ( | ) |
Definition at line 701 of file MPNG.py.
00701 : 00702 00703 mpng = MPNG( None ) 00704 factors = Factors.Factors( None ) 00705 00706 num = Number.FromString( "2^3" ) 00707 factors.add( num ) 00708 00709 ndm = NumDenMul.new( factors ) 00710 00711 printCycle = False 00712 globals.quiet += 2 00713 00714 cycleMax = 0 00715 count = mpng.cycle( ndm, cycleMax ) 00716 00717 print "%d cycles" % count 00718 00719 return 00720 def profile_2_23( ):
def MPNG::profile_2_52_3_20_5_12_7_8 | ( | ) |
Definition at line 675 of file MPNG.py.
00675 : 00676 00677 mpng = MPNG( None ) 00678 factors = Factors.Factors( None ) 00679 00680 num = Number.FromString( "2^52" ) 00681 factors.add( num ) 00682 num = Number.FromString( "3^20" ) 00683 factors.add( num ) 00684 num = Number.FromString( "5^12" ) 00685 factors.add( num ) 00686 num = Number.FromString( "7^8" ) 00687 factors.add( num ) 00688 00689 ndm = NumDenMul.new( factors ) 00690 00691 printCycle = False 00692 globals.quiet += 2 00693 00694 cycleMax = 0 00695 count = mpng.cycle( ndm, cycleMax ) 00696 00697 print "%d cycles" % count 00698 00699 return 00700 def profile_2_3( ):
MPNG::a600 = False |
string MPNG::RSLTS_txt = "RSLTS.txt" |
MPNG::t600 = False |
int MPNG::verbose = 0 |