How to implement a timeout on simplify() ?

4 visualizzazioni (ultimi 30 giorni)
Imran Khan
Imran Khan il 2 Set 2024
Modificato: Imran Khan il 5 Set 2024
I want to use a timeout on the simplify() function. I think this functionality exists using the 'seconds' option. From MATLAB help: "Time limit for the simplification process, specified as the comma-separated pair consisting of 'Seconds' and a positive value that denotes the maximal time in seconds."
But for some reason this doesn't seem to be working. For example, when I have a rather long symbolic expression as given in the attached file (exceeded character limit for the question form), and try to run:
simplify(blah,'Seconds',5)
This just keeps running without timing out.
Am I doing something wrong? Is there some way to specify a timeout for the simplify() function?
  7 Commenti
Walter Roberson
Walter Roberson il 3 Set 2024
Seconds is meant for timeout.
In practice, it is impractical to check the timer at each low-level step. In practice, the code recurses through expressions. Potentially it might check the timer each time it recurses, or after each significant step. But the problem is your expressions are complicated, and even digging into the children a fair ways gets you expressions that are hard to simplify. You have sums of sines and cosines, and pattern matching needs to be done on each potential grouping of sine and cosine in each expression, because of possible trig reductions.
sin(A) + sin(B) + cos(C) + cos(D)
has to check {sin(A), sin(B)}, {sin(A), cos(C )}, {sin(A), cos(D)}, {cos(C }, cos(D)} for potential reductions. But you have whole series of them in each expression... Probably the program is trying to reduce the entire sum, taking a long time at it, and not checking the timer until after it is done.
Imran Khan
Imran Khan il 4 Set 2024
@Walter Roberson, thanks for your detailed explanation of how the timer is likely working internally - it makes me think that this is an issue to escalate to support. That is, if something can be done about it.

Accedi per commentare.

Risposte (1)

Imran Khan
Imran Khan il 5 Set 2024
Modificato: Imran Khan il 5 Set 2024
Contacted MATHWORKS support. This is a known issue under Windows 10. Fixed in MATLAB 2023Rb Release 6.

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by