Use properties to transform `ForEachObject` inputs
We currently convert parameters given in the Instrument
's init method (can be strings for default or pre-defined values, scalar values when shared between all MOSAs or SC, or a dictionary, or a ForEachObject
instance) to a ForEachObject
instance.
This breaks when the user modifies the Instrument
instance after initialization.
Two solutions:
- We can use properties to make sure that we correctly set those attributes at all times (performing verifications and conversions, maybe even reading and interpolating files).
- Verifications, conversions and other pre-processing steps are performed multiple times if one changes the parameters multiple times before running the simulation.
- On the other side, parameters are valid at all times (we check then when they are set). This means that users don't have to run simulations to see error messages.
- We can prevent users to mutate parameters once the simulation has been run (and prevent potential mismatches between simulation results and parameters in the
Instrument
instance).
- Or delay those steps to simulation time, and only keep raw parametrization until
simulate()
is called.- Only perform verifications, conversions and others once before simulation.
- Initialization and parametrization are computationally inexpensive. All the heavy lifting is performed in
simulate()
.
Edited by Jean-Baptiste Bayle