Integrate stateful C computations with Modelica <p>I have integrated a machine learning algorithm implemented in C with a Modelica model running in OpenModelica.</p> <p>The machine learning algorithm is in close-loop, taking as input the deviation from the target state and providing as output a control signal.</p> <p>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.</p> <p>This makes me suspect that in order to solve the model, OpenModelica needs to invoke it several times per simulation iteration.</p> <p>This is affecting the way the algorithm is learning, as it keeps state regarding its experience.</p> <p>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?</p>