V2Xgithub / WiLabV2Xsim

V2X simulator
GNU General Public License v3.0
79 stars 32 forks source link

additional options for controlling simID and the main output file #24

Closed chestnutcase closed 1 year ago

chestnutcase commented 1 year ago

Hi V2Xsim maintainers,

The purpose of this pull request is to add additional options to control whether the application writes the summary of results to MainOut.xls, in addition to being able to control the name. There is also the option to manually specify the simID - if not specified, it will use the old logic of auto incrementing (if printing to main out is disabled, defaults to simID 1)

The motivation behind this is to enable parallelism such as running many simulations at once using parfeval or parfor. If you want to call WiLabV2Xsim.m in a parallel environment, the original behavior of trying to auto increment the ID will cause a race condition between the processes. In such cases, it is much more conducive to prepopulate a list of sim IDs depending on the research question being investigated, and have each simulation not write over each others' files because they might complete at different times.

chestnutcase commented 1 year ago

hi wzf,

Thank you for your changes, i think the lock file is a good idea. I think it is reasonable to assume that if an advanced user is using parfor to do parameter sweeps, he should be responsible to set unique simulationids. One would usually write helper code, the experiment runner, to use parfor, the helper code will have a better idea of what id to use. It is very difficult for an individual experiment proceess to decide on auto-increment id unless we change to randomly generated uuids.

I don't have permissions to merge, but I am okay with the current fix.