Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simulink 'trouble solving algebraic loop' error -- need help

1,672 views
Skip to first unread message

Kate J.

unread,
Oct 13, 2011, 3:47:29 PM10/13/11
to
I have a Simulink model that includes a biomechanical model block (takes muscle activation values as inputs & returns joint angles as outputs), as well as a controller block that calculates inputs to the biomechanical block (controller block inputs joint angles & other variables, and outputs muscle activation values). The outputs of the biomechanical block are fed back into the controller block as inputs. I have verified that these 2 blocks individually work without problems. However, when I try to run this model with both blocks and their feedback connections, I get the error message:

Trouble solving algebraic loop containing 'myModel/biomech_model' at time 0. Stopping simulation. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)

I have already tried to reduce the step size, but this hasn't helped, and I continue to get the error message above. I also assigned names to all of the signals going into and coming out of both blocks, and have created a text file that assigns values to each of these variables; I run the text file before I try to run the Simulink model. However, I continue to get the error message above.

I'll note that I have a real-time block in this model; the error message above results, whether the real-time block is present or removed from the model.

Update: When I added Rate Transition blocks to the outputs of the biomechanical model block, the model actually ran for ~2 seconds; but then it stops, and gives the same error message as above (except that it cites "time 0.11"). So, the Rate Transition blocks resulted in a minor improvement, but the model still terminates in error.

Does anyone have suggestions about why my Simulink model that now contains these 2 blocks connected together in a feedback relationship, which blocks *individually* work with no problems, gives me the error message above when I run it? Thanks for your input.

Phil Goddard

unread,
Oct 14, 2011, 8:46:28 PM10/14/11
to
Have you looked in the section of the documentation that describes algebraic loops and how they are handled by Simulink?

The link is:
http://www.mathworks.com/help/toolbox/simulink/ug/f7-8243.html?#f7-19688

In summary, at every time step Simulink is solving an optimization problem that attempts to find signal values so that the input and output of the blocks in the algrebraic loop are consistent.
In your case it is having difficulty doing that and you need to try one of the suggestions in the documentation.

From your previous posts I think you use your model in a real-time system.
Note that Simulink Coder (formerly Real-time Workshop) will not work with models containing algebraic loops so you will need to get rid of the algrebraic loop -- simply making the step size smaller (even if it did work for the simulation) would not work for the real-time code.

Phil.

Saurabh Mahapatra

unread,
Oct 15, 2011, 1:04:12 PM10/15/11
to
Please put in a zero order delay to resolve this. An "algebraic" loop is the natural consequence of flow graph execution in time. An additional constraint is needed to remove the ambiguity "what should be computed first at a time step" much like the "chicken-egg" paradox. The unit delay will force one part of the loop to look back in time and use the previous value. Graphical representation and execution are not the same thing.

Saurabh Mahapatra

unread,
Oct 15, 2011, 1:14:10 PM10/15/11
to
I meant unit delay block.

Kate J.

unread,
Oct 17, 2011, 1:01:29 PM10/17/11
to
Thanks for your suggestions, Phil and Saurabh. A few updates and follow-up questions:

~ Phil, you're correct that I *had* been using xPC Target with this system; however, due to problems with my biomechanical model-block apparently not being able to run correctly with xPC Target (was generating all NAN values) in my Target Simulink model, I decided to try moving the biomechanical model block over to my Host Simulink model, and to completely eliminate my use of xPC Target & Real-Time Workshop.
-- Instead, to achieve real-time functionality, I'm simply using a real-time block within my Host Simulink model. This shouldn't cause a problem, should it?

~ Saurabh, I added Unit Delay blocks into the signal-paths of the 4 outputs of my biomechanical model block, as well as the 6 outputs of my controller block (which are the inputs to my biomechanical model block). However, I still continue to get the same error message:
"Derivative input 3 of 'Host_model/biomech_model' at time 0.135 is Inf or NaN. Stopping simulation. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)."

-- what confuses me is that the biomech_model block takes 6 inputs, each of which is a regular *double* value; there are no derivative inputs to that model block. Could this be causing the problem?

~ I followed the advice within the Algebraic Loops documentation page, and ran the Simulink Debugger, & used the "ashow" command to display the algebraic loops; however, the message I get is, "No Algebraic loop found."
-- Any explanations about why I'm receiving this "no algebraic loop found" message, if there *is* an apparent algebraic loop in my model?

Thanks.

David Lagarejo

unread,
Aug 21, 2013, 3:42:09 PM8/21/13
to
"Kate J." wrote in message <j7hn19$qh7$1...@newscl01ah.mathworks.com>...
Hi, I use the Memory Block... this is solution... Ok Regards

Kate J.

unread,
Aug 26, 2013, 12:30:12 PM8/26/13
to
> Hi, I use the Memory Block... this is solution... Ok Regards

Thanks for your suggestion, David. I'll look into implementing it if it becomes necessary for my project (which has now moved onto a different stage). Thanks!

razieh

unread,
Oct 15, 2014, 2:04:40 AM10/15/14
to
hi
now I have similar proplem.
now I have a biomechanical problem and I have these error how can to solve it
I used memory block.......



0 new messages