Code: Select all

`variables`

real state;

boolean changestate;

equations

changestate = event(sin(time));

if (state==1 and changestate) then state = 2;

else if (state==2 and changestate) then state = 1; end;

end;

compiling it will give you the following error: unable to break algebraic loop for (state==1 and changestate).

You might wonder which algebraic loop is meant. Well, none. The problem here is that the variable state has no initial value. So adding

Code: Select all

`initialequations`

state=1;

to the code solves the problem. It occurs quite often that this error results from an initialization that was forgotten.