jakobaxelsson / sossim

A system-of-systems (SoS) simulator
MIT License
0 stars 0 forks source link

Better approach to handling configurations #12

Closed jakobaxelsson closed 12 months ago

jakobaxelsson commented 1 year ago

Configurations are parameters that control the model generation and simulation. The parameters have default values, that can be updated in batch mode using the command line interface, and in interactive mode using dialogues. In the future, it would also be nice to be able to save a configuration to file, and to reload it later.

Currently, the configuration is handled as parameters to the init functions of different classes. A better approach would be to instead have a Configuration class that gathers all the parameters in one place, together with meta information that can be used to generate both the command line interface and the UI dialogs. The whole configuration can be passed to class init's, who extract whatever they are interested in from there. The class can also have methods for saving and loading itself from files.

jakobaxelsson commented 12 months ago

A partial implementation is ready. It handles the model generation and UI parts. However, some things remain to do:

jakobaxelsson commented 12 months ago

The handling of configurations should be refined to keep parameter metadata and actual values in two separate dictionaries. The metadata should be in a class attribute, so the same for all instances. This means that adding parameters can be done in the classes that actually use those parameters, which is more logical. The parameter values are stored in each configuration object, and it is this data that is serialized, which solves the JSON problem.

jakobaxelsson commented 12 months ago

Configurations have been revised to separate metadata and data. This also means than JSON input and output of instance data now works. Parsing command line arguments has also been revised to (mostly) use the configuration class.