OMSimulator icon indicating copy to clipboard operation
OMSimulator copied to clipboard

Support for FMU state management

Open rruusu opened this issue 1 month ago • 2 comments

The FMI standard defines APIs for getting and setting the internal state of FMUs using the functions:

  • fmi2GetFMUstate
  • fmi2SetFMUstate
  • fmi2FreeFMUstate
  • fmi2SerializedFMUstateSize
  • fmi2SerializeFMUstate
  • fmi2DeSerializeFMUstate

These can be used for stepping back to a previous state and serialization of the FMU state to a sequence of bytes, allowing the simulation to be continued later even when the simulator has been restarted.

These APIs are not currently supported at all by OMSimulatorLib.

If would be useful, if OMSimulatorLib would provide APIs for managing the state of the model FMUs at both the system and individual FMU levels, The system level would require that each contained FMU provides support for the APIs in question.

Returning to a previous point would enable performing operations that need repeated simulations from an earlier point, such as unscented Kalman filtering.

Serialization to a file would enable:

  • Continuation of a lengthy simulation in the case of an interruption, such as power loss.
  • Repeatedly starting simulations from a previously achieved state, such as a steady state.
    • Thus eliminating a need to repeat a potentially long starting sequence to reach the state.

There could be a command line options for:

  • Automatically storing the state at the end of the simulation, or periodically during simulation, to enable continuation.
  • Starting the simulation from a given serialized state.

rruusu avatar Nov 20 '25 13:11 rruusu