Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

adding timelimit to CAS calls to integrate when CAS does not support built-in timelimit

34 views
Skip to first unread message

Nasser M. Abbasi

unread,
Jan 26, 2024, 1:48:31 AMJan 26
to
FYI;

I run some tests using different CAS systems that do not support
setting a timelimit on its calls.

For example Reduce and Fricas and Maxima and GIAC and others.

For me, timelimit() is the most important function, as without
it, it is very easy to make any CAS hang. Yet, strangely
open source CAS systems do not have such a basic function as
a built-in.

They do not have a direct way to insure a call to some command
such as integrate should not take more than say 30 seconds and
to return an error if the call exceeds this timelimit.

Commercial CAS systems Maple and Mathematica have an easy to use
built-in command for this. This document is meant to describe how
to add timelimit to other systems that do not support this.

This method only works and have been tested on Linux.

I found this method to be reliable and works well. It is
based on using the Linux command timeout and using
Python's subprocess.Popen().

Python is used as the main driver for all these scripts.

<https://12000.org/my_notes/faq/time_out_cas/index.htm>

--Nasser

nob...@nowhere.invalid

unread,
Jan 26, 2024, 3:45:00 AMJan 26
to

"Nasser M. Abbasi" schrieb:
>
> I run some tests using different CAS systems that do not support
> setting a timelimit on its calls.
>
> For example Reduce and Fricas and Maxima and GIAC and others.
>
> For me, timelimit() is the most important function, as without
> it, it is very easy to make any CAS hang. Yet, strangely
> open source CAS systems do not have such a basic function as
> a built-in.
>
> They do not have a direct way to insure a call to some command
> such as integrate should not take more than say 30 seconds and
> to return an error if the call exceeds this timelimit.
>

Presumably nobody felt the need for this back when these systems were
conceived because they were meant for console operation and a
computation could always be interrupted with Control-C or similar.

>
> [...]
>

Martin.

Nasser M. Abbasi

unread,
Jan 26, 2024, 4:11:54 AMJan 26
to
Ok, but isn't the birth of Mathematica and Maple is around same
time frame as these other open source CAS systems? Mathematica
was born in 1988, and Maple in 1982. Sure, Reduce and Maxima
and Fricas are few years older, but not by much. May be 10 years?

Sympy is also a much younger CAS than all of them and it
has no timelimit() command. Also mupad has no timelimit()
built-in and I had to do many ticks in Matlab to implement it.

In Mathematica, TimeConstrained has date of 1988 on it.

<https://reference.wolfram.com/language/ref/TimeConstrained.html>

Also, open source CAS systems had all the time to add
such a built-in function since the 1970's or 1980's?

Btw, Maple timelimit() also has some problems I complained
about before. It does not always work (i.e. terminate
the call at the time requested). I could ask for 30 seconds
time limit, and it could terminate after 5 minutes or 10.

So even Maplesoft still needs to work/improve its
timelimit() function.

I found Mathematica's TimeConstrained function very robust
and always works and stops the call at the time limit requested.

--Nasser

>>
>> [...]
>>
>
> Martin.

Nasser M. Abbasi

unread,
Jan 26, 2024, 2:59:44 PMJan 26
to
Fyi;

I was told that Fricas now has timeout which is good. I did not
know about it. First open source CAS to have timeout !

https://fricas.github.io/api/TimeoutPackage.html#index-1

----------------
eval_with_timeout: (() -> S, Integer) -> Union(S, failed)
eval_with_timeout(f, t) calls f with timeout of t seconds.
Returns value computed by f or “failed” if f did not finish within t seconds.
-------------------

--Nasser
0 new messages