mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > FactorDB

Reply
 
Thread Tools
Old 2010-09-20, 21:34   #881
Syd
 
Syd's Avatar
 
Sep 2008
Krefeld, Germany

2×5×23 Posts
Default

Quote:
Originally Posted by maxal View Post
Thanks, that's helpful
But n=100 seems to produce only a couple of dozens id's ;(
Also, parameter maxdig would be helpful to avoid factorization of monsters.

On a different topic, could you please add support for cyclotomic polynomials (similarly to Phi() in ecm) ?
Sure you can. Maxdig is in and the n=100 limit now also works.

For retrieving the numbers there is another script thats maybe helpful:

getnumber.php?id=<id>

returns the Code (C, PRP, ..)+space+all digits. No HTML at all.

I'll add the cyclotomic polynomials later - first I have to read about that topic.

Last fiddled with by Syd on 2010-09-20 at 21:35 Reason: typo
Syd is offline   Reply With Quote
Old 2010-09-20, 21:42   #882
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

2×1,433 Posts
Default

Quote:
Originally Posted by Syd View Post
I'll add the cyclotomic polynomials later - first I have to read about that topic.
Factorizations available here
kar_bon is offline   Reply With Quote
Old 2010-09-20, 21:44   #883
maxal
 
maxal's Avatar
 
Feb 2005

3748 Posts
Default

Quote:
Originally Posted by Syd View Post
Sure you can. Maxdig is in and the n=100 limit now also works.
http://factordb.com/getrandom.php?n=100&t=3 produces an empty page ;(
maxal is offline   Reply With Quote
Old 2010-09-20, 21:47   #884
Syd
 
Syd's Avatar
 
Sep 2008
Krefeld, Germany

2×5×23 Posts
Default

Quote:
Originally Posted by maxal View Post
Whoops.
Wrong maxdig default. Please try again
Syd is offline   Reply With Quote
Old 2010-09-20, 21:54   #885
maxal
 
maxal's Avatar
 
Feb 2005

22·32·7 Posts
Default

Quote:
Originally Posted by Syd View Post
Whoops.
Wrong maxdig default. Please try again
It now works. Thanks!

Here is an updated script that uses new features.

Code:
#!/usr/bin/perl
use strict;

print("FactorDB Helper 1.3\n");

# wget executable
my $wget = "wget --no-check-certificate";

# msieve executable
my $msieve = "/home/maxal/libs/msieve/msieve/trunk/msieve -t 3";

# min and max number of digits to factor
my $mindig = 65;
my $maxdig = 100;


$| = 1;
$/ = undef;

while(1) {

my @todo;

# getting 100 random unfactored numbers
$_ = `$wget -O - "http://factordb.com/getrandom.php?n=100&t=3&mindig=$mindig&maxdig=$maxdig"`;

# or getting 100 smallest unfactored numbers
#$_ = `$wget -O - "http://factordb.com/listtype.php?t=3&scriptmode=1"`;


while( /(\d{19})\s(\d+)/gs ) {

#  /<a href=\"index\.php\?id=([^\"]*)\"><font color=\"\#002099\">([^<]*)<\/font><\/a><sub>&lt;(\d+)&gt;<\/sub>/gs ) {

    my $id = $1;
    my $digits = $2;
    
    if( ($digits >= $mindig) && ($digits <= $maxdig) ) {
	push(@todo,$id);
    }
}

print("Todo size: ",scalar(@todo),"\n");

if( scalar(@todo) == 0 ) {
    print("No suitable numbers. Resting for a while.\n");
    sleep 60;
    next;
}

shuffle(@todo);


foreach (@todo) { 
    my $id = $_;

    # checking status and getting the number in decimal
    $_ = `$wget -O - http://factordb.com/getnumber.php?id=$id`;
    if( ! /(\S+)\s(\d+)/ ) {
	print("Error 1\n");
	sleep 60;
	next;
    }
    
    if( $1 eq "FF" ) {
	print("\nid=$id is already factored.\n\n");
	next;
    }
    
    my $number = $2;
    my $digits = length($number);
    
    print("Factoring $digits-digit number (id=$id)\n");
    
    if( $digits >= 80 ) {
	$_ = `$msieve -v -n $number`;
    }
    else {
	$_ = `$msieve -v $number`;
    }
    
    if( /prp\d+ factor: (\d+)\s/s ) {
	my $factor = $1;
	print("\nFactor found: $factor\n\n");
	$_ = `$wget --post-data "report=$factor&format=0" -O - http://factordb.com/index.php?id=$id`;
    }
    else {
	print("Error 2\n");
	sleep 60;
    }
}
}

exit;


sub shuffle {
    for (my $i = 0; $i < @_; $i++) {
        my $j = rand(@_ - $i) + $i;             # pick random element
        ($_[$i], $_[$j]) = ($_[$j], $_[$i]);    # swap 'em
    }
}
maxal is offline   Reply With Quote
Old 2010-09-20, 22:02   #886
firejuggler
 
firejuggler's Avatar
 
Apr 2010
Over the rainbow

1001110101102 Posts
Default

edit
ok, my fault found the problem : I didn't copy the subroutine at the end, and thanks for the msieve output.
Oon another note, don't worry (for now) about the max size. From what i seen , (listtype.php?t=3&start=10000&perpage=1000 - if I use start=11000 its the same page that appear, and it has 77 digits-) the number of digits take a long time rizing. at the speed of 140 sec by number on my medium comp, it will take 427 hours to do them all on a single cpu.

-damn it. much shorter than i though- ermmm... but since new composite with no know factor are 'discovered' vey often, it may take much longuer to go to 77 digits

Last fiddled with by firejuggler on 2010-09-20 at 22:45
firejuggler is offline   Reply With Quote
Old 2010-09-20, 23:13   #887
rekcahx
 
Oct 2009
Oulu, Finland

2×3×5 Posts
Default Helper script + yafu

Hi. I did some refactorization to helper script. This version uses Yafu instead of Msieve.

Changes: shuffle-subroutine from end to begin. Spaces converted to tabs. Yafu insted of Msieve.

Code:
#!/usr/bin/perl
use strict;

print("FactorDB Helper 1.4 with yafu\n");

# wget executable
my $wget = "wget --no-check-certificate";

# min and max number of digits to factor
my $mindig = 71;
my $maxdig = 95;

$| = 1;
$/ = undef;

sub shuffle {
    for ( my $i = 0 ; $i < @_ ; $i++ ) {
        my $j = rand( @_ - $i ) + $i; # pick random element
        ( $_[$i], $_[$j] ) = ( $_[$j], $_[$i] ); # swap 'em
    }
}

while (1) {
    
    my @todo;

    # getting 100 random unfactored numbers
    $_ = `$wget -O - "http://factordb.com/getrandom.php?n=100&t=3&mindig=$mindig&maxdig=$maxdig"`;

    # or getting 100 smallest unfactored numbers
    #$_ = `$wget -O - "http://factordb.com/listtype.php?t=3&scriptmode=1"`;

    while (/(\d{19})\s(\d+)/gs) {

        my $id = $1;
        my $digits = $2;

        if ( ( $digits >= $mindig ) && ( $digits <= $maxdig ) ) {
            push( @todo, $id );
        }
    }

    print( "Todo size: ", scalar(@todo), "\n" );

    if ( scalar(@todo) == 0 ) {
        print("No suitable numbers. Resting for a while.\n");
        sleep 60;
        next;
    }

    shuffle(@todo);

    foreach (@todo) {
        my $id = $_;

        # checking status and getting the number in decimal
        $_ = `$wget -O - http://factordb.com/getnumber.php?id=$id`;
        if ( !/(\S+)\s(\d+)/ ) {
            print("Error 1\n");
            sleep 60;
            next;
        }

        if ( $1 eq "FF" ) {
            print("\nid=$id is already factored.\n\n");
            next;
        }

        my $number = $2;
        my $digits = length($number);

        print("Factoring $digits-digit number (id=$id)\n");

        my $yafu = "./yafu \"siqs($number)\" >joo.log";
        system($yafu);
        my $text = do { local ( @ARGV, $/ ) = "joo.log"; <> };
        print "Num: $number\nResults:\n";
        my @results;

        my @out = split( "\n", $text );
        for (@out) {
            if (/P.*? = (\d+)/) {
                push( @results, $1 );
                print "$1\n";
            }
        }

        unlink "joo.log";

        if ( scalar(@results) > 0 ) {
            my $factors = join("\n",@results);
            $_ = `$wget --post-data "report=$factors&format=0" -O - http://factordb.com/index.php?id=$id`;
        }
        else {
            print("Error 2\n");
            sleep 60;
        }
    }
}
rekcahx is offline   Reply With Quote
Old 2010-09-20, 23:32   #888
Syd
 
Syd's Avatar
 
Sep 2008
Krefeld, Germany

23010 Posts
Default

The helper script works great!
Just 2 small changes:
There has almost no ECM work been done on these numbers, I just pulled a P16 out of a C75 with SIQS. So I changed siqs() to factor() to do proper ECM.
The number does not need to be "FF" if a factor is found, it could be "CF" with a small composite part. So changed the check to != "C".

Code:
#!/usr/bin/perl
use strict;

print("FactorDB Helper 1.4 with yafu\n");

# wget executable
my $wget = "wget --no-check-certificate";

# min and max number of digits to factor
my $mindig = 65;
my $maxdig = 95;

$| = 1;
$/ = undef;

sub shuffle {
    for ( my $i = 0 ; $i < @_ ; $i++ ) {
        my $j = rand( @_ - $i ) + $i; # pick random element
        ( $_[$i], $_[$j] ) = ( $_[$j], $_[$i] ); # swap 'em
    }
}

while (1) {
    
    my @todo;

    # getting 100 random unfactored numbers
    $_ = `$wget -O - "http://factordb.com/getrandom.php?n=100&t=3&mindig=$mindig&maxdig=$maxdig"`;

    # or getting 100 smallest unfactored numbers
    #$_ = `$wget -O - "http://factordb.com/listtype.php?t=3&scriptmode=1"`;

    while (/(\d{19})\s(\d+)/gs) {

        my $id = $1;
        my $digits = $2;

        if ( ( $digits >= $mindig ) && ( $digits <= $maxdig ) ) {
            push( @todo, $id );
        }
    }

    print( "Todo size: ", scalar(@todo), "\n" );

    if ( scalar(@todo) == 0 ) {
        print("No suitable numbers. Resting for a while.\n");
        sleep 60;
        next;
    }

    shuffle(@todo);

    foreach (@todo) {
        my $id = $_;

        # checking status and getting the number in decimal
        $_ = `$wget -O - http://factordb.com/getnumber.php?id=$id`;
        if ( !/(\S+)\s(\d+)/ ) {
            print("Error 1\n");
            sleep 60;
            next;
        }

        if ( $1 != "C" ) {
            print("\nid=$id has known factors / is already factored.\n\n");
            next;
        }

        my $number = $2;
        my $digits = length($number);

        print("Factoring $digits-digit number (id=$id)\n");

        my $yafu = "H:/PATH/TO/YAFU/yafu \"factor($number)\" >joo.log";
        system($yafu);
        my $text = do { local ( @ARGV, $/ ) = "joo.log"; <> };
        print "Num: $number\nResults:\n";
        my @results;

        my @out = split( "\n", $text );
        for (@out) {
            if (/P.*? = (\d+)/) {
                push( @results, $1 );
                print "$1\n";
            }
        }

        unlink "joo.log";

        if ( scalar(@results) > 0 ) {
            my $factors = join("\n",@results);
            $_ = `$wget --post-data "report=$factors&format=0" -O - http://factordb.com/index.php?id=$id`;
        }
        else {
            print("Error 2\n");
            sleep 60;
        }
    }
}

Last fiddled with by Syd on 2010-09-21 at 00:23 Reason: added firejuggler's comments
Syd is offline   Reply With Quote
Old 2010-09-20, 23:59   #889
firejuggler
 
firejuggler's Avatar
 
Apr 2010
Over the rainbow

2×1,259 Posts
Default

for Syd version to work(for windows) you need to change
Code:
my $yafu = "./yafu \"factor($number)\" >joo.log"
to
my $yafu = "H:/Docume~1/Vincent/Bureau/script/yafu \"factor($number)\" >joo.log";
and since the 64- digits are automatically factored, why do 'we' set the min digit limit at 71 digits?
this is a 7 digits disperency

Last fiddled with by firejuggler on 2010-09-21 at 00:20 Reason: clarification, spelling error, missing word...
firejuggler is offline   Reply With Quote
Old 2010-09-21, 01:01   #890
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

54628 Posts
Default

Quote:
Originally Posted by firejuggler View Post
Code:
my $yafu = "H:/Docume~1/Vincent/Bureau/script/yafu \"factor($number)\" >joo.log";
This depends on your computer. Set $yafu without any path and put the pl-script and yafu.exe/ini in the same folder.
kar_bon is offline   Reply With Quote
Old 2010-09-21, 01:05   #891
firejuggler
 
firejuggler's Avatar
 
Apr 2010
Over the rainbow

1001110101102 Posts
Default

i'm using a shortcut to run the script.that need the full path
firejuggler is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database for k-b-b's: 3.14159 Miscellaneous Math 325 2016-04-09 17:45
Factoring database issues Mini-Geek Factoring 5 2009-07-01 11:51
database.zip HiddenWarrior Data 1 2004-03-29 03:53
Database layout Prime95 PrimeNet 1 2003-01-18 00:49
Is there a performance database? Joe O Lounge 35 2002-09-06 20:19

All times are UTC. The time now is 21:20.

Thu Jan 21 21:20:59 UTC 2021 up 49 days, 17:32, 0 users, load averages: 1.92, 2.28, 2.30

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.