Draft: Simplify Parameter init for FreeVariables#246
Draft: Simplify Parameter init for FreeVariables#246maxdinkel wants to merge 1 commit intoqueens-py:mainfrom
Conversation
|
I like this feature, I found it quite unintuitive before when having to use free variables explicitly. |
leahaeusel
left a comment
There was a problem hiding this comment.
I like this feature, too 👍 Just two minor comments from my side:
29a6b50 to
a2b2dc8
Compare
a2b2dc8 to
efe6318
Compare
| for parameter_name in parameters_without_distribution: | ||
| if parameter_name in parameters: | ||
| raise ValueError(f"Parameter name {parameter_name} can only be used once.") |
There was a problem hiding this comment.
Nice catch. I think the error message should be more precise, specifying that it was specified once by pure name and once using a distribution.
Additionally, we need to check if the user provides the same name twice, e.g., Parameters("x1","x1") as this might happen now.
| for parameter_name in parameters_without_distribution: | ||
| if parameter_name in parameters: | ||
| raise ValueError(f"Parameter name {parameter_name} can only be used once.") | ||
| parameters[parameter_name] = FreeVariable(1) |
There was a problem hiding this comment.
Should we add some logging information that we are assuming the parameter to be 1d?
| *parameters_without_distribution (str): Names of one-dimensional parameters without | ||
| assumption about underlying distribution. |
There was a problem hiding this comment.
| *parameters_without_distribution (str): Names of one-dimensional parameters without | |
| assumption about underlying distribution. | |
| *parameters_without_distribution (str): Names of one-dimensional parameters without | |
| assumption about the underlying distribution. |
|
I hate to spoil the party, but I’m not sure I like the direction of this change. I agree that useability of the parameters object can be improved, but I had always envisioned this going a different route. What worries me is that introducing a special interface adds a fair bit of complexity — we now have another “if” in the conceptual tree of how to use the parameter object. Users need to know which interface to use depending on whether it’s a deterministic or random variable, which makes things less uniform. I’ve always appreciated that it’s just “the same thing” for both. I fear that this might make life easier for expert users, but harder for new ones. Additionally, I had imagined extending the functionality of free variables — for example, defining bounds for deterministic variables used in the optimization or gird iterator — so that all related properties live in one place: the parameters object. The proposed interface feels too specific to one-dimensional real-valued parameters and doesn’t strike a good balance between added complexity and added value, in my opinion. |
I agree, the parameters do way too much. Yet, I still think such a functionality is an acceptable interim solution. Completely changing the parameters interface will be a lot of work, and tbh it's not easy, I've looked into it in the past :(
I don't think that this is as easy as you think. It depends on what is meant by new ones. People who only care about the model infrastructure will find this change beneficial, but for those who are interested in distributions, it may cause confusion. I think we, experts accustomed to the strangeness of QUEENS, should seek the opinion of newish users, and not try to speak for them.
We had this in the past, which I personally found as a mix between nice and annoying, mainly due to its implementation, which could definitely be improved :)
My guesstimate would be that the strong majority of QUEENS users only use one-dimensional parameters. I don't have evidence to support that, just a feeling. Some I spoke to didn't even realise that one could do multivariate ones. I just want to highlight that it is an important case (not the only one for sure) I think the willingness to improve the parameter setup is nice. Recently, I have studied factory functions, which I think are quite beneficial for usability and easy to test. Examples of these are |
Description and Context:
What and Why?
If someone wants to use queens for deterministic analyses, the setup of
ParameterswithFreeVariables is a bit cumbersome. This PR aims to simplify this process by allowing*argsforParametersthat are used for 1d parameters without underlying distributions.For example:
can be simplified to
This is just a suggestion that might ignite ideas for a better solution 🙂
Related Issues and Pull Requests
Interested Parties