Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with updating parameters #133

Open
antoniaih opened this issue Jul 18, 2024 · 6 comments
Open

Problem with updating parameters #133

antoniaih opened this issue Jul 18, 2024 · 6 comments

Comments

@antoniaih
Copy link
Collaborator

Sometimes parameters get updated. For example when adding a dataset. Or when adding a transit compartment.

This is because when the model structure is changed new parameters might be added or existing parameters might be removed. Therefore model_state.parameters is updated to include new parameters and unused ones are removed. In other words the intersection between the model_state parameters and the model parameters (the model that is being built from the model state).
Parameters that exist in both are kept as they are. So a parameter whose initial value is different in the model than in model_state.parameters is changed so that it matches the one in model_state.parameters.

The problem is to know which set is the correct one. When we always update from the model it is not possible to change parameters in the parameter tab. Ideally we would want to know if the model features have been changed and in that case set model_state.parameters = model.parameters. But we do not know if the model features have been changed since there is no memory of a previous state. We would have to evaluate this outside of the model state.

@rikardn
Copy link
Contributor

rikardn commented Jul 18, 2024

Do you mean that a modeling function might change a parameter value that overrides what the user has set in the UI?

@antoniaih
Copy link
Collaborator Author

Yes. But not only the user input but also the previous parameter state in general. I do not override existing parameters.

@rikardn
Copy link
Contributor

rikardn commented Jul 18, 2024

Ok. What do we want to happen? One strategy is to save all parameters manually input by the user and let these override whatever is created automatically. The ones that were never changed manually we can allow being changed by the model transformations.

@antoniaih
Copy link
Collaborator Author

But they cannot be saved inside the model state because then we do not know if they have been recently changed or not. A parameter changed by the user could still be updated by the modeling functions.

@rikardn
Copy link
Contributor

rikardn commented Jul 18, 2024

So we keep all changed parameters by the user and these always takes precedence (unless removed) over automatically changed parameters. So there will be a dict with user changed parameters and a set_initial_estimates will be called to keep these values. If a parameter gets removed we could consider keeping it here in case it reappears.

@antoniaih
Copy link
Collaborator Author

The current solution for this is that model_state.parameters gets reset whenever an attribute except parameters is updated.
This means that when changing anything in the model after having changed parameters will overwrite the parameters. Maybe there will be a better solution for this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants