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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by