Skip to content

Improvement of utilities for TwoLevelTree#82

Merged
JulStraus merged 4 commits intomainfrom
js/TwoLevelTree_updates
Oct 29, 2025
Merged

Improvement of utilities for TwoLevelTree#82
JulStraus merged 4 commits intomainfrom
js/TwoLevelTree_updates

Conversation

@JulStraus
Copy link
Collaborator

This PR combines two topics:

  1. bf23cec includes a default value for probability_branch and
  2. eb97da6 updates utility functions (and their tests) as well as adds some.

A key factor for the changes to probability_branch is that we have to include it in practice in all multiplications for CAPEX contributions to the cost function. Otherwise, we would end up counting each branch as if the probability is 1. In this respect, the function is similar to probability. However, we could improve in the documentation that one should either use probability or probability_branch as the latter is included in all other TreePeriods or AbstractTreeStructure.

Regarding the utility functions, I would suggest we think whether we should export some of them. Specifically, I used n_strat_per in one of the changes I plan to implement within EnergyModelsBase.

@JulStraus JulStraus requested a review from trulsf October 22, 2025 10:03
@trulsf
Copy link
Member

trulsf commented Oct 28, 2025

I am not sure I see the need for the get_strat_node function. Is it made just to be used in the tests?

I guess, some of the utilities can be exported. At the same time, I am bit concerned about exposing to much functionality for interacting directly with the tree structure. Is it not enough to be able to iterate through the nodes of the tree and the scenario paths to each leave? At least, I think we should have some good use cases where it seems relevant.

@JulStraus
Copy link
Collaborator Author

I am not sure I see the need for the get_strat_node function. Is it made just to be used in the tests?

Honestly speaking, I do not recall it right now. I probably lost a bit track of the different branches and stashes I have within all EMX packages ;) I think however it is good to have it for a latter stage (but without a docstring and internal). It is in general preferred to use the iterator utilities, but sometimes this is, at least in my view, not really possible as we do not consider all potential applications.

At the same time, I am bit concerned about exposing to much functionality for interacting directly with the tree structure.

I agree. I am currently using at least the functionality for identification of the numbers, i.e., n_strat_per, n_children and n_leaves. The question is whether they should be available or not.

@JulStraus
Copy link
Collaborator Author

The last two commits just update the exports and tests. The former was discussed above, the latter was essentially a requirement.

@JulStraus JulStraus merged commit 025d09a into main Oct 29, 2025
6 checks passed
@JulStraus JulStraus deleted the js/TwoLevelTree_updates branch October 29, 2025 13:13
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

Successfully merging this pull request may close these issues.

2 participants