Skip to content

Conversation

@FBumann
Copy link
Member

@FBumann FBumann commented Dec 25, 2025

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Related Issues

Closes #(issue number)

Testing

  • I have tested my changes
  • Existing tests still pass

Checklist

  • My code follows the project style
  • I have updated documentation if needed
  • I have added tests for new functionality (if applicable)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added comprehensive time-series clustering functionality for reducing problem size while maintaining solution quality.
    • Introduced clustering expansion capability to restore full-resolution solutions from clustered models.
    • Added configurable storage behavior modes during clustering operations.
    • New example notebooks demonstrating clustering workflows, multi-period clustering, and storage mode configurations.
  • Documentation

    • Added cluster architecture design documentation with detailed implementation guidance.
    • Expanded example system generators for clustering demonstrations.

✏️ Tip: You can customize this high-level summary in your review settings.

  Summary of simplification:

  1. Added clusters: pd.Index | None = None parameter to constructor (like periods, scenarios)
  2. Simplified coords property - just adds cluster if self.clusters is not None
  3. Simplified _use_true_cluster_dims → return self.clusters is not None
  4. Simplified _cluster_n_clusters → return len(self.clusters)
  5. Simplified _cluster_timesteps_per_cluster → return len(self.timesteps)
  6. Simplified _cluster_time_coords → return self.timesteps
  7. Simplified from_dataset - just uses ds.indexes.get('cluster') and ds.indexes['time']
  8. Simplified to_dataset - uses self.clusters directly
  9. Removed all _cluster_info and _clustered_data handling

  The cluster dimension is now treated just like period and scenario - simply another dimension in the coordinate system. The code is much cleaner and more consistent.
  1. flixopt/components.py - InterclusterStorageModel fixes

  _add_linking_constraints (line 1470-1476):
  - Added decay factor (1-loss)^N to link SOC between periods per Blanke et al. (2022) Eq. 5
  - Changed from scalar float() conversion to keeping rel_loss.mean('time') as DataArray to respect period/scenario dimensions

  _add_combined_bound_constraints (line 1514-1528):
  - Added decay factor (1-loss)^t to the combined bounds check per Blanke et al. (2022) Eq. 9
  - Changed from scalar float() conversion to keeping rel_loss.mean('time') as DataArray

  2. flixopt/transform_accessor.py - expand_solution fix

  Lines 1206-1220:
  - Fixed self-discharge decay calculation to use xarray DataArrays properly
  - Created time_within_period_da as a DataArray with 'time' dimension
  - Compute decay as (1 - loss_value) ** time_within_period_da to properly broadcast across period/scenario dimensions

  Key Technical Details

  - All parameters use xr.DataArray to respect per-period/scenario values
  - Decay factors use mean loss rate over time (period-level linking doesn't use per-timestep loss)
  - xarray broadcasting handles alignment across dimensions automatically
* Add realsitic data to notbeooks

* Add local catch warnings to solution of model

* Add local catch warnings to solution of model

* Remove solving from generate_example_systems.py script

* Remove new system

* Remove new system
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