Problem for programmers

Message boards : Science : Problem for programmers
Message board moderation

To post messages, you must log in.

AuthorMessage
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 317 - Posted: 16 Aug 2023, 9:32:49 UTC
Last modified: 16 Aug 2023, 9:39:43 UTC

Dear participants!

We have an interesting problem for programmers.
If you want to help us solve this problem, write here, or PM, or at
natalimak1@yandex.ru

To get started, please read the sequence in the OEIS
https://oeis.org/A054679

Example
n = 31

{1552841185921, 1552841185963, 1552841185969, 1552841185981, 1552841185993, 1552841185999, 1552841186023,
1552841186047, 1552841186119, 1552841186137, 1552841186167, 1552841186227, 1552841186251, 1552841186293,
1552841186317, 1552841186341, 1552841186353, 1552841186359, 1552841186551, 1552841186581, 1552841186629,
1552841186683, 1552841186737, 1552841186887, 1552841186947, 1552841186959, 1552841187031, 1552841187091,
1552841187103, 1552841187109, 1552841187133}

In another format it looks like this

1552841185921: [42, 6, 12, 12, 6, 24, 24, 72, 18, 30, 60, 24, 42, 24, 24, 12, 6, 192, 30, 48, 54, 54, 150, 60, 12, 72, 60, 12, 6, 24]

We need to generate such sequences of primes in large quantities for the algorithm I developed for searching for symmetric tuples from consecutive primes.

You can see the details in the topic (in Russian)
https://boinc.progger.info/odlk/forum_thread.php?id=247

Please ask your questions.

To be continued…
ID: 317 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 318 - Posted: 17 Aug 2023, 2:31:42 UTC
Last modified: 17 Aug 2023, 2:34:51 UTC

My algorithm for finding odd-length symmetric tuples from consecutive primes consists of two stages.

1) generation of special sequences of prime numbers;
these are sequences of the kind you see in the OEIS article
https://oeis.org/A054679

2) search for symmetric tuples in the generated sequences.

The following statement is true: in any symmetric tuple of odd length from consecutive prime numbers
p1, p2, p3, …, pn (n odd)
the condition
p(k + 1) – pk, k = 1, 2, 3, …, n - 1
is a multiple of 6.

My colleague and I implemented both stages at PARI/GP.
The second stage is no problem.
The program of the first stage is catastrophically slow!

Program of the first stage (generation of special sequences of prime numbers)
author gris

\l sp_res.txt;
{i1=7898849508999998000;
 i2=7898849517000000000;
lmin=17;
n=1;
p=nextprime(i1);
pt=[p]; 
while (p<i2,  pn=nextprime(p+1);      
  if( (pn-p)%6==0, n++; p=pn; pt=concat(pt,p)
    , \\ else   
       if( n>lmin-1, 
           pd=vector(n-1,i,pt[i+1]-pt[i]);
           print(pt[1],": ", pd); print(););     
       n=1; p=pn; pt=[p]; 
  ); \\end if  
); \\end while
}

https://boinc.progger.info/odlk/forum_thread.php?id=247&postid=12310

You can run this program if you have the PARI/GP shell installed.

If you don't have the PARI/GP shell, download it from the official page
http://pari.math.u-bordeaux.fr/download.html

Please ask your questions.

To be continued…
ID: 318 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 319 - Posted: 17 Aug 2023, 5:56:17 UTC
Last modified: 19 Aug 2023, 2:52:23 UTC

The program worked on my computer for almost 40 minutes.
In the given interval, 407 special sequences of primes were generated.

Showing some special sequences

7898849509017169993: [114, 24, 18, 18, 60, 84, 72, 30, 6, 72, 162, 24, 30, 42, 30, 144, 84]
7898849509059768529: [48, 6, 24, 84, 6, 60, 24, 30, 90, 66, 36, 60, 6, 24, 66, 12, 150, 6]
7898849509063947271: [36, 132, 78, 12, 42, 42, 18, 72, 114, 60, 24, 12, 6, 18, 210, 60]
7898849509078089073: [18, 6, 42, 18, 24, 6, 216, 6, 102, 6, 174, 150, 102, 6, 132, 30]
7898849509088283997: [30, 12, 12, 12, 6, 72, 96, 30, 24, 6, 36, 90, 48, 6, 42, 84, 6, 18]
7898849509090844107: [6, 138, 36, 54, 72, 84, 186, 66, 30, 18, 54, 18, 42, 162, 126, 42, 48]
7898849509117152097: [24, 6, 12, 12, 42, 54, 54, 42, 6, 18, 12, 162, 18, 42, 36, 30]
7898849509118682251: [96, 30, 222, 42, 48, 54, 6, 108, 12, 174, 36, 18, 6, 18, 48, 168]
7898849509218513611: [6, 102, 12, 30, 66, 36, 54, 30, 6, 30, 18, 18, 60, 24, 174, 6]
7898849509282382023: [114, 12, 72, 18, 18, 6, 48, 96, 96, 186, 24, 96, 12, 36, 42, 30, 120]
7898849509283244979: [12, 48, 30, 30, 42, 6, 6, 78, 36, 30, 12, 30, 54, 18, 12, 54, 12, 78, 42, 24, 30, 90, 36, 12, 60, 36, 54]
7898849509283793143: [24, 42, 42, 6, 42, 24, 6, 78, 54, 60, 48, 48, 12, 30, 78, 6, 36, 108]
. . . . . . . . 

7898849516649670811: [30, 132, 60, 18, 42, 24, 114, 18, 90, 18, 84, 30, 12, 36, 102, 18, 114]
7898849516676644291: [12, 84, 24, 18, 24, 114, 30, 12, 12, 6, 84, 78, 60, 12, 48, 48, 6, 30]
7898849516711459051: [30, 6, 42, 48, 102, 78, 90, 30, 84, 6, 6, 120, 60, 18, 6, 42, 78]
7898849516727859307: [24, 6, 84, 12, 6, 162, 36, 36, 18, 66, 30, 30, 72, 24, 18, 42, 30]
7898849516737672853: [6, 48, 84, 36, 36, 66, 210, 18, 12, 42, 12, 24, 66, 180, 180, 108]
7898849516753429291: [12, 18, 6, 90, 60, 12, 12, 42, 60, 6, 30, 18, 12, 42, 96, 30, 12, 18]
7898849516778200251: [60, 48, 12, 30, 42, 66, 42, 6, 12, 102, 48, 18, 30, 30, 36, 66]
7898849516807426519: [42, 18, 72, 18, 30, 48, 84, 12, 18, 180, 6, 42, 114, 114, 42, 90, 12]
7898849516833262419: [42, 48, 174, 120, 78, 48, 42, 18, 102, 96, 30, 60, 24, 18, 18, 66, 18]
7898849516837914711: [6, 12, 12, 36, 30, 54, 66, 54, 36, 6, 6, 72, 48, 294, 54, 54, 6]
7898849516876992199: [18, 12, 108, 6, 120, 6, 42, 96, 30, 132, 12, 18, 12, 18, 12, 30]
7898849516900353801: [6, 12, 48, 6, 36, 30, 102, 120, 102, 6, 48, 12, 84, 66, 24, 24]
7898849516976713551: [18, 18, 66, 30, 66, 12, 42, 84, 12, 24, 24, 12, 48, 6, 120, 6]
time = 39min, 55,489 ms.

See (in Russian)
https://boinc.progger.info/odlk/forum_thread.php?id=247&postid=12311

Note: This program generates special sequences starting with length 17.

The program execution time is very long!
Of course, on another computer (with better performance), program can run 2-3-4 times faster.
But it's also very slow!

We need to look for another solution to the problem: how to execute this program 10-20 times faster.
To do this, you need to abandon PARI/GP and write this program in another language.

Please ask your questions.

To be continued…
ID: 319 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 323 - Posted: 17 Aug 2023, 17:53:25 UTC
Last modified: 18 Aug 2023, 1:28:08 UTC

Now special sequences are generated in the next interval

i1=18446744096999998000;
i2=18446744107000000000;

Generated 473 special sequences of prime numbers.
Unfortunately, I did not record the running time of the program here.

Several special sequences shown

18446744097029134577: [54, 6, 144, 102, 24, 132, 48, 96, 18, 132, 36, 132, 18, 42, 120, 30]
18446744097032217167: [12, 42, 6, 6, 60, 66, 12, 150, 60, 30, 42, 36, 60, 90, 54, 24, 60, 132, 24, 18]
18446744097034560221: [90, 12, 108, 36, 42, 48, 6, 90, 198, 18, 30, 114, 186, 42, 150, 6]
18446744097053906087: [12, 78, 24, 36, 6, 60, 36, 12, 6, 114, 120, 102, 30, 90, 36, 42]
18446744097091266773: [84, 24, 12, 24, 60, 42, 102, 108, 12, 12, 6, 18, 42, 108, 120, 6, 18]
18446744097099291301: [126, 6, 36, 42, 126, 60, 36, 18, 42, 66, 12, 42, 24, 36, 24, 126]
18446744097104608981: [90, 36, 24, 18, 42, 6, 6, 30, 24, 24, 6, 30, 66, 6, 54, 24, 42]
18446744097117989617: [60, 114, 12, 78, 42, 18, 12, 60, 48, 18, 12, 18, 84, 210, 54, 12]
18446744097120265931: [120, 60, 66, 120, 12, 180, 84, 6, 18, 36, 6, 12, 12, 84, 96, 60]
18446744097129454919: [72, 30, 12, 36, 18, 24, 36, 60, 24, 18, 48, 12, 12, 18, 24, 36, 18, 6]
18446744097164999989: [72, 120, 6, 30, 72, 30, 42, 6, 36, 30, 60, 48, 12, 54, 30, 60, 66, 6, 54]
18446744097168856087: [90, 42, 102, 48, 54, 48, 6, 54, 12, 90, 24, 42, 60, 24, 30, 24]
18446744097185784997: [12, 12, 36, 54, 12, 54, 42, 42, 150, 30, 12, 30, 36, 54, 30, 18]
18446744097191571509: [78, 6, 18, 48, 24, 36, 24, 24, 6, 6, 24, 54, 12, 78, 30, 114]
18446744097199162111: [12, 66, 42, 6, 6, 48, 30, 12, 24, 30, 60, 24, 168, 108, 60, 60]
. . . . . . . 

18446744106569552999: [12, 96, 36, 24, 42, 12, 90, 6, 114, 42, 6, 108, 36, 6, 60, 48, 30, 114]
18446744106651157243: [66, 12, 90, 36, 12, 18, 6, 120, 54, 96, 288, 78, 12, 12, 6, 12, 12]
18446744106666052201: [30, 6, 30, 6, 78, 30, 12, 90, 18, 36, 6, 60, 6, 90, 18, 42]
18446744106668222101: [12, 6, 12, 42, 30, 48, 96, 144, 42, 6, 18, 36, 24, 42, 72, 12]
18446744106690458597: [24, 270, 30, 36, 30, 24, 48, 48, 42, 84, 6, 30, 84, 54, 30, 126]
18446744106718514803: [90, 36, 24, 36, 48, 30, 12, 162, 96, 12, 48, 66, 18, 102, 66, 42, 12, 48, 18, 30]
18446744106749852911: [36, 30, 54, 18, 24, 144, 30, 36, 6, 30, 54, 48, 60, 72, 36, 24, 24, 30]
18446744106756777733: [48, 48, 30, 108, 60, 36, 108, 42, 78, 12, 54, 42, 54, 18, 60, 102]
18446744106760366811: [18, 48, 12, 18, 12, 18, 30, 36, 48, 156, 42, 18, 72, 60, 42, 18, 12, 42]
18446744106773181757: [12, 138, 54, 42, 18, 72, 18, 36, 6, 30, 36, 18, 6, 60, 48, 30]
18446744106816573623: [6, 102, 72, 36, 18, 84, 30, 36, 30, 42, 18, 6, 18, 132, 6, 12]
18446744106822164869: [138, 54, 36, 42, 24, 30, 24, 84, 18, 84, 54, 24, 36, 6, 30, 6]
18446744106835789109: [60, 132, 42, 30, 18, 126, 12, 42, 66, 6, 54, 162, 78, 12, 78, 36]
18446744106840082417: [126, 48, 42, 90, 96, 18, 12, 84, 6, 12, 42, 24, 36, 18, 6, 102, 12, 78]
18446744106852738679: [72, 48, 24, 60, 174, 84, 36, 42, 12, 12, 150, 30, 48, 126, 30, 6, 174, 84, 12]
18446744106863937827: [114, 6, 12, 12, 78, 108, 12, 30, 162, 6, 90, 72, 60, 48, 90, 36, 6]
18446744106935458807: [72, 42, 48, 18, 24, 6, 54, 12, 126, 12, 30, 48, 18, 66, 6, 18]
18446744106964037731: [150, 30, 48, 30, 108, 12, 24, 198, 12, 36, 12, 30, 12, 18, 42, 60, 18, 60, 30]

To be continued…
ID: 323 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 325 - Posted: 18 Aug 2023, 2:33:23 UTC

Dear participants!

Have you already understood the problem?
I don't see any questions.
This means that you understand everything that I am saying.

Next, I will show another test, which will indicate the time of the program.
ID: 325 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 326 - Posted: 18 Aug 2023, 7:17:55 UTC
Last modified: 19 Aug 2023, 0:14:48 UTC

Showing the second test.
Processed interval

i1=18446744106999998000;
i2=18446744119000000000;

In this interval, 527 special sequences of primes were generated.
These are some generated special sequences

18446744107018257637: [54, 6, 30, 54, 150, 42, 48, 30, 102, 48, 18, 90, 42, 6, 36, 18, 78, 54]
18446744107035719341: [96, 6, 30, 138, 6, 72, 18, 84, 42, 78, 30, 48, 48, 30, 42, 12, 42]
18446744107038384017: [6, 6, 12, 6, 30, 90, 42, 72, 42, 6, 84, 180, 24, 6, 30, 24, 30, 120, 6, 78]
18446744107104086621: [162, 48, 12, 84, 24, 66, 12, 12, 18, 42, 12, 30, 48, 48, 48, 42, 42]
18446744107117860601: [6, 72, 120, 12, 18, 12, 30, 12, 66, 72, 90, 66, 12, 78, 210, 54]
18446744107188070781: [18, 12, 18, 12, 12, 48, 12, 144, 6, 96, 18, 12, 42, 30, 6, 6, 18]
18446744107207502633: [84, 12, 18, 156, 18, 90, 66, 60, 42, 24, 6, 108, 60, 24, 18, 24, 108, 6, 54]
18446744107217481149: [42, 12, 36, 48, 36, 36, 72, 18, 42, 30, 42, 216, 84, 48, 72, 6, 48]
18446744107232419093: [90, 18, 12, 30, 24, 84, 36, 6, 6, 192, 6, 114, 66, 24, 72, 48]
18446744107234637939: [24, 18, 90, 90, 72, 36, 18, 126, 54, 30, 120, 24, 6, 36, 24, 30]
18446744107249309531: [12, 54, 6, 120, 18, 30, 6, 84, 126, 42, 24, 6, 18, 30, 84, 36]
18446744107273759723: [96, 48, 6, 60, 6, 84, 6, 48, 66, 24, 24, 36, 120, 60, 12, 102, 102]
18446744107352775883: [18, 36, 90, 24, 36, 144, 48, 18, 42, 12, 6, 24, 36, 24, 6, 12]
18446744107374599563: [18, 12, 54, 102, 12, 6, 6, 30, 114, 24, 12, 6, 24, 36, 168, 30, 12]
18446744107438105939: [54, 24, 54, 36, 36, 120, 6, 54, 6, 24, 24, 12, 30, 24, 48, 6]
18446744107445327507: [30, 12, 12, 42, 30, 60, 54, 12, 54, 24, 102, 90, 90, 162, 78, 60]
. . . . . . . . 

18446744118832199783: [54, 90, 12, 72, 42, 18, 6, 90, 66, 96, 12, 30, 36, 12, 48, 60]
18446744118838557281: [78, 78, 42, 18, 66, 6, 12, 90, 18, 12, 6, 84, 90, 6, 54, 12]
18446744118868492519: [138, 66, 36, 48, 6, 84, 30, 12, 24, 30, 186, 48, 114, 18, 54, 174, 102]
18446744118868771859: [60, 78, 42, 72, 42, 6, 60, 60, 84, 24, 30, 42, 12, 18, 18, 6, 66]
18446744118886067419: [24, 6, 24, 84, 96, 6, 72, 18, 18, 72, 72, 12, 108, 18, 18, 66, 30]
18446744118929208569: [12, 66, 66, 30, 30, 36, 84, 90, 90, 174, 24, 42, 18, 132, 198, 6]
18446744118939701507: [24, 102, 6, 12, 6, 54, 42, 84, 24, 30, 6, 24, 12, 18, 12, 54, 12, 18]
18446744118953061713: [90, 48, 36, 30, 126, 54, 66, 30, 36, 42, 120, 42, 30, 6, 18, 66, 84]
18446744118973554073: [18, 60, 66, 30, 162, 42, 18, 24, 54, 60, 60, 12, 18, 36, 48, 12]
18446744118973636507: [30, 42, 12, 42, 18, 6, 36, 6, 198, 30, 24, 78, 12, 12, 60, 30, 18]
time = 4h, 41min, 14,253 ms.

At the end you see the program execution time.

You can also take this test.
To do this, you need to run the program

\l sp_res.txt;
{i1=18446744106999998000;
 i2=18446744119000000000;
lmin=17;
n=1;
p=nextprime(i1);
pt=[p]; 
while (p<i2,  pn=nextprime(p+1);      
  if( (pn-p)%6==0, n++; p=pn; pt=concat(pt,p)
    , \\ else   
       if( n>lmin-1, 
           pd=vector(n-1,i,pt[i+1]-pt[i]);
           print(pt[1],": ", pd); );     
       n=1; p=pn; pt=[p]; 
  ); \\end if  
); \\end while
}
ID: 326 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 331 - Posted: 19 Aug 2023, 3:14:41 UTC
Last modified: 19 Aug 2023, 3:19:24 UTC

Quote
My algorithm for finding odd-length symmetric tuples from consecutive primes consists of two stages.

This algorithm has been tested in the BOINC project Gerasim@Home, Application "Get Symmetrical Tuples".
Some tuples were found.
For example,

7897171810805243831: [60,12,30,66,84,18,18,84,66,30,12,60]
7897555715751827053: [60,6,30,30,18,36,36,18,30,30,6,60]
7897569703330351801: [12,18,30,12,6,42,42,6,12,30,18,12]
7898531423490328493: [6,42,18,24,18,30,30,18,24,18,42,6]
7898564860789732043: [24,12,54,6,24,30,30,24,6,54,12,24]
7898640814002684817: [24,30,42,48,36,30,30,36,48,42,30,24]

Also the solutions are posted here

https://boinc.progger.info/odlk/forum_thread.php?id=242&postid=12179
https://boinc.progger.info/odlk/forum_thread.php?id=242&postid=12211
https://boinc.progger.info/odlk/forum_thread.php?id=242&postid=12296

These are good results!

This Application is currently suspended.

We plan to run this algorithm in our BOINC project SPT.
This will be Application 2.
But first need to modernize the program in order to achieve fast execution.

I hope you will help us in this, dear participants!
ID: 331 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 332 - Posted: 19 Aug 2023, 4:38:27 UTC

ID: 332 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 337 - Posted: 20 Aug 2023, 2:39:17 UTC

At the moment, Belyshev's program is running in our BOINC project SPT, which uses the "primesieve" generator.
This generator generates prime numbers up to 2^64.
When we reach the end of the range, the Application will stop.

Then my algorithm will be needed.
This algorithm will continue searching beyond 2^64.
We can run the algorithm now.
But it is required to modernize the program for generating special sequences so that it works much faster.

However, I started generating special sequences on my PC.
I started the generation from point 2^64.

You can help me with this!
ID: 337 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 339 - Posted: 20 Aug 2023, 2:54:57 UTC

At the moment I am generating special sequences in the interval

i1=18446744161999998000;
i2=18446744174000000000;

Next, I generated the following intervals - these are tasks (WU)

#1
18446744173999998000
18446744186000000000

#2
18446744185999998000
18446744198000000000

#3
18446744197999998000
18446744210000000000

#4
18446744209999998000
18446744222000000000

#5
18446744221999998000
18446744234000000000

etc.

You can connect right now.
You can start with WU #1 or any other WU.

Next, I will show you how you will use the generator program.
ID: 339 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 340 - Posted: 20 Aug 2023, 3:08:16 UTC
Last modified: 20 Aug 2023, 3:13:55 UTC

Create an inp.txt file in the folder where you store the sp.txt and gp.exe programs.

Write any WU in this form to the inp.txt file

18446744173999998000
18446744186000000000

Next, run the sp.txt program

\l sp_res.txt;
{tin = fileopen("inp.txt");
    i1=eval(filereadstr(tin));
    i2=eval(filereadstr(tin));
fileclose(tin);
lmin=17;
n=1;
p=nextprime(i1);
pt=[p]; 
while (p<i2,  pn=nextprime(p+1);      
  if( (pn-p)%6==0, n++; p=pn; pt=concat(pt,p)
    , \\ else   
       if( n>lmin-1, 
           pd=vector(n-1,i,pt[i+1]-pt[i]);
           print(pt[1],": ", pd););     
       n=1; p=pn; pt=[p]; 
  ); \\end if  
); \\end while
}

Please ask your questions.
ID: 340 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 342 - Posted: 20 Aug 2023, 7:02:00 UTC
Last modified: 20 Aug 2023, 7:04:50 UTC

Program for generating special sequences in a given interval
i1=18446744161999998000;
i2=18446744174000000000;

ended.

Show the end of the output in the console

. . . . . . . . 
18446744173773086539: [30, 72, 96, 42, 18, 42, 54, 30, 24, 12, 30, 30, 12, 6, 18
0, 30]
18446744173837773817: [72, 84, 78, 36, 96, 54, 24, 36, 6, 6, 60, 12, 30, 60, 6,
72]
18446744173841827751: [12, 54, 12, 24, 48, 72, 24, 102, 12, 72, 48, 36, 42, 54,
18, 6]
18446744173875844759: [102, 42, 108, 18, 12, 96, 6, 120, 24, 12, 240, 54, 54, 24
, 12, 6]
18446744173895846261: [12, 6, 30, 78, 54, 78, 12, 72, 54, 114, 6, 12, 198, 84, 3
0, 108, 24]
time = 4h, 42min, 53,831 ms.
(10:12) gp >

The program ran for 4h, 42min, 53,831 ms.
My computer has poor performance.
On your computer, this program will run 2-3-4 times faster.

Now I start generating at the next interval, WU#1
18446744173999998000
18446744186000000000
ID: 342 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 421 - Posted: 27 Aug 2023, 21:03:02 UTC
Last modified: 27 Aug 2023, 21:03:49 UTC

Unfortunately, no one has suggested anything to solve the problem.

I keep generating special sequences in two threads.
Intervals #35 and #36 are currently being processed.

I proposed Corporal to run this algorithm in Application 2 of our SPT project (this algorithm was tested in the BOINC project Gerasim@home, testing was successful).
Corporal said he didn't have enough experience in starting a BOINC project.

So we're inviting someone with experience in BOINC projects to help Corporal get the job done.

Next, I will show another way to solve this problem.
Perhaps this way is easier.
ID: 421 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 422 - Posted: 27 Aug 2023, 21:19:22 UTC

Here you see Belyshev's program

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <set>
#include <ctime>
#include <Windows.h>
#include "primesieve.h"

using namespace std;

typedef unsigned long long ull;
enum poziciya{chasy,minuty,sekundy,sdelano,vremya,interval,provereno,skorostq,vsego_16,konec};
enum shablony{s_16=15,s_17,s_18,s_19,s_20,s_21,s_22,s_23,s_24,s_25,s_26,s_27,s_28,s_29,s_30,s_31,s_32,s_33};

const int dlina_intervala = 2000000000;
const int chislo_shablonov = 18;
const int max_smew = ((s_33 + 1) >> 1);
const int centr = (s_33 >> 1) - 1;
const int ss = 100;
const int sss = 1000000;
const COORD koord[] = {{40,0},{51,0},{54,0},{13,2},{49,0},{0,1},{0,2},{0,3},{12,4},{0,22}};

class _kursor{
	HANDLE ScrHandle;
public:
	_kursor(){ScrHandle = GetStdHandle(STD_OUTPUT_HANDLE);}
	void skrytq(){
		CONSOLE_CURSOR_INFO kursinf;	
		GetConsoleCursorInfo(ScrHandle , &kursinf);
		kursinf.bVisible = false;
		SetConsoleCursorInfo(ScrHandle , &kursinf);
	}
	void pokazatq(){
		CONSOLE_CURSOR_INFO kursinf;	
		GetConsoleCursorInfo(ScrHandle , &kursinf);
		kursinf.bVisible = true;
		SetConsoleCursorInfo(ScrHandle , &kursinf);
	}
	void pomestitq(COORD z){SetConsoleCursorPosition(ScrHandle, z);}
} kursor;

HANDLE hpotok;
DWORD idpotok;
UINT_PTR idTimer;
int speed, najdeno[chislo_shablonov];
ull start, endint, max_stop = primesieve::get_max_stop();
unsigned progress;
bool otobr, poisk, pros, provr;
vector<ull> primes;
clock_t nachtik;

void __stdcall TimerProc(HWND, UINT, UINT, DWORD);
DWORD __stdcall potok(void*);
bool vypolnitq();
bool init(int nabor[]);
void proverka(int nabor[]);
void vyvod(long long stprime, int nabor[], int st, int shablon);
void prov_ne_poln(int nabor[]);
void prov_nach_ne_poln(int nabor[]);
inline void vremya_vyvod(){
	static int tik, minuta, chas;	
	if(tik > 57){
		tik = 0;
		if(minuta > 58){
			minuta = 0;
			chas++;
			kursor.pomestitq(koord[chasy]);	
			cout << setw(10) << chas;
		}
		else minuta++;
		kursor.pomestitq(koord[minuty]);
		cout << setw(2) << setfill('0') << minuta;
		kursor.pomestitq(koord[sekundy]);
		cout << setw(2) << tik << setfill(' ');
	}
	else{
		tik +=2;				
		kursor.pomestitq(koord[sekundy]);
		cout << setw(2) << setfill('0') << tik << setfill(' ');
	}
}
inline void inf_pros(){
	kursor.pomestitq(koord[interval]);
	cout << "Текущий интервал: [" << start << " ... " << endint << "]\nПросеяно  :      0%";
	kursor.pomestitq(koord[skorostq]);
	cout << "Скорость  : ";
	if(speed) cout << setw(6) << speed;
	else for(int i = s_16; i <= s_33; i++) cout << "\nНайдено " << (i + 1) << ':';
	pros = false;
}
inline void inf_provr(){
	kursor.pomestitq(koord[provereno]);
	cout << "Проверено :      0%";
	provr = false;
}
inline void inf_otobr(){
	unsigned t;
	kursor.pomestitq(koord[sdelano]);
	if(poisk){
		t = progress / ((primes.size() - 1) / ss);
		cout << setw(5) << t;
		COORD krd = koord[vsego_16];
		for(int i = 0; i < chislo_shablonov; i++, krd.Y++){
			kursor.pomestitq(krd);
			cout << setw(6) << najdeno[i];
		}
	}
	else{
		t = primes.size() / sss;
		cout << setw(5) << t;
	}
}
inline void proverka_ch(int nabor[], int st, int i){
	for(int j = 1, t = centr + st; j <= 7; j++){
		if(nabor[(t - j) & s_32] != nabor[(t + j) & s_32]) return;
	}
	vyvod(primes[i - s_25], nabor, st + 8, s_16);
	for(int j = 8, t = centr + st; j <= centr; j++){
		if(nabor[(t - j) & s_32] != nabor[(t + j) & s_32]) return;
		vyvod(primes[i - s_18 - j], nabor, st + s_16 - j, s_16 + ((j - 7) << 1));
	}
}
inline void proverka_nch(int nabor[], int st, int i){
	for(int j = 0, t = centr + st; j <= 7; j++){
		if(nabor[(t - j) & s_32] != nabor[(t + j + 1) & s_32]) return;
	}
	vyvod(primes[i - s_25], nabor, st + 8, s_17);
	for(int j = 8, t = centr + st; j <= centr; j++){
		if(nabor[(t - j) & s_32] != nabor[(t + j + 1) & s_32]) return;
		vyvod(primes[i - s_18 - j], nabor, st + s_16 - j, s_17 + ((j - 7) << 1));
	}
}
inline void prov_nach(int nabor[], int i, int k){
	for(int j = 0; j < (i >> 1); j++) if(nabor[k + j] != nabor[i - 1 + k - j]) return;
	vyvod(primes[k], nabor, k, i);
}

int main(){
	setlocale(LC_CTYPE, "rus");
	system("cls");
	kursor.skrytq();
	cout << "Поиск ассоциативных наборов простых";
	kursor.pomestitq(koord[vremya]);	
	cout << "0:00:00";
	hpotok = CreateThread(NULL, 0, potok, NULL, 0, &idpotok);	
	idTimer = SetTimer(NULL, 1, 2000, TimerProc);
	MSG msg;	
	while(true){
		GetMessage(&msg, NULL, 0, 0);
		DispatchMessage(&msg);
	}	
	return 0;
}

DWORD __stdcall potok(void*){
	ifstream fin("start.txt");
	if(fin) fin >> start;
	fin.close();
	start &= 0xfffffffffffffffe;
	while(vypolnitq());
	KillTimer(NULL, idTimer);
	Sleep(100);
	cout << "\n\nДостигнут максимум " << max_stop << "\nДля выхода нажмите любую клавишу . . .\n";
	system("pause > nul");
	kursor.pokazatq();
	exit(0);
	return 0;
}

void __stdcall TimerProc(HWND, UINT, UINT, DWORD){
	vremya_vyvod();
	if(pros) inf_pros();
	if(provr) inf_provr();
	if(otobr) inf_otobr();
	kursor.pomestitq(koord[konec]);
}

bool vypolnitq(){
	if(start >= max_stop) return false;
	endint = min(start + dlina_intervala, max_stop);
	if(!otobr) otobr = true;
	pros = true;	
	poisk = false;
	primes.clear();
	nachtik = clock();
	primesieve::generate_primes(start, endint, &primes);
	if(primes.size() <= s_16) return false;
	int nabor[s_33];
	if(!init(nabor)) return false;
	proverka(nabor);
	return true;
}

bool init(int nabor[]){
	static bool inicial;
	if(inicial){
		if(primes.size() <= s_33){
			if(primes.size() == s_33) prov_ne_poln(nabor);
			return false;
		}
		for(int i = 0; i < s_33; i++) nabor[i] = int(primes[i + 1] - primes[i]);
	}else{
		if(primes.size() <= s_33){
			prov_nach_ne_poln(nabor);
			return false;
		}
		for(int i = 0; i < s_33; i++) nabor[i] = int(primes[i + 1] - primes[i]);
		for(int i = s_16; i <= s_30; i++)
			for(int k = 0; k < max_smew - ((i + 1) >> 1); k++) prov_nach(nabor, i, k);
		inicial = true;
	}
	return true;
}

void proverka(int nabor[]){
	poisk = provr = true;
	int st = 0;
	for(size_t i = s_33;; i++){
		proverka_ch(nabor, st, i);
		proverka_nch(nabor, st, i);
		if(i >= primes.size() - 1) break;
		nabor[st] = int(primes[i + 1] - primes[i]);	
		st = (st + 1) & s_32;
		progress = i;
	}
	speed = int(7200000.0 / (clock() - nachtik) + 0.5);
	start = primes[primes.size() - s_33] - 1;
	ofstream fout("start.txt");
	fout << start;
	fout.close();
}

//s_17 - ((shablon + 1) >> 1)

void vyvod(long long  stprime, int nabor[], int st, int shablon){
	ostringstream imya;
	imya << "kpppch_" << (shablon + 1) << ".txt";
	ofstream fout(imya.str(), ios::out | ios::app);
	fout << stprime << ": 0";
	for(int i = 0, sum = 0; i < shablon; i++) fout << ' ' << (sum += nabor[(st + i) & s_32]);
	fout << endl;
	najdeno[shablon - s_16]++;
}

void prov_ne_poln(int nabor[]){
	for(int i = 0; i < s_32; i++) nabor[i] = int(primes[i + 1] - primes[i]);
	for(int i = s_16; i <= s_31; i++){
		for(int j = s_16 - ((i + 1) >> 1); j <= s_20 - ((i + 2) >> 1); j++){
			for(int k = 0; k < (i >> 1); k++){if(nabor[k + j] != nabor[i - 1 - k + j]) goto next;}
			vyvod(primes[j], nabor, j, i);
next:		;
		}
	}
}

void prov_nach_ne_poln(int nabor[]){
	int raz = primes.size() - 1;
	for(int i = 0; i < raz; i++) nabor[i] = int(primes[i + 1] - primes[i]);
	for(int i = s_16; i <= raz; i++){
		for(int j = 0; j <= raz - i; j++){
			for(int k = 0; k < (i >> 1); k++){if(nabor[k + j] != nabor[i - 1 - k + j]) goto next;}
			vyvod(primes[j], nabor, j, i);
next:		;
		}
	}
}

The program is written in C++.
Therefore, this path is suggested for those who know the C++ language well.

In our BOINC project SPT, another version of this program is running, it differs from the version shown in the assortment of tuples we are looking for.
The version shown looks for tuples of lengths 16 - 33.
For my algorithm, this is quite enough.

this path is suggested for those who know the C++ language well.

Next, I will tell you how to change this program for my algorithm.
ID: 422 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote
Natalia Makarova
Volunteer moderator
Project administrator
Project developer
Project tester
Avatar

Send message
Joined: 14 Jun 23
Posts: 321
Credit: 280,293
RAC: 0
Message 423 - Posted: 27 Aug 2023, 22:05:24 UTC
Last modified: 27 Aug 2023, 22:07:14 UTC

I'll tell you how the Belyshev's program works.

The starting point of the checked range is set, for example: 7900284711475208887.
Starting from this point, an interval of length 2,000,000,000 is fixed.
In this interval, primesieve program generates all prime numbers.

Next, in the array of these prime numbers, symmetric tuples of lengths 16 - 33 are searched.
We do not need this search!

We will look for other tuples.

So, in the program, everything that concerns the search for tuples in the generated array of prime numbers must be thrown out.

If you can set this point in the program, we can move on.

PS. In the program, the search continues in portions, then prime numbers are generated in the next interval of length 2,000,000,000 and everything repeats.
ID: 423 · Rating: 0 · rate: Rate + / Rate - Report as offensive     Reply Quote

Message boards : Science : Problem for programmers

©2024 Natalia Makarova & Alex Belyshev & Tomáš Brada