Dear Carl, This function is provided in IO 4.7, which is distributed with gap 4.11 (the latest release). I'm not positive exactly when it was added.
Chris From: Carl-Fredrik Nyberg Brodda (MTH - Postgraduate Researcher) <c.nyberg-bro...@uea.ac.uk> Sent: 28 January 2021 10:31 To: Christopher Jefferson <ca...@st-andrews.ac.uk>; Frank Lübeck <frank.lueb...@math.rwth-aachen.de> Cc: forum@gap-system.org Subject: Re: [GAP Forum] Run GAP command for x seconds Hi, Chris: I cannot seem to load the function IO_CallWithTimeout, or indeed IO_CallWithTimeoutList -- there seems to be no function with this name. I have IO 4.5.2 loaded. Frank: Your code runs fine, but when I run e.g the following code > ParTakeFirstResultByFork([function(x) local F; F := FreeGroup(x); return F; > end], [[1]],rec(TimeOut :=rec(tv_sec :=2, tv_usec := 0 ))); this makes my GAP go haywire and totally breaks it, forcing me to restart it (it finishes the computation 2 seconds later, though...). It should just return FreeGroup(1), of course). I get the error message "No 1st choice method found for IO_Pickle", which, as delicious as it sounds, doesn't tell me much. Perhaps I am doing something wrong? It doesn't seem to break if I do, say, "F := x^2" instead of "F := FreeGroup(x)", so it's quite a mystery to me. "F := FreeMonoid(x)" also breaks it. The problem seems to be with calling any function inside these functions... Here is the full error message. I am using Linux. Error, no method found! For debugging hints type ?Recovery from NoMethodFound Error, no 1st choice method found for `IO_Pickle' on 2 arguments at /usr/local/gap-4.9.3/lib/methsel2.g:250 called from IO_Pickle( j.childtoparent, ret ); at /usr/local/gap-4.9.3/pkg/io-4.5.2/gap/background.gi:110 called from BackgroundJobByForkChild( j, fun, args ); at /usr/local/gap-4.9.3/pkg/io-4.5.2/gap/background.gi:85 called from BackgroundJobByFork( jobs[i], args[i], rec( ImmediatelyTerminate := true ) ) at /usr/local/gap-4.9.3/pkg/io-4.5.2/gap/background.gi:283 called from <function "unknown">( <arguments> ) called from read-eval loop at *stdin*:8 Best, Carl-Fredrik ________________________________ From: Christopher Jefferson <ca...@st-andrews.ac.uk<mailto:ca...@st-andrews.ac.uk>> Sent: Thursday, January 28, 2021 9:28 AM To: Frank Lübeck <frank.lueb...@math.rwth-aachen.de<mailto:frank.lueb...@math.rwth-aachen.de>>; Carl-Fredrik Nyberg Brodda (MTH - Postgraduate Researcher) <c.nyberg-bro...@uea.ac.uk<mailto:c.nyberg-bro...@uea.ac.uk>> Cc: forum@gap-system.org<mailto:forum@gap-system.org> <forum@gap-system.org<mailto:forum@gap-system.org>> Subject: RE: [GAP Forum] Run GAP command for x seconds Warning: This email is from outside the UEA system. Do not click on links or attachments unless you expect them from the sender and know the content is safe. Hi, I agree with Frank. There is an alternative function (which uses the same underlying mechanism) -- IO_CallWithTimeout (and IO_CallWithTimeoutList, which just takes the function arguments as a list). IO_CallWithTimeout(rec(seconds := 2), Intersection, AlternatingGroup(20), AlternatingGroup(20)*(1,2)); (note that IO_CallWithTimeout uses different names for the times, seconds in this case). After about 2 seconds outputs [ false ] Chris -----Original Message----- From: Frank Lübeck <frank.lueb...@math.rwth-aachen.de<mailto:frank.lueb...@math.rwth-aachen.de>> Sent: 27 January 2021 18:19 To: Carl-Fredrik Nyberg Brodda (MTH - Postgraduate Researcher) <c.nyberg-bro...@uea.ac.uk<mailto:c.nyberg-bro...@uea.ac.uk>> Cc: forum@gap-system.org<mailto:forum@gap-system.org> Subject: Re: [GAP Forum] Run GAP command for x seconds On Wed, Jan 27, 2021 at 04:54:03PM +0000, Carl-Fredrik Nyberg Brodda (MTH - Postgraduate Researcher) wrote: > Thank you for your response. I am having trouble getting the timeout > to work. Do you have an example of using the timeout? > > I have attempted to pass the last (third, optional) argument of > ParTakeFirstResultByFork as rec(TimeOut := rec(tv_sec :=2, tv_usec := > 0)), hoping for my execution to run for 2 seconds, but this does not > work (it never times out). I have also tried setting the tv_sec record > to be the current time (plus 10 seconds or so), but this does not time out > either. Hi, This looks correct and it works for me, for example: gap> Runtimes(); ParTakeFirstResultByFork([function(x) while true do gap> od; end], [[1]],rec(TimeOut := rec(tv_sec :=2, tv_usec := 0 ))); gap> Runtimes(); rec( system_time := 90, system_time_children := 15, user_time := 1103, user_time_children := 3985 ) [ ] rec( system_time := 94, system_time_children := 15, user_time := 1103, user_time_children := 5984 ) I'm only using Linux systems. Some functions of the IO package may not work as expected when GAP is used in Windows (but I don't know the details). Best regards again, Frank Lübeck > Best, > Carl-Fredrik Nyberg Brodda > ________________________________ > From: Frank Lübeck > <frank.lueb...@math.rwth-aachen.de<mailto:frank.lueb...@math.rwth-aachen.de>> > Sent: Wednesday, January 27, 2021 3:53 PM > To: Carl-Fredrik Nyberg Brodda (MTH - Postgraduate Researcher) > <c.nyberg-bro...@uea.ac.uk<mailto:c.nyberg-bro...@uea.ac.uk>> > Cc: forum@gap-system.org<mailto:forum@gap-system.org> > <forum@gap-system.org<mailto:forum@gap-system.org>> > Subject: Re: [GAP Forum] Run GAP command for x seconds > > On Wed, Jan 27, 2021 at 02:53:14PM +0000, Carl-Fredrik Nyberg Brodda (MTH - > Postgraduate Researcher) wrote: > > Hi all, > > > > A problem which I recently stumbled upon is the following: is there > > a way to execute a given GAP command only for a certain amount of > > time, before stepping past the command and continuing execution? > > > > Let us say I have a table of finitely many finitely presented > > groups, and wish to see whether GAP has a "naive" solution for their > > word problem. I find a KnuthBendixRewritingSystem() of the group, > > and then run > > MakeConfluent() on this rewriting system. Of course, this process > > may not terminate at all! But sometimes it does. My problem is > > essentially that I wish to run MakeConfluent() for some amount of > > time (say 5 seconds), and then, if the command has not terminated, > > continue on with the next group. This avoids all decidability > > issues, and would in other programming languages be easily implemented with > > a timer. > > > > Of course the problem is general, so the above is just a use-case. > > Is there something that can help with this? > > > > Best, > > Carl-Fredrik Nyberg Brodda > > Dear Forum, > > I have used successfully the function > ParTakeFirstResultByFork > from the IO package for this kind of applications. > It has an optional third argument which allows to specify a timeout. > > Best regards, > Frank -- /// Dr. Frank Lübeck, Lehrstuhl für Algebra und Zahlentheorie, \\\ Pontdriesch 14/16, 52062 Aachen, Germany /// E-mail: frank.lueb...@math.rwth-aachen.de<mailto:frank.lueb...@math.rwth-aachen.de> \\\ WWW: https://eur01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.math.rwth-aachen.de%2F~Frank.Luebeck%2F&data=04%7C01%7CC.Nyberg-Brodda%40uea.ac.uk%7C4a7f3000673e461268c208d8c36f0b70%7Cc65f8795ba3d43518a070865e5d8f090%7C0%7C0%7C637474228991796377%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=fV1tnoVE4trQswORvGyM%2FPWZ62gjcbFj1fqiaBe9Yw8%3D&reserved=0 _______________________________________________ Forum mailing list Forum@gap-system.org<mailto:Forum@gap-system.org> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.gap-system.org%2Fmailman%2Flistinfo%2Fforum&data=04%7C01%7CC.Nyberg-Brodda%40uea.ac.uk%7C4a7f3000673e461268c208d8c36f0b70%7Cc65f8795ba3d43518a070865e5d8f090%7C0%7C0%7C637474228991796377%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=qqRY6icBsrlUpdQ8s9HpNE3MviNrgzWttP4G4XOuNrs%3D&reserved=0 _______________________________________________ Forum mailing list Forum@gap-system.org https://mail.gap-system.org/mailman/listinfo/forum