davidrmiller / biosim4

Biological evolution simulator
Other
3.1k stars 435 forks source link

Generalized syntax for specifying an automatic parameter value change #39

Closed apatho closed 2 years ago

apatho commented 2 years ago

Inspired by the replaceBarrierType and replaceBarrierTypeGenerationNumber parameters, I wanted to have the option to change any runtime changable parameter automatically at a given generation number. Building on the automatic ini file reloading system, I came up with a generalized syntax for this without the need to add extra parameters: if you specify an existing parameter in the ini file and append "@123" to the parameter name, the new value will supersede the original value after generation 123. You can specify any number of value changes for the same parameter like this (e.g. make the value change at generation 100, 200, 400, etc.), the only limitation is that the generation specifiers (the "@ part) have to be in ascending order (higher generation numbers after lower) - this limitation could be removed but that would complicate the currently very simple implementation a bit.

I removed the original replaceBarrierType and replaceBarrierTypeGenerationNumber parameters since their function can be easily replicated via the new syntax.

davidrmiller commented 2 years ago

Very clever! I love how general it is.

venzen commented 2 years ago

This change is interesting and generally useful. The '@123' notation is compatible with the INI file standard.

From a testing perspective (using Python), a series of '@' parameters can be converted to a list and processed after the simulation completes.

Alternatively, and this remains true irrespective of this PR change, new parameter values can still be effected by changing values in the INI file on-the-fly, right?