mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > YAFU

Reply
 
Thread Tools
Old 2022-08-01, 21:20   #375
kotenok2000
 
Mar 2018

110112 Posts
Default

It says "couldn't open stx for reading" for me when i redirect output to text file and open it in notepad++
kotenok2000 is offline   Reply With Quote
Old 2022-08-02, 01:15   #376
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

1110110010002 Posts
Default

Quote:
Originally Posted by kotenok2000 View Post
It says "couldn't open stx for reading" for me when i redirect output to text file and open it in notepad++
Not in my case, redirected output is indeed an empty-string filename between two spaces.
James Heinrich is offline   Reply With Quote
Old 2022-08-02, 13:04   #377
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

378410 Posts
Default

This is in 2.07 so may have already been fixed, but I noticed something odd this morning:
Quote:
Starting factorization of 120429365390603351499490655344463033901953027604028644082960952575362981787169556144813176219675060180597674664423811465923470403
input indicated to have been pretested to t43.01
current ECM pretesting depth: 43.01
scheduled 2178 curves at B1=0 toward target pretesting depth of 43.01
James Heinrich is offline   Reply With Quote
Old 2022-08-03, 09:32   #378
BudgieJane
 
BudgieJane's Avatar
 
"Jane Sullivan"
Jan 2011
Beckenham, UK

2·5·31 Posts
Default

Quote:
Originally Posted by James Heinrich View Post
This is in 2.07 so may have already been fixed, but I noticed something odd this morning:
That's a rounding problem: try telling it that the input has been pretested to t43.02 or t44
BudgieJane is offline   Reply With Quote
Old 2022-08-03, 09:45   #379
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

23·11·43 Posts
Default

Quote:
Originally Posted by BudgieJane View Post
That's a rounding problem: try telling it that the input has been pretested to t43.02 or t44
It might be a rounding issue if it just wants to run some more curves. My issue is with the curves being run at B1=0.
James Heinrich is offline   Reply With Quote
Old 2022-08-04, 16:01   #380
James Heinrich
 
James Heinrich's Avatar
 
"James Heinrich"
May 2004
ex-Northern Ontario

23·11·43 Posts
Default

Quote:
Originally Posted by bsquared View Post
I'm liking this quite a bit, hopefully it can be useful!
Since the default YAFU factor.log output is both quite verbose and hard-to-parse, and the upcoming factor.json format is compact and easy-to-parse, I wrote a PHP script to convert factor.log to factor.json
Usage: php yafu-log2json.php factor.log > factor.json

Please let me know if you come across a log sample where this fails.

Code:
<?php
// YAFU factor.log to JSON format converter
// written by: James Heinrich <james@mersenne.ca>
// v0.1.0-202208041146 - initial release
// v0.1.1-202208061639 - zero-width-assertions not working correctly in some cases
// usage: php yafu-log2json.php factor.log > factor.json

if ((count($_SERVER['argv']) != 2) || !preg_match('#\\.log$#i', $_SERVER['argv'][1])) {
	trigger_error('Usage: php '.basename(__FILE__).' factor.log'."\n", E_USER_ERROR);
} elseif (!file_exists($_SERVER['argv'][1])) {
	trigger_error($_SERVER['argv'][1].' does not exist'."\n", E_USER_ERROR);
}
$rawlog = file_get_contents($_SERVER['argv'][1]);

function YAFUfactorLogParse(&$rawlog) {

	// first look for nested factorizations of composites, and replace those blocks with the prime factors only
	$composites = array();
	if (preg_match_all('#^(.+), c([0-9]+) = ([0-9]+)[ \r\n]#im', $rawlog, $matchset, PREG_PATTERN_ORDER)) {
		foreach ($matchset[3] as $composite) {
			$composites[$composite] = $composite;
		}
		ksort($composites);
		foreach ($composites as $composite) {
			if (preg_match('#^([^\\n]+)Starting factorization of '.$composite.'(.+)Total factoring time = [0-9\\.]+ seconds#imsU', $rawlog, $matches)) {
				if (preg_match_all('# p(rp)?([0-9]+) = ([0-9]+)#i', $matches[2], $matches2)) {
					list($dummy, $dummy, $dummy, $prime_factors) = $matches2;
					if (FactorsAddUp($composite, $prime_factors)) {
						$composites[$composite] = implode('*', $prime_factors);
						$rawlog = str_replace($matches[0], '', $rawlog);
						if (preg_match('#^([^\\n]+), c'.strlen($composite).' = '.$composite.'#im', $rawlog, $matches3)) {
							$prime_replacements = array();
							foreach ($prime_factors as $prime_factor) {
								$prime_replacements[] = $matches3[1].', prp'.strlen($prime_factor).' = '.$prime_factor;
							}
							$rawlog = str_replace($matches3[0], implode(PHP_EOL, $prime_replacements), $rawlog);
						}
					} else {
						trigger_error('!FactorsAddUp('.$composite.', '.implode('*', $prime_factors).')'."\n", E_USER_ERROR);
					}
				}
			}
		}
	}
	foreach ($composites as $composite => $composite_factored) {
		if ($composite == $composite_factored) {
			trigger_error('Unfactored Composite: '.$composite."\n", E_USER_ERROR);
		}
	}

	// split out each factorization attempt, skipping any aborted attempts
	if (preg_match_all('#^([^\\n]+)Starting factorization of ([0-9]+)((?!Starting factorization of).*)Total factoring time = ([0-9\\.]+) seconds#imsU', $rawlog, $matchset, PREG_PATTERN_ORDER)) { // negative-string-match https://stackoverflow.com/questions/406230/
		unset($matchset[1], $matchset[2], $matchset[3]); // save memory
		$JSON = array();
		foreach ($matchset[0] as $matchnum => $logtext) {
			if (preg_match('#^(.+), Starting factorization of ([0-9]+)#i', $logtext, $matches)) {
				list($dummy, $timestamp_computer, $composite) = $matches;
				$datetime_start = YAFUtimestampParse($timestamp_computer);

				// div: found prime factor = 3
				// prp16 = 6490148442004687 (curve 6 stg2 B1=11000 sigma=3972849619 thread=0)
				// prp32 = 15434893707426995319538878760499
				$prime_factors = array();
				if (preg_match_all('# div: found prime factor = ([0-9]+)#i', $logtext, $matches2)) {
					foreach ($matches2[1] as $prime_factor) {
						$prime_factors[] = $prime_factor;
					}
				}
				if (preg_match_all('# p(rp)?([0-9]+) = ([0-9]+)#i', $logtext, $matches2)) {
					foreach ($matches2[3] as $prime_factor) {
						$prime_factors[] = $prime_factor;
					}
				}
				if (!FactorsAddUp($composite, $prime_factors)) {
					trigger_error('!FactorsAddUp('.$composite.', '.implode('*', $prime_factors).')'."\n", E_USER_ERROR);
				}

				/*
				// https://www.mersenneforum.org/showthread.php?p=605289#post605289
				{
				        "input-expression":"factor(2^523-1)",
				        "input-decimal":"27459190640522438859927603196325572869077741200573221637577853836742172733590624208490238562645818219909185245565923432148487951998866575250296113164460228607",
				        "input-argument-string":"factor(2^523-1) -v -threads 32 -snfs_xover 70 -plan light ",
				        "factors-prime":["160188778313202118610543685368878688932828701136501444932217468039063","171417691861249198128317096534322116476165056718630345094896620367860006486977101859504089"],
				        "pm1-curves" : {"150000":1,"3750000":1},
				        "ecm-curves" : {"2000":256,"11000":256,"50000":256,"250000":256},
				        "ecm-levels" : {"t15":117.64,"t20":47.95,"t25":6.49,"t30":0.68,"t35":0.06},
				        "runtime" : {"total":1729.3813, "ecm":3.6256, "pm1":1.1629, "pp1":0.0000, "siqs":0.0000, "nfs-total":1720.8274, "nfs-poly":0.0000, "nfs-sieve":989.4496, "nfs-filter":405.3591, "nfs-la":175.4860, "nfs-sqrt":52.9520},
				        "time-start" : "2022-05-05  09:20:43",
				        "time-end" : "2022-05-05  09:49:33",
				        "info":{"compiler":"INTEL 2021","ECM-version":"7.0.4","GMP-version":"6.2.0","yafu-version":"2.08"}
				}
				*/
				$data = array(
					'input-decimal' => $composite,
					'factors-prime' => $prime_factors,
					'runtime' => array('total'=> $matchset[4][$matchnum]),
					'time-start' => $datetime_start,
				);
				if (preg_match('#^.+, Total factoring time = ([0-9\\.]+) seconds#im', $logtext, $matches2)) {
					$data['time-end'] = YAFUtimestampParse($matches2[0]);
				}
				$elapsedTimes = array(
					'siqs'     => 'SIQS',  // SIQS elapsed time = 5.3933 seconds.
					'nfs-sqrt' => 'Sqrt',  // Sqrt elapsed time = 0.0060 seconds.
					'nfs'      => 'NFS',   // NFS elapsed time = 54998.4025 seconds.
					                       // Lanczos elapsed time = 0.6300 seconds.
				);
				foreach ($elapsedTimes as $json_key => $text_string) {
					if (preg_match('#^.+, '.$text_string.' elapsed time = ([0-9\\.]+) seconds\\.#im', $logtext, $matches2)) {
						$data['runtime'][$json_key] = $matches2[1];
					}
				}
				$JSON[] = json_encode($data);

			} else {
				trigger_error('Failed to match start of factorization in logtext #'.$matchnum."\n\n".$logtext."\n", E_USER_ERROR);
			}
		}
		return implode("\n", $JSON);
	} else {
		trigger_error('Failed to preg_match_all "Starting factorization .. Total factoring time" in $rawlog ('.number_format(strlen($rawlog)).' bytes)'."\n");
	}
	return false;
}

function YAFUtimestampParse($line) {
	list($rawdate, $rawtime) = explode(' ', $line);
	return date('Y-m-d H:i:s', strtotime($rawdate.' '.$rawtime));
}
function FactorsAddUp($bignumber, $factors) {
	$composite = 1;
	foreach ($factors as $factor) {
		$composite = gmp_mul($composite, $factor);
	}
	$composite = gmp_strval($composite);
	return ($composite == $bignumber);
}

echo YAFUfactorLogParse($rawlog)."\n";


Caveat: I discovered a quirk in YAFU v1.34.5 that double-outputs prp factor lines when it discovers a "perfect power":
Quote:
Starting factorization of 3827960579805422062343214616570866403
****************************
prp13 = 1564308789787
prp13 = 1564308789787
prp13 = 1564308789787
input is a perfect power
prp13 = 1564308789787
prp13 = 1564308789787
prp13 = 1564308789787
This case is not handled by my script since it appears YAFU v2.x no longer does this, you'll just get a factors-don't-match error if this is encountered.

Last fiddled with by James Heinrich on 2022-08-06 at 20:45
James Heinrich is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
yafu ignoring yafu.ini chris2be8 YAFU 9 2022-02-17 17:52
Running YAFU via Aliqueit doesn't find yafu.ini EdH YAFU 8 2018-03-14 17:22
YAFU-1.34 bsquared YAFU 119 2015-11-05 16:24
Yafu bug. storflyt32 YAFU 2 2015-06-29 05:19
yafu 1.32 bsquared YAFU 28 2012-07-20 16:17

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


Tue Aug 9 20:57:35 UTC 2022 up 33 days, 15:44, 2 users, load averages: 1.02, 1.04, 1.13

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, 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.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔