How to implement a timeout on simplify() ?

4 ビュー (過去 30 日間)
Imran Khan
Imran Khan 2024 年 9 月 2 日
編集済み: Imran Khan 2024 年 9 月 5 日
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 件のコメント
Walter Roberson
Walter Roberson 2024 年 9 月 3 日
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 2024 年 9 月 4 日
@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.

サインインしてコメントする。

回答 (1 件)

Imran Khan
Imran Khan 2024 年 9 月 5 日
編集済み: Imran Khan 2024 年 9 月 5 日
Contacted MATHWORKS support. This is a known issue under Windows 10. Fixed in MATLAB 2023Rb Release 6.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by