Opened 6 years ago

Closed 6 years ago

#5103 closed defect (worksforme)

CompositeModel::solveAlgLoop: max. number of iterations

Reported by: Boldizsár Németh <nboldi@…> Owned by: Lennart Ochel
Priority: high Milestone: 1.13.0
Component: OMSimulator Version: v1.13.0-dev-nightly
Keywords: Cc:

Description

While trying to simulate two connected FMUs, I got the following error.

nboldi@nboldi-VirtualBox:~/OMSimulator$ build/linux/src/OMSimulator/OMSimulator ../moonlander.lua
info:	New temp directory: "/home/nboldi/OMSimulator/temp"
# FMI composite model "model"
## FMI sub model "Lander"
type: FMU
## FMI sub model "World"
type: FMU
## Connections
model: World:h -> Lander:h
model: World:v -> Lander:v
model: Lander:u -> World:u
warning: Alg. loop (size 3)
error:   CompositeModel::solveAlgLoop: max. number of iterations (10) exceeded at time = 0.000000
info:	Result file: results.mat (bufferSize=1)
error:   failed to fetch variable Lander:u
error:   Failed to log simulation results
MoonLander::InitToFF
MoonLander::FFtoControlled
Segmentation fault (core dumped)

The FMUs World and Lander are connected. There is one variable from Lander to World (u) and two variables from World to Lander (h and v).

After initialization, Lander outputs 0 for u, and World returns 1000 and 0 for h and v. They should return the same value for repeated calls regardless of the inputs they are given. I checked this behavior by simulating individual FMUs.

Since the FMUs were generated from different sources, it is possible that they are unconventional in some way. Could you suggest what can be the problem behind the errors?

Attachments (4)

MoonLander.fmu (637.3 KB ) - added by Boldizsár Németh <nboldi@…> 6 years ago.
WorldModel.fmu (18.0 KB ) - added by Boldizsár Németh <nboldi@…> 6 years ago.
moonlander.lua (526 bytes ) - added by Boldizsár Németh <nboldi@…> 6 years ago.
moonlander_outputs.png (16.3 KB ) - added by Lennart Ochel 6 years ago.
Alg. loop (size 3)

Download all attachments as: .zip

Change History (17)

comment:1 by Lennart Ochel, 6 years ago

I don’t quite get the issue. Do you expect an algebraic loop when connecting the two FMUs? Can you provide the FMUs for testing? What tool did you use to generate the FMUs?

And did you run the example with the latest version of OMSimulator or which version did you use?

by Boldizsár Németh <nboldi@…>, 6 years ago

Attachment: MoonLander.fmu added

by Boldizsár Németh <nboldi@…>, 6 years ago

Attachment: WorldModel.fmu added

by Boldizsár Németh <nboldi@…>, 6 years ago

Attachment: moonlander.lua added

comment:2 by Boldizsár Németh <nboldi@…>, 6 years ago

I attached the models and the lua script that loads them. I do not quite understand algebraic loops, I expected the simulation to be run without errors. One of the FMUs is handwritten (WorldModel.fmu), the other is generated by txtUML (MoonLander.fmu). I'm on a commit about a month old, I will check out if the error is still present in the current master.

comment:3 by Lennart Ochel, 6 years ago

I run the model with the latest version of OMSimulator and got the following log file:

info:    Initializing logging (OMSimulator v2.0.0-dev-596-gf3c4549-linux)
info:    New temp directory has been created: "./temp/"
info:    New temp directory: "/tests/5103/temp"
warning: No solver instance is assigned to FMU "Lander"; A default solver will be selected: internal
warning: No solver instance is assigned to FMU "World"; A default solver will be selected: internal
warning: Alg. loop (size 3)
error:   CompositeModel::solveAlgLoop: max. number of iterations (10) exceeded at time = 0.000000
info:    Result file: results.mat (bufferSize=1)
error:   failed to fetch variable Lander:u
error:   Failed to log simulation results
error:   failed to fetch variable Lander:u
error:   Failed to log simulation results
info:    Removed model from scope: model
info:    Logging completed properly

Apparently, it is not possible to fetch signal Lander:u. I guess this is an issue with the FMU itself. Can you please verify this?

Last edited 6 years ago by Lennart Ochel (previous) (diff)

by Lennart Ochel, 6 years ago

Attachment: moonlander_outputs.png added

Alg. loop (size 3)

comment:4 by Lennart Ochel, 6 years ago

The main issue seems to be the alg. loop. As you can see from the graph, the signals depend directly on each other and form a loop. That makes it difficult to do the communication. An iterative approach is used to handle these cases, but in your case the system diverges. Maybe you could introduce a delay to break this this loop.

comment:5 by Boldizsár Németh <nboldi@…>, 6 years ago

Thank you! Yes, I think I should add a delay. The u variable of lander should be accessible. I could read it when debugging only the Lander model.

in reply to:  5 comment:6 by Lennart Ochel, 6 years ago

Replying to Boldizsár Németh <nboldi@…>:

Thank you! Yes, I think I should add a delay. The u variable of lander should be accessible. I could read it when debugging only the Lander model.

Yes, I noticed that as well. I think the error message (failed to fetch variable Lander:u) is misleading in this case, and occurs only because the algebraic loop couldn't be solved.

comment:7 by Boldizsár Németh <nboldi@…>, 6 years ago

I tried to add the delay internally in one of the FMUs (by making doStep use previous inputs), but it didn't work. Is there a way to instruct the simulator to impose a delay on one of the FMUs?

comment:8 by Lennart Ochel, 6 years ago

No, there is no such functionality available. But you are very welcome to make a feature request: https://github.com/OpenModelica/OMSimulator/issues/new/choose

comment:9 by Boldizsár Németh <nboldi@…>, 6 years ago

Unfortunately I couldn't solve this issue over the last weeks.

My situation is:

  • My two models (World and Lander) are depending on each other with their inputs and outputs.
  • The two models are discrete in nature.
  • The models have matching initial values for their variables, h=1000, v=0 and u=0.
  • The models are constructed in a way that output values will only change when doStep is called.

How should I simulate these two models together to avoid the algorithmic loop error?

comment:10 by Lennart Ochel, 6 years ago

Sorry, that it took so long time to come back to you. I did some more investigation, and it seems not related to the alg. loop. Even without any connection between the two FMUs, the model fails with following error message:

error:   [updateSignals] failed to fetch variable u
h: 1000 v: -0.1625 u: 0 crash: 0
MoonLander::InitToFF
MoonLander::FFtoControlled
Segmentation fault (core dumped)

I think the MoonLander.fmu has internal problems.

comment:11 by Lennart Ochel, 6 years ago

Milestone: Future1.13.0
omc_version: OMSimulator v2.0.0-dev-880-ge2e7de1-linux
Version: v1.13.0-dev-nightly

in reply to:  9 comment:12 by Lennart Ochel, 6 years ago

Replying to Boldizsár Németh <nboldi@…>:

  • The models are constructed in a way that output values will only change when doStep is called.

The modelDescription.xml of both FMUs contain direct dependencies between the outputs and their inputs. That is actually where the algebraic loop is coming from. It seems that the dependency information in the FMUs are wrong.

comment:13 by Lennart Ochel, 6 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.