Converting symbolic to MATLAB functions became 30x slower from R2018b to R2020a
2 次查看(过去 30 天)
显示 更早的评论
I have code that converts a vector-valued 16x1 symbolic function of 50 variables into a MATLAB function stored in a file:
fxout=matlabFunction(fx,'Vars',order,'File','fxfun');
In R2018b, this ran in less than 2 seconds. In R2020a, to which I just upgraded, it takes 63 seconds. I profiled both and the difference is entirely in the execution time of mupadmex, a MEX file the contents of which obviously don't get profiled. The number of calls to mupadmex is higher in R2020a too, but by 25% or so, not by 30x.
I read the Symbolic Toolbox release notes for the last few versions and nothing jumps out at me as an explanation for this.
Anyone have any ideas? I don't even know where to start... I get that this should take a bit of time since it's a complex operation. I'm ok with 2 seconds. I'm not ok with 60+ seconds, especially since I need to do a similar operation for a much larger function, which used to take 2 minutes, and, if this scales linearly, would now take 1 hour.
0 个评论
采纳的回答
Paul Williams
2020-8-18
A colleague had a similar issue with symbolic toolbox between R2018 and R2019b. I investigated this and found that the degradation happens as of R2019a Update 4. This is due to a change in the lib.tar (toolbox\symbolic\mupad\lib). Inside the tar, a function was changed that optimizes the symbolic expressions. A special case was added for single input expressions in 2019a Update 4. Specifically, GENERATE\optimize.mu, commenting out the line:
equations[k+1..-1] := flattenOneArgFunctions(equations[k+1..-1]);
and re-taring the lib file restored the pre-update performance.
3 个评论
Rik
2020-8-18
I presume by filling out the contact form, or by filing a bug report (I believe you can choose to label it as an enhancement request instead of a bug).
Alternatively you could send an email to a Mathworks employee you may have had contact with and ask them to forward it to the correct department. But filling out the contact form is clearly more polite.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!