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

[Feature] Enable optional parameters for objective functions with functools #36

Open
samgdotson opened this issue Feb 22, 2023 · 3 comments
Assignees
Labels
Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:3-Expert This issue is not only complicated, but also complex. It may require special advanced skills. Priority:3-Desired This work is important, but not urgent. Status:2-Backlog This issue has been claimed, but it's not being worked on right now, and it's not next to be tackled Type:Feature New feature or feature request

Comments

@samgdotson
Copy link
Collaborator

samgdotson commented Feb 22, 2023

Currently, all objectives and constraints in osier require two items, the list of technologies and a solved dispatch model. Some calculations will require tunable parameters. Such as a volatility calculation using weighted_permutation_entropy, for example. Therefore, allowing users to specify the optional parameters at run time with some thing like:

objectives = (func1, functools.partial(func2, m = 7, tau=60))

Where the second objective function func2 has some optional parameters that cannot be set once a simulation begins (except by using functools.partial).

Edit:
To clarify the desired behavior, users should be able to pass a function and it's parameters to osier without explicitly calling functools.partial. E.g.,

from osier import CapacityExpansion

problem = CapacityExpansion(..., objectives=[func1, {func2: {m:7, tau:60}}], ...)

Users would be required to know which parameters they need.

Conversation

@yardasol @ZoeRichter @smpark7 @nsryan2 @munkm

Does this functionality make sense? Which version is clearer? The clarification would add more complexity to the osier.CapacityExpansion object, but it's already so similar to the functools implementation that I'm not sure anymore if the "simplification" makes sense. Looking for thoughts.

@samgdotson samgdotson added Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:3-Expert This issue is not only complicated, but also complex. It may require special advanced skills. Priority:3-Desired This work is important, but not urgent. Status:2-Backlog This issue has been claimed, but it's not being worked on right now, and it's not next to be tackled Type:Feature New feature or feature request labels Feb 22, 2023
@samgdotson samgdotson self-assigned this Feb 22, 2023
@smpark7
Copy link
Contributor

smpark7 commented Feb 28, 2024

From a user perspective, I think functools.partial should be abstracted away. Then the user would also not be required to import functools.

Will func1 be passed as is or as a key in its own dict paired with a None value? e.g., func1 or {func1: None}. Consistency with func2 would be nice.

@samgdotson
Copy link
Collaborator Author

Thanks @smpark7! This behavior is only for the cases where a function has some additional parameters, which would be ‘func2’ in this case. ‘func1’ is not modified so ‘osier’ can simply use it. This is what I would consider “advanced” usage. I’d rather not complicate the syntax too much by harmonizing the format. 9/10 times users would pass ‘func’:None.

@smpark7
Copy link
Contributor

smpark7 commented Feb 28, 2024

Okay if that's the case then just func1 is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:3-Expert This issue is not only complicated, but also complex. It may require special advanced skills. Priority:3-Desired This work is important, but not urgent. Status:2-Backlog This issue has been claimed, but it's not being worked on right now, and it's not next to be tackled Type:Feature New feature or feature request
Projects
None yet
Development

No branches or pull requests

2 participants