-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable saving the entire simulation state to disk and restoring it again #757
Comments
Suggestions for suitable storage formats are welcome. Note that according to the FMI spec, each subsimulator does its own serialisation and deserialisation, and all the co-simulator sees are binary blobs. So the format needs to support storage of arbitrary binary data. |
This is a follow-up to #765 and the final step to close #757. Here, I've implemented functionality to export the internal state of individual subsimulators in a generic, structured form, and to import them again later. This exported form is intended as an intermediate step before serialisation and disk storage. The idea was to create a type that can be inspected and serialised to almost any file format we'd like. The type is defined by `cosim::serialization::node` in `cosim/serialization.hpp`. It is a hierarchical, dynamic data type with support for a variety of primitive scalar types and a few aggregate types: strings, arrays of nodes, dictionaries of nodes, and binary blobs. (Think JSON, only with more types.)
@davidhjp01, you asked in another issue discussion whether you should start working on this issue. But as noted in the issue description, this depends on #768, which is a work currently in progress, so there is a limit to how much can be done on this yet. It might be good to start looking into suitable file formats for the saved state, though. We need some format which can store the contents of a Personally, I would prefer something which is lightweight both in terms of features, complexity, and additional dependencies, but efficiency is also a factor. I guess we can discuss where the perfect trade-off lies when we have some alternatives on the table. Once we've decided on a storage format, it is also possible to write the functions to save/load a generic |
AI generated list 😅:
|
Nice summary. Without having spent a lot of time thinking about this, I immediately lean towards the simple and efficient schema-less formats, i.e., MessagePack, CBOR, or BSON. I don't have hands-on experience with any of them, but having read a bit about them, I think CBOR looks most promising. It seems to have been designed as an improvement of MessagePack, is an IETF standard (which is good for stability and third-party support), and has multiple C++ implementations. |
I do have experience with Protocol Buffers, though, and while it is good in terms of performance and built-in versioning, I think I'd prefer to avoid the extra compilation step and use of machine-generated source code. |
I can try some of the options to find out potential candidates :) |
@davidhjp01 wrote (in what I suspect was the wrong thread?):
I like the idea. We actually used nlohmann_json in the past, but it was replaced with yaml-cpp because we wanted to support writing scenario files in YAML too (#275). YAML is a superset of JSON, so one library could support both. I'm not sure it can replace Boost PropertyTree, though. We're mainly using that to parse XML right now (in addition to Xerces-C++), and I started using it as a generic data type in #769. I don't think we're using it for JSON anywhere.
Hmm… that may be problematic. From a cursory look, it seems that the data would need to pass through a JSON-based data structure before they get converted to CBOR, and thus they lose type information. For example, JSON doesn't differentiate between signed and unsigned integer types, nor between different integer widths. Am I right, or can we keep the type information intact somehow? |
Or was that actually where you suggested replacing it, i.e. turn |
This feature is desired in the OptiStress project, where we will need to simulate the same system many times in a loop with parameter variations. It will save a lot of time since we can start each simulation from a “warmed up” state.
Depends on #756 and #768.
The text was updated successfully, but these errors were encountered: