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

Refactor allocation code #1465

Closed
4 of 5 tasks
SouthEndMusic opened this issue May 14, 2024 · 4 comments · Fixed by #1503
Closed
4 of 5 tasks

Refactor allocation code #1465

SouthEndMusic opened this issue May 14, 2024 · 4 comments · Fixed by #1503
Assignees
Labels
allocation Allocation layer core Issues related to the computational core in Julia improvement Improvements of the usability of existing functionality

Comments

@SouthEndMusic
Copy link
Collaborator

SouthEndMusic commented May 14, 2024

These refactoring points came out of the knowledge sharing session (which was more of a code review session):

  • Use function is_main_network here:
    if subnetwork_id == 1
  • Introduce a separate allocation_util.jl file with allocation utility functions. This might need some discussion though, I'm not sure what counts as a utility function
  • The function allocate!: Dispatch on optimization_type, so several if statements can be removed
  • The functions allocate! and allocate_priority! need to be renamed, maybe simply to optimize! and optimize_priority!, as they are not always allocating, depending on the optimization_type
  • For the functions in allocate_priority
  • We now only have the AbstractParameterNode type for nodes. We can add a more specific abstract node type in between, say AbstractDemandNode, for nodes that define a demand.
  • For the adjust_demands_* functions, loop over the AbstractDemandNode subtypes and dispatch on them. Alternatively, for all the adjust_* functions, dispatch on the constraint set names.
@SouthEndMusic SouthEndMusic added allocation Allocation layer core Issues related to the computational core in Julia improvement Improvements of the usability of existing functionality labels May 14, 2024
@gijsber
Copy link
Contributor

gijsber commented May 14, 2024

Hi @SouthEndMusic
You now have one allocate function where you have multiple times and iff statement to see if you need to collect_demands.
In callback.jl (update_allocation) you call allocate multiple times, sometimes to collect_demands, sometimes to allocate_demands.
I would recommend to turn the current allocate function in two functions, one called collect_demands and one called allocate of allocate_demands
[ ] split allocate into collect_demands and allocate_demands function

@SnippenE SnippenE assigned SnippenE and Jingru923 and unassigned SnippenE May 16, 2024
@Jingru923 Jingru923 linked a pull request May 28, 2024 that will close this issue
@Jingru923
Copy link
Contributor

Steps 1, 3, 4, 5 are finished.

As for step 2, the functions in allocation_optim.jl are utility functions. If we create a new file for utility functions, based on the definition of utility functions in programming, we might move everything from allocation_optim.jl.

I understand that we wanted to split allocation_optim.jl into multiple files, maybe we can come up a different categorization for the functions in there

@gijsber
Copy link
Contributor

gijsber commented May 31, 2024

Hi @Jingru923 ,
did you also split the current allocate function in two functions, one called collect_demands and one called allocate of allocate_demands ?

@Jingru923
Copy link
Contributor

Yes @gijsber

Jingru923 added a commit that referenced this issue Jun 3, 2024
Fixes #1465 allocation refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
allocation Allocation layer core Issues related to the computational core in Julia improvement Improvements of the usability of existing functionality
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants