"alarm" fails to limit calculation time in ideal primeness testing and ideal saturation

60 views
Skip to first unread message

Andrew Critch

unread,
Jul 6, 2011, 8:06:52 AM7/6/11
to maca...@googlegroups.com, Thomas Kahle, Adam Boocher
(There may be other problems with "alarm", but I'm new to Macaulay, so I wouldn't know about them...)

An earlier post,

suggests using "alarm" to limit the execution time of a command.  I've read the documentation, which is here:

This would be extremely useful when running long sequences of tests... sometimes a test takes too long, and you'd like Macaulay to skip it and move on to the next one instead of just stalling at 3am when you're asleep...

... but "alarm" fails to abort testing the primeness of an ideal, and also fails to abort computing the saturation of an ideal by an element.  It *does* work to abort the calculation of double factorials, though, so I don't think it's a problem with my syntax... here's my code, which is also attached:

---------------------------------------------------------------
restart
-- The fourth code block shows that the "alarm" command does 
-- not work to abort testing the primality of ideals,
-- at least those I'm interested in. There really should be
-- a reliable way to limit the time Macaulay spends on 
-- calculations, especially for running long seqeuences
-- of tests.

-- CODE BLOCK 1: The sequence L will index the 
-- calculations I want to do.  Typically there are over 100,
-- but here we'll just do four.
L=(2,3,4,22)

-- CODE BLOCK 2: This code defines a sequence of ideals.
-- It works fine and shouldn't need to be examined.
needsPackage"GraphicalModels"
G4_2 = digraph {{1, {2,3,4}}, {2, {3,4}}, {3, {4}},{4,{}}}
G4_3 = digraph {{1, {3,4}}, {2, {3,4}}, {3, {4}},{4,{}}}
G4_4 = digraph {{1, {4}}, {2, {3,4}}, {3, {4}},{4,{}}}
G4_22 = digraph {{1, {2}}, {2, {}}, {3, {2}},{4,{}}}
R=markovRing (2,2,2,2);
for i in L do S4_i = globalMarkov G4_i
for i in L do I_i=markovIdeal(R,G4_i,S4_i)

-- CODE BLOCK 3:  This demonstrates how "alarm" does in fact work
-- to abort calculations of double factorials of L entries:
for i in L do (
     try (alarm 1; print (i, i!!))
     else print (i, "too long")
     )

print "cancel old alarm"

-- CODE BLOCK 4:  "alarm" does NOT work to abort checking the 
-- primeness of an ideal:
for i in L do (
     try (alarm 1; print (i, isPrime(I_i)))
     else print (i, "too long")
     )

-- It also fails to abort computing saturations of ideals, so there may 
-- be other problems.  Thanks for any feedback on this!
---------------------------------------------------------------

Cheers,

--
Critch, Andrew
UC Berkeley
http://math.berkeley.edu/~critch/
alarm_problem.m2

Daniel R. Grayson

unread,
Jul 6, 2011, 11:16:27 AM7/6/11
to maca...@googlegroups.com, Thomas Kahle, Adam Boocher
If certain computations are unaffected by alarm, then presumably they are also unaffected by interrupts, and the reason is that we have a tight loop in the engine that is not checking periodically for exceptions.  We'll take a look and make that work, in the current source code.

Grayson, Daniel R.

unread,
Aug 5, 2011, 11:17:05 AM8/5/11
to maca...@googlegroups.com
It seems that "alarm", i.e., SIGALRM, no longer works at all on the trunk of the source code repository, so I'll have to fix that first!

Andrew Critch

unread,
Aug 15, 2011, 12:31:54 PM8/15/11
to maca...@googlegroups.com
Okay, please keep me informed on progress with fixing the ALARM command :)

> --
> You received this message because you are subscribed to the Google Groups
> "Macaulay2" group.
> To post to this group, send email to maca...@googlegroups.com.
> To unsubscribe from this group, send email to
> macaulay2+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/macaulay2?hl=en.
>

josephine.yu

unread,
Aug 24, 2011, 4:26:08 PM8/24/11
to Macaulay2
Is "alarm" fixed yet?

On Aug 5, 11:17 am, "Grayson, Daniel R." <d...@math.uiuc.edu> wrote:
> It seems that "alarm", i.e., SIGALRM, no longer works at all on the trunk of the source code repository, so I'll have to fix that first!
>
> On Jul 6, 2011, at 7:06 AM, Andrew Critch wrote:
>
> > (There may be other problems with "alarm", but I'm new to Macaulay, so I wouldn't know about them...)
>
> > An earlier post,
> >http://groups.google.com/group/macaulay2/browse_thread/thread/50791b0...
>
> > suggests using "alarm" to limit the execution time of a command.  I've read the documentation, which is here:
> >http://www.math.uiuc.edu/Macaulay2/doc/Macaulay2-1.4/share/doc/Macaul...

Grayson, Daniel R.

unread,
Aug 24, 2011, 6:37:15 PM8/24/11
to maca...@googlegroups.com
No, not yet.

Daniel R. Grayson

unread,
Aug 27, 2011, 12:33:27 PM8/27/11
to maca...@googlegroups.com
I think I've fixed it now, so try running "svn up" to get the latest changes from the repository and rebuild.  However, this will not be compatible with threads yet.
Reply all
Reply to author
Forward
0 new messages