(There may be other problems with "alarm", but I'm new to Macaulay, so I wouldn't know about them...)
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!