Remove algebraic loop without delay
1 回表示 (過去 30 日間)
I have an algebraic loop in my Simulink scheme. Actually, it only generates a warning and the system runs perfectly fine anyway, because the solver is able to solve such a loop somehow.
The problem is that this causes a huge increment of the computational time for the simulation, that I cannot afford. Hence, I must remove the algebraic loop.
But the usual way of adding a delay in the scheme is not a solution, since it (correctly removes the loop, but) adds some dynamics to the system that does not make it work as it should.
How can I solve this problem?
回答 (1 件)
John D'Errico 2023 年 9 月 18 日
編集済み: John D'Errico 2023 年 9 月 18 日
I don't know for sure how Simulink resolves the issue internally, but the answer seems straightforward. Consider the equation
x = 2*x + 3
You want to solve for x. Now the trivial solution is to perform algebra, since this is effectively an algebraic problem. And that equation is a trivial one to solve. But suppose it were slightly more complex?
x = tan(x) + 3
this is now a problem that has no algebraic solution. We can use a numerical solver to resolve it of course. BUT THAT ADDS TIME. How could it not?
The thing is, Simulink is not smart enough to resolve when a trivial algebraic operation could solve the problem. How could it? Simulink does not do symbolic algebra. And so, Simulink MUST resort always to a numerical solver. Yes, some of the time it will converge rapidly. But there is no assurance. And no matter what, it will be far less efficient than a simple, direct computation.
The trick of adding a delay sort of works, almost, because often it might be the case where x is slowly varying. Now it may cost us little to change the problem to something like
x(i+1) = f(x(i))
No algebraic loop anymore. But potentially different fundamental behavior.
I'd suggest the answer is to remove the implicit loop you have created. In the first case, you would have something as simple as:
x = -3
In the second case, as I said, there is no solution to that problem. At least, none besides the use of a solver, a root finder.
Sometimes difficult problems take time to solve. Then the solution often reduces to getting a faster computer.