noe
noe

Reputation: 2144

Integrate stateful C computations with Modelica

I have integrated a machine learning algorithm implemented in C with a Modelica model running in OpenModelica.

The machine learning algorithm is in close-loop, taking as input the deviation from the target state and providing as output a control signal.

I have set a sampling period so that the C algorithm is only called every X millisecs. However, I am seeing that the algorithm is being called several times for the same clock values.

This makes me suspect that in order to solve the model, OpenModelica needs to invoke it several times per simulation iteration.

This is affecting the way the algorithm is learning, as it keeps state regarding its experience.

Why is OpenModelica invoking my algorithm several times per clock tick? How can I address this to not lead the learning to get confused by the multiple invocations for the same time?

Upvotes: 2

Views: 116

Answers (1)

Adrian Pop
Adrian Pop

Reputation: 4231

There are 2 ways:

  1. use an Euler solver which does not backtrack (default dassl does)

  2. use an external C function with a static variable which you set/check

Upvotes: 3

Related Questions