#!/usr/local/bin/perl -w # creates gallager matrices in code/GHB and checks them out. # # to make some comparison seagate codes, # beckmann.p w=4 codewordsearch=0 N=1998 M=222 verbose=1 codemodops="-t2 0" T=20 # $quiet=0; # where to put output $devnull = 1 ; # whether to write all errors to devnull. # method 3: $s0 = 0 ; #seed offset (recommmend divisible by 1000) $code5arg="-maxa 3000" ; # max attempts before giving up on overlaps $docodemod = 1 ; $codemodops="-x3 1 -t3 1" ; $codemodops="-t2 0" ; $bin='bindec'; $bin='bini386' ; $M=-1; $N=99 ; $T=1 ; # number to make @methodlist = ( 1 , 2 , 3 ) ; @methodlist = ( 3 ) ; $w = 3 ; # weight per column $makecode = 1 ; # whether to make the code. $readerr = 1 ; # whether to read the error log file. $verbose = 0 ; $cwweight = 8 ; $codewordsearch = 1 ; # whether to look for weight 8 codewords # GHG.p N=$N seed=$seed spec1.1 > GHB/$N.spec1.1 # GHG.p N=$N seed=$seed spec1.3 > GHB/$N.spec1.3 # not this: # ../bini386/code4r -cheap 1 -n $N -t1 3 -v 0 -rho 0 -hd 3 -seed $seed -o GHB/$N.4r.3 # method 3: # ../bini386/code5 -n $N -t1 3 -v 0 -m $N -hd 3 -seed $seed -o GHB/$N.4r.3 # ../bini386/codemodify -ai GHB/99.4r eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; if ( $M < 0 ) { $M = $N ; } foreach $method (@methodlist) { print "trying method $method\n================\n" ; $failtot = 0 ; # dull initialization $doubletssum = 0 ; $success = 0 ; $weightenumeratorsfound = 0 ; for ( $weight = 0 ; $weight <= $cwweight ; $weight ++ ) { $cumstot[$weight] = 0 ; $cwstot[$weight] = 0 ; $dirtied[$weight] = 0 ; } for ( $t = 1 ; $t <= $T ; $t ++ ) { $seed = $s0 + $method * 100 + $t ; $err = $devnull ? "/dev/null" : "e/$N.$w.$method.$seed" ; if ( $method == 1 ) { $spec = "spec$w.1" ; } elsif ( $method ==2 ) { $spec = "spec$w.$w" ; } elsif ( $method == 3 ) { $ao = "GHB/$N.$M.$w.$seed" ; # was n.5.w.seed # ../bini386/code5 -n 99 -t1 3 -v 0 -m 99 -hd 3 -seed 123 -o GHB/99.5.3 $command = "../$bin/code5 $code5arg -n $N -m $M -t1 $w -v 0 -hd 3 -seed $seed -o $ao >& $err" ; } if ( $method == 1 || $method == 2 ) { $ao = "GHB/$N.$spec.$seed" ; $command = "(GHG.p N=$N seed=$seed $spec > $ao) >& $err" ; } # check the matrix for loops $properties = "e/p$seed" ; $command2 = "../$bin/codemodify2 -ai $ao $codemodops >& $properties " ; # check for codewords $properties3 = "e/cw$seed" ; $command3 = "wordfind.p w=$cwweight < $ao >& $properties3 " ; # # Do the commands # if ( $makecode ) { print $command , "\n" ; system ( $command ) ; # method 1,2: #look for: failures: 0. Writing code. # method 3: } if ( $readerr ) { open ( ERR , "< $err" ) ; $failures = - 1; if ( $method != 3 ) { while ( ) { if ( /failures:\s+([^\.]+)\./ || /definitely stuck/ ) { $failures = 1 ; } } if ( $failures < 0 ) { print STDERR "problem reading ERR stream $err\n" ; } } else { while ( ) { if ( /failure/ || /definitely stuck/ ) { $failures = 1 ; } # print ; } print "\n" ; if ( $failures < 0 ) { $failures = 0 ; print "NO FAILS \n" if ( $verbose) ; } else { print " FAILED !!!!!! \n" if ( $verbose) ; } } } else { $failures = 0 ; # assert (having not read the err file) that there are no failures } if ( $failures > 0 ) { print STDERR "F" ; $failtot ++ ; } else { # check how good this code is $nofile = 0 ; $overlaps = -1 ; $doubleentries = -1 ; $badloops = -1 ; $doublets = -1 ; $md = -1 ; $x3 = "-0" ; $t3 = "-0" ; if ($docodemod) { print "checking code: $command2\n" ; system ( $command2 ) ; open ( IN , "< $properties" ) ; INLOOP: while ( ) { if ( /No such file/ ) { $nofile = 1 ; last INLOOP ; } if ( /([^\s]+)\soverlaps,\s([^\s]+)\sdouble/ ) { $overlaps = $1 ; $doubleentries = $2 ; } if ( /TOTALS.*\s+([^\s]+)\s+bad loops\s+([^\s]+)\s+doublets\s+([^\s]+)\s+/ ) { $badloops = $1 ; $doublets = $2 ; $md = $3 ; if ( /x3:\s+([^\s]+)\s+/ ) { $x3 = $1 ; } if ( /t3:\s+([^\s]+)\s+/ ) { $t3 = $1 ; } } } if ( $nofile ) { $failures = 1 ; $failtot ++ ; } else { if ( $overlaps < 0 ) { print STDERR "problem o !\n" ; } if ( $doublets < 0 ) { print STDERR "problem dbts !\n" ; } if ( $doubleentries < 0 ) { print STDERR "problem do !\n" ; } if ( $badloops < 0 ) { print STDERR "problem bo !\n" ; } if ( $md < 0 ) { print STDERR "problem mo !\n" ; } if ( $overlaps > 0 ) { print STDERR "unexpected overlaps !\n" ; $failtot ++ ; $failures = 1 ; } if ( $doubleentries > 0 ) { print STDERR "unexpected double entries !\n" ; $failtot ++ ; $failures = 1 ; } } if ( $failures == 0 ) { $success ++ ; $doubletssum += $doublets ; } } if ( $codewordsearch ) { print "checking for codewords: $command3\n" ; system ( $command3 ) ; open ( IN , "< $properties3" ) ; $foundit = 0 ; while ( ) { if ( /cums:/ ) { $foundit = 1 ; # s/cums:\s*// ; @cums = split ; # zero element is "cums" } if ( /cws:/ ) { $foundit = 1 ; s/\d*\s*cws:\s*/cws: / ; @cws = split ; # zero element is "cws" } } close (IN) ; if ( $foundit ) { $weightenumeratorsfound ++ ; for ( $weight = 1 ; $weight <= $cwweight ; $weight ++ ) { $cumstot[$weight] += $cums[$weight] ; $cwstot[$weight] += $cws[$weight] ; $dirtied[$weight] += ($cws[$weight]>0) ? 1 : 0 ; } } } } } print STDERR "\n$N: weight $w method $method succeeded $success / $T; $doubletssum\n\n" ; open ( REP , ">> r/$method.$w" ) ; print REP "$N $w $method $failtot $success $T $doubletssum" ; if ( $success > 0 ) { printf REP " %8f " , $doubletssum/$success ; } else { print REP " -0 " ; } print REP "$x3 $t3 " ; if ( $codewordsearch ) { if ( $weightenumeratorsfound ) { for ( $wt = 1 ; $wt <= $cwweight ; $wt ++ ) { $cumstot[$wt] = $cumstot[$wt] / $weightenumeratorsfound ; $cwstot[$wt] = $cwstot[$wt] / $weightenumeratorsfound ; $dirtied[$wt] = $dirtied[$wt] / $weightenumeratorsfound ; print REP "$wt " ; print REP "$dirtied[$wt] " ; print REP "$cwstot[$wt] " ; print REP "$cumstot[$wt] " ; print REP " " ; } } } print REP "\n" ; }