Remove algebraic loop without delay

1 回表示 (過去 30 日間)
Ale_798 2023 年 9 月 18 日
コメント済み: Paul 2023 年 9 月 19 日
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 件のコメント
Paul 2023 年 9 月 19 日
Hi Ale_798,
The first question to be answered is whether or not an algebraic loop is expected for the actual system you're trying to model. Sometimes, an algebraic loop is expected. But most of the time (in my own experience) an algebraic loop results from an improper or approximate represenation of the underlying system. Does the existence of the algebraic loop make sense for the system you're trying to model?


回答 (1 件)

John D'Errico
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.
  1 件のコメント
Ale_798 2023 年 9 月 18 日
Thanks for your answer. Then, it seems I have no alternatives but keeping the algebraic loop and waiting for the solver to do its work.
Since I cannot eliminate my problem, how could I at least minimize it? That is, what is the faster solver I can choose in the Model Settings? And are there other precautions I could take to this purpose?



Help Center および File ExchangeConfigure Simulation Conditions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by