Hello everyone,
I recently noticed an unexpected behaviour when using the scipy/MC solvers.
Summarising: when defining the forward model class, one needs to have a consistent order for the output sensor in the interface() method and in the response() output dictionary; otherwise the solver runs, but gives completely wrong results. This is not specified anywhere in the documentation and I find it counterintuitive: having a dictionary, I would not expect the order of the keys to play any role.
I briefly discussed this with @danielandresarcones and we found that instead of using the dictionary structure, the scipy solver transforms the response() output dictionary directly into a numpy array without any checks. Being both interface() and response() user-defined, there is no guarantee of order consistency, but there is no warning/error for this.
We also noted that the ordering of the experimental data dictionary does not play any role, since it is reordered upon being given to the forward model. So the experimental data ordering is always consistent with the sensor definition order.
Given this, we thought of three possible solutions:
automatically reorder the response() dictionary each time (straightforward but needs to be done for every model evaluation)
automatically reorder the output sensors (and thus consequently the experimental data) (needs to be done only once, but might create problems elsewhere?)
check the consistency of the ordering once and for all and putting out an error/warning message (quicker but requires that the user fixes the ordering by himself (but this is the current situation anyways))
What do you think? Do you have any other ideas?
Below is a python script as an example:
you have two forward models, identical but for the output sensor order in the response() output dictionary, who behave differently.
The problem for the second forward model lies in the inconsistency in the ordering of the sensors between interface() and response().
I would opt for sorting (don't think that sorting the dict with the references (the actual vectors are IMO not copied), or even use an ordered dict in python
Hello everyone, I recently noticed an unexpected behaviour when using the scipy/MC solvers. Summarising: when defining the forward model class, one needs to have a consistent order for the output sensor in the interface() method and in the response() output dictionary; otherwise the solver runs, but gives completely wrong results. This is not specified anywhere in the documentation and I find it counterintuitive: having a dictionary, I would not expect the order of the keys to play any role.
I briefly discussed this with @danielandresarcones and we found that instead of using the dictionary structure, the scipy solver transforms the response() output dictionary directly into a numpy array without any checks. Being both interface() and response() user-defined, there is no guarantee of order consistency, but there is no warning/error for this. We also noted that the ordering of the experimental data dictionary does not play any role, since it is reordered upon being given to the forward model. So the experimental data ordering is always consistent with the sensor definition order.
Given this, we thought of three possible solutions:
What do you think? Do you have any other ideas?
Below is a python script as an example: you have two forward models, identical but for the output sensor order in the response() output dictionary, who behave differently. The problem for the second forward model lies in the inconsistency in the ordering of the sensors between interface() and response().