Skip to content

Partition duration for time structures#95

Merged
JulStraus merged 12 commits into
mainfrom
js/partition_duration
Jun 19, 2026
Merged

Partition duration for time structures#95
JulStraus merged 12 commits into
mainfrom
js/partition_duration

Conversation

@JulStraus

Copy link
Copy Markdown
Collaborator

This is a first take on including partitions based on the duration of operational periods as outlined in #94. There are a few things to highlight:

The introduction of the PartitionDuration abstract type enables

  • the introduction of time profiles indexed over the partition,
  • the utilization of existing time profiles for indexing, and
  • simplified indexing of variables (easier to identify the corresponding partition).

However, it requires the introduction of subtypes for all potential combinations. This is a bit annoying, but does not require to much work either.

There are still a few open questions:

  1. Shall we allow for varying durations of the partitions? I personally think yes as a partition could be, e.g., 5 days and 2 days to differentiate between work week days and weekend days. The implementation should be straight forward.
  2. The last partition can be in the current stage shorter than specified. The reason is that we do not know a priori a) how many partitions are available and how many time periods are in the last partition.

My plan is now to

  1. incorporate profile indexing and
  2. introduce all other subtypes that are required.

Important

I consider partitions only to be relevant for operational periods. The reason is that it does not make sense, at least in my opinion, to have partitions of operational scenarios. It could theoretically make sense for representative periods or strategic periods, but I think it is better to not allow for it at the current stage.

- To be added for other time structures
@JulStraus JulStraus requested a review from trulsf June 11, 2026 07:30
@JulStraus JulStraus self-assigned this Jun 11, 2026
@JulStraus JulStraus added the enhancement New feature or request label Jun 11, 2026
@JulStraus JulStraus requested a review from hellemo June 11, 2026 13:56
@JulStraus JulStraus marked this pull request as ready for review June 11, 2026 13:56
@JulStraus

Copy link
Copy Markdown
Collaborator Author

I added now support for most of the available time structures, excluding TwoLevelTree, SimpleTimes, and CalendarTimes. TwoLevelTree is something which I want to add in a different PR. In addition, I also want to add in a different PR the potential for specifying explicitly the minimum duration of each partition.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces duration-based partitioning for operational time structures, enabling profiles and variable indexing over these partitions (per #94).

Changes:

  • Added partition_duration and supporting PartitionDuration* types/iterators to generate non-overlapping duration-based partitions.
  • Introduced PartitionProfile and extended profile indexing/arithmetic to support partition-based indices.
  • Added extensive tests and updated API reference docs for the new functionality.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/utils.jl Adds PartitionDuration abstractions and the core partition_duration iterator implementation.
src/partitions/strat_periods.jl Implements partition types and higher-level partition generation for strategic/two-level structures.
src/partitions/rep_periods.jl Implements partition types and higher-level partition generation for representative periods (incl. nested scenarios).
src/partitions/opscenarios.jl Implements partition types and higher-level partition generation for operational scenarios.
src/profiles.jl Adds PartitionProfile and enables profile indexing via PartitionDuration indices; adds arithmetic overloads.
src/TimeStruct.jl Includes new partition source files and exports PartitionProfile / partition_duration.
test/runtests.jl Adds test coverage for partition/profile indexing behavior and partition iterator invariants.
docs/src/reference/api.md Documents partition_duration and PartitionProfile in the API reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils.jl Outdated
Comment thread src/utils.jl Outdated
Comment thread src/utils.jl Outdated
Comment thread src/profiles.jl Outdated
Comment thread src/profiles.jl Outdated
Comment thread src/partitions/strat_periods.jl
Comment thread src/partitions/rep_periods.jl
Comment thread src/partitions/opscenarios.jl
Comment thread test/runtests.jl Outdated

@trulsf trulsf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Maybe fix some of the comment typos identified by Copilot (other comments seem not that relevant).

JulStraus and others added 3 commits June 18, 2026 15:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Simplifies using the type for normal partitions
- Corresponds more to what they mean
@JulStraus

Copy link
Copy Markdown
Collaborator Author

I did a minor additional naming change @trulsf . Let me know if you are ok with it and I will merge it afterwards.

@trulsf

trulsf commented Jun 18, 2026

Copy link
Copy Markdown
Member

I think the new name is better so just go ahead with the merge - after a minor format fix :)

@JulStraus

JulStraus commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

I think the new name is better so just go ahead with the merge - after a minor format fix :)

Interestingly, the local formatter (v2.6.11 compared to v2.8.5) considered it to be formatted... I see the return with a throw statement slightly critical and stupid as in my opinion, there should not be a return of a throw statement as it automatically breaks the code anyhow.

@JulStraus JulStraus merged commit 930fc4f into main Jun 19, 2026
6 checks passed
@JulStraus JulStraus deleted the js/partition_duration branch June 19, 2026 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants