Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
65486ae
⏺ I've completed the core migration to tsam 3.0.0. Here's a summary o…
FBumann Jan 12, 2026
156bc47
⏺ The tsam 3.0 migration is now complete with the correct API. All 79…
FBumann Jan 12, 2026
46f3418
⏺ The simplification refactoring is complete. Here's what was done:
FBumann Jan 12, 2026
cfb9926
I continued the work on simplifying flixopt's clustering architecture…
FBumann Jan 12, 2026
cf5279a
All the clustering notebooks and documentation have been updated fo…
FBumann Jan 12, 2026
addde0b
Fixes made:
FBumann Jan 12, 2026
65e872b
⏺ All 126 clustering tests pass. I've added 8 new tests in a new Test…
FBumann Jan 12, 2026
1547a36
Summary of Changes
FBumann Jan 12, 2026
5117967
Summary of changes:
FBumann Jan 12, 2026
ddd4d2d
rename to ClusteringResults
FBumann Jan 12, 2026
3365734
New xarray-like interface:
FBumann Jan 12, 2026
a55b9a1
Updated the following notebooks:
FBumann Jan 12, 2026
5056873
ClusteringResults class:
FBumann Jan 12, 2026
6fc34cd
Renamed:
FBumann Jan 12, 2026
72d6f0d
Expose SegmentConfig
FBumann Jan 12, 2026
42e37e1
The segmentation feature has been ported to the tsam 3.0 API. Key c…
FBumann Jan 12, 2026
c5409c8
Added Properties
FBumann Jan 12, 2026
ad6e5e7
Summary of Changes
FBumann Jan 12, 2026
860b15e
⏺ I've completed the implementation. Here's a summary of everything t…
FBumann Jan 13, 2026
b73a6a1
Add method to extract data used for clustering.
FBumann Jan 13, 2026
e6ee2dd
Summary of Refactoring
FBumann Jan 13, 2026
e880fad
Changes Made
FBumann Jan 13, 2026
fbb2b0f
Update Notebook
FBumann Jan 13, 2026
151e4b3
1. Clustering class now wraps AggregationResult objects directly
FBumann Jan 13, 2026
57f59ed
I've completed the refactoring to make the Clustering class derive …
FBumann Jan 13, 2026
b39e994
The issue was that _build_aggregation_data() was using n_timesteps_…
FBumann Jan 13, 2026
8b1daf6
❯ Remove some data wrappers.
FBumann Jan 13, 2026
bf5d7ff
Improve docstrings and types
FBumann Jan 13, 2026
bb5f7aa
Add notebook and preserve input data
FBumann Jan 13, 2026
556e90f
Implemented include_original_data parameter:
FBumann Jan 13, 2026
810c143
Changes made:
FBumann Jan 13, 2026
1696e47
Changes made:
FBumann Jan 13, 2026
5cf85ac
drop_constant_arrays to use std < atol instead of max == min
FBumann Jan 13, 2026
8332eaa
Temp fix (should be fixed in tsam)
FBumann Jan 14, 2026
9ba340c
Revert "Temp fix (should be fixed in tsam)"
FBumann Jan 14, 2026
94477b1
Merge origin/main into feature/tsam-v3+rework
FBumann Jan 14, 2026
13002a0
Updated tsam dependencies to use the PR branch of tsam containing the…
FBumann Jan 15, 2026
fddea30
All fast notebooks now pass. Here's a summary of the fixes:
FBumann Jan 15, 2026
982e75a
⏺ All fast notebooks now pass. Here's a summary of the fixes:
FBumann Jan 15, 2026
9d5d969
Fix notebook
FBumann Jan 15, 2026
946d374
Fix CI...
FBumann Jan 15, 2026
b483ad4
Revert "Fix CI..."
FBumann Jan 15, 2026
c847ef6
Fix CI...
FBumann Jan 15, 2026
872bbbd
Merge branch 'main' into feature/tsam-v3+rework
FBumann Jan 16, 2026
a5f0147
Merge branch 'dev' into feature/tsam-v3+rework
FBumann Jan 16, 2026
450739c
Fix: Correct expansion of segmented clustered systems (#573)
FBumann Jan 16, 2026
ebf2aab
Added @functools.cached_property to timestep_mapping in clustering/b…
FBumann Jan 16, 2026
79d0e5e
perf: 40x faster FlowSystem I/O + storage efficiency improvements (#578)
FBumann Jan 16, 2026
7a4280d
perf: Optimize clustering and I/O (4.4x faster segmented clustering) …
FBumann Jan 17, 2026
1287792
2. Lines 1245-1251 (new guard): Added explicit check after drop_con…
FBumann Jan 17, 2026
ecbe6a8
⏺ I've designed and implemented the DCE (Declaration-Collection-Execu…
FBumann Jan 17, 2026
1c03e02
Ruff checks
FBumann Jan 17, 2026
8376bad
The DCE pattern is now implemented for Flow. Here's a summary:
FBumann Jan 17, 2026
4e2eb1e
The example demo works but the benchmark fails on a binary variable b…
FBumann Jan 17, 2026
efd91f5
Fix/broadcasting (#580)
FBumann Jan 17, 2026
7d3ff2d
Constraint Batching Success!
FBumann Jan 17, 2026
05ac1be
Effect Share Batching - Completed
FBumann Jan 17, 2026
0bd0f74
The simplified code using xr.concat and broadcasting is much cleaner:
FBumann Jan 17, 2026
7d38ded
The status bounds batching is now working. Here's a summary:
FBumann Jan 17, 2026
b69fa5b
Improve bounds stacking
FBumann Jan 17, 2026
298895e
Merge branch 'feature/tsam-v3+rework' into feature/vectorized-model-c…
FBumann Jan 17, 2026
5c90821
Summary: StatusModel DCE Integration
FBumann Jan 17, 2026
3ea4ce9
Phase 1 is complete. Here's a summary of what was implemented:
FBumann Jan 17, 2026
abe79bf
Phase 2: FlowsModel Implementation
FBumann Jan 17, 2026
8b21a02
Add infrastructure to use the old OR the new modeling mode
FBumann Jan 17, 2026
630ce1e
Finish BusModel implementation
FBumann Jan 17, 2026
ba0a3a2
BusesModel Implementation
FBumann Jan 17, 2026
4e53444
Summary - Effect Shares with Per-Element Visibility
FBumann Jan 17, 2026
4b259d3
Summary - StoragesModel Implementation
FBumann Jan 17, 2026
f572d8a
Summary
FBumann Jan 17, 2026
11e1131
New Class: InvestmentsModel (features.py:157-502)
FBumann Jan 17, 2026
a0976a9
⏺ I've completed the batched investment integration for flows. Here's…
FBumann Jan 17, 2026
dbf0ead
Summary: Batched StatusesModel Implementation
FBumann Jan 17, 2026
2b0639f
⏺ Summary of Session
FBumann Jan 17, 2026
e5722c4
Add modeling config option
FBumann Jan 17, 2026
1bb5a85
Final solution using xr.broadcast():
FBumann Jan 17, 2026
d4a5676
Fix stacking
FBumann Jan 17, 2026
c3a81e1
Fix stacking
FBumann Jan 17, 2026
4e0f66d
Ported over more functionality
FBumann Jan 17, 2026
ba73baf
1. Fixed InvestmentsModel._stack_bounds - Added a method to handle …
FBumann Jan 17, 2026
3e82cf1
All notebooks pass with type_level mode up to solution retrieval:
FBumann Jan 17, 2026
8286aaf
Summary: Batched Effects with 'effect' Dimension
FBumann Jan 18, 2026
ab01295
Summary: Unified Share Variables
FBumann Jan 18, 2026
66be595
Fix some some missing stuff
FBumann Jan 18, 2026
ff62c54
Notebook Testing Results
FBumann Jan 18, 2026
669226d
Summary of Changes
FBumann Jan 18, 2026
35e3824
Use contributor dim instead of element dim in effect variables
FBumann Jan 18, 2026
c38cf47
Summary of Changes
FBumann Jan 18, 2026
0991102
Fix some dim names
FBumann Jan 18, 2026
bdcc0d9
Summary of Changes
FBumann Jan 18, 2026
d888c6c
⏺ The SharesModel implementation is now complete and working. Here's …
FBumann Jan 18, 2026
963244e
SharesModel Implementation Summary
FBumann Jan 18, 2026
75b4b6b
⏺ The refactored code works. Here's the clean registration pattern no…
FBumann Jan 19, 2026
7dae6ac
Final Clean Architecture
FBumann Jan 19, 2026
ec3ff02
Summary: Property-Based Effect Factors
FBumann Jan 19, 2026
9d2c573
⏺ Summary: Clean Batching Architecture
FBumann Jan 19, 2026
061b111
⏺ The SharesModel class has been removed successfully. Here's a summa…
FBumann Jan 19, 2026
ee44330
⏺ Done! Summary of changes:
FBumann Jan 19, 2026
4b8ed02
Simplification complete. The _stack_bounds() method went from 34 line…
FBumann Jan 19, 2026
49f5502
⏺ The share variable approach is now clean:
FBumann Jan 19, 2026
05475d1
The structure is now cleaner:
FBumann Jan 19, 2026
d900717
- _share_coords(element_dim, element_index, temporal=True/False) - …
FBumann Jan 19, 2026
3d38571
The structure is now:
FBumann Jan 19, 2026
97b232f
⏺ The compact implementation works correctly and maintains excellent …
FBumann Jan 19, 2026
314731f
⏺ Refactoring Complete: Transition to Type-Level Mode
FBumann Jan 19, 2026
8b95d8d
Summary of Refactoring Progress
FBumann Jan 19, 2026
54ff2d8
The StatusesModel refactoring is complete. Here's a summary of what w…
FBumann Jan 19, 2026
18fa2e8
InvestmentsModel refactoring is complete. Here's a summary of changes:
FBumann Jan 19, 2026
2bf16a4
InvestmentsModel refactoring is complete. Here's a summary of changes:
FBumann Jan 19, 2026
7bfc82e
InvestmentsModel refactoring is complete. Here's a summary of changes:
FBumann Jan 19, 2026
fb2ee62
investment inlining refactoring is complete. Here's a summary of what…
FBumann Jan 19, 2026
ac4e4a0
The refactoring is complete. Here's a summary of what was done:
FBumann Jan 19, 2026
14b95c2
⏺ All done! Here's a summary of the properties added:
FBumann Jan 19, 2026
d453cad
⏺ All working. The properties now access self.model.variables['var_na…
FBumann Jan 19, 2026
a26adc6
⏺ Now both work correctly:
FBumann Jan 19, 2026
762ce94
Summary of changes:
FBumann Jan 19, 2026
35b30e2
⏺ All changes are complete and working. Here's the summary:
FBumann Jan 19, 2026
815769f
No redundant |duration.
FBumann Jan 19, 2026
5884718
⏺ Refactoring complete. Here's the summary:
FBumann Jan 19, 2026
9f1e97e
Review complete. Summary of changes:
FBumann Jan 19, 2026
50cfdf6
Summary
FBumann Jan 19, 2026
843141d
⏺ Everything is working correctly. Let me summarize:
FBumann Jan 19, 2026
07c9fe9
Summary of Ported Constraint Methods
FBumann Jan 19, 2026
f120749
⏺ Summary of Completed Work
FBumann Jan 19, 2026
c6c59d4
Summary of Additional Improvements
FBumann Jan 19, 2026
3f1ee54
⏺ All working. The renamed properties are cleaner:
FBumann Jan 19, 2026
2193595
Added cached properties to StoragesModel (components.py lines 1544-16…
FBumann Jan 19, 2026
6f9312a
⏺ Summary of All Changes
FBumann Jan 19, 2026
473b281
I've completed the MaskHelpers implementation and integration. Here's…
FBumann Jan 19, 2026
1643b3d
Time-varying coefficients are now fully supported in the batched appr…
FBumann Jan 19, 2026
d796260
Investment Effects Implementation Summary
FBumann Jan 20, 2026
9e62d26
Summary of Renames and Unification
FBumann Jan 20, 2026
81e1b7b
⏺ Let me summarize what was accomplished in this session:
FBumann Jan 20, 2026
280dd54
Merged PiecewiseConvertersModel into ComponentsModel - Now all compon…
FBumann Jan 20, 2026
e705916
⏺ Summary: Transmission Model porting is complete.
FBumann Jan 20, 2026
38a1279
I have successfully implemented the plan to split ComponentsModel int…
FBumann Jan 20, 2026
5db031d
All transmission tests pass. Let me provide a summary of the changes …
FBumann Jan 20, 2026
4e4ca7d
Summary
FBumann Jan 20, 2026
d54a7e8
Summary of Changes
FBumann Jan 20, 2026
e1c484b
⏺ Summary of Session Accomplishments:
FBumann Jan 20, 2026
70ab619
Another step
FBumann Jan 20, 2026
f95ce93
Summary
FBumann Jan 21, 2026
c869e0f
Summary of Changes
FBumann Jan 21, 2026
36d7f50
The InterclusterStoragesModel batching work is complete. Let me provi…
FBumann Jan 21, 2026
020cd8d
The dead Submodel infrastructure has been successfully removed from …
FBumann Jan 21, 2026
f354057
All tasks are now complete. Here's a summary of what was accomplished:
FBumann Jan 21, 2026
f3d5ccc
Summary of Code Simplifications
FBumann Jan 21, 2026
43596d3
Use logical properties instead of init stuff
FBumann Jan 23, 2026
c3fdb72
Changes made:
FBumann Jan 23, 2026
69da7ba
Use ElementContainers
FBumann Jan 23, 2026
2694cf8
Add batched data class
FBumann Jan 23, 2026
61a7681
Improve FlowsData
FBumann Jan 23, 2026
cc6a8fb
Add remaining properties to FlowsData
FBumann Jan 23, 2026
694fe7b
Update FlowsModel
FBumann Jan 23, 2026
45b2556
Re-add some params
FBumann Jan 23, 2026
5717436
Move some logic to data
FBumann Jan 23, 2026
d7dc50a
Simplify
FBumann Jan 23, 2026
79122c0
Reduce unnessesary broadcasting
FBumann Jan 23, 2026
d63aaa5
Remove not needed variables
FBumann Jan 23, 2026
536a4cf
Summary of Changes
FBumann Jan 23, 2026
7d752b3
Reorder properties
FBumann Jan 23, 2026
08ef226
Improve constraint
FBumann Jan 23, 2026
62abe1f
Improve constraints and properties
FBumann Jan 23, 2026
bd26348
Improve constraints and properties
FBumann Jan 23, 2026
5426afc
Improve constraints and properties
FBumann Jan 23, 2026
282db6a
Update size and status constraints
FBumann Jan 23, 2026
7e25067
Update constraint names etc
FBumann Jan 23, 2026
567bc05
Update test labels
FBumann Jan 23, 2026
1484956
Add dimension ordering
FBumann Jan 23, 2026
e2e3e81
Move contributions math to FlowsModel
FBumann Jan 23, 2026
5605295
Move contributions math to FlowsModel
FBumann Jan 23, 2026
0ee1d1b
Remove old method
FBumann Jan 23, 2026
c05a0d9
Add mroe flags to FlowsData
FBumann Jan 23, 2026
2d7a25d
Move status sthings directly to FlowsModel
FBumann Jan 23, 2026
4cdb0f3
Update tests
FBumann Jan 23, 2026
3952a0c
Update tests and add previous status
FBumann Jan 23, 2026
d96f5e2
Summary of Changes
FBumann Jan 23, 2026
5e1a25e
Efficiency Improvements
FBumann Jan 23, 2026
5a3be6b
- status_effects_per_active_hour → effects_per_active_hour
FBumann Jan 23, 2026
775dde5
StatusHelpers is now slimmer. Summary of what's left:
FBumann Jan 23, 2026
990df5f
Created a new StatusData class that batches StatusParameters for a gr…
FBumann Jan 23, 2026
d76618c
Summary of changes:
FBumann Jan 23, 2026
728e6a9
Summary:
FBumann Jan 23, 2026
f126b29
Summary of Investment Modeling:
FBumann Jan 23, 2026
35d4386
Add documentation for the new modeling approach
FBumann Jan 23, 2026
78543ad
Fixed the issue where minimum_or_fixed_size and other properties retu…
FBumann Jan 23, 2026
19049e5
Only sum over periods if periods present
FBumann Jan 23, 2026
0fb73aa
small perf improvements
FBumann Jan 23, 2026
491f860
Add benchmark
FBumann Jan 23, 2026
4762340
Add batched bus constraint
FBumann Jan 23, 2026
18d8957
Final benchmark: 165ms (down from 1485ms initial - 9x speedup)
FBumann Jan 23, 2026
60204f7
Performance Summary:
FBumann Jan 23, 2026
436f4d6
Summary of _stack_values improvements:
FBumann Jan 23, 2026
21caf9f
establish method for broadcasting
FBumann Jan 23, 2026
2d41ed4
Make conversion constraint faster
FBumann Jan 23, 2026
cf467ea
Make conversion constraint faster
FBumann Jan 23, 2026
ac75aaa
Add mask to create_linear_constraints
FBumann Jan 23, 2026
c03274c
Make bus balance more readabale and use masking
FBumann Jan 24, 2026
4730a1e
Improve benchmark_model_build.py
FBumann Jan 24, 2026
b24986c
Improve benchmark_model_build.py
FBumann Jan 24, 2026
1d3b0d7
Add batching to piecewise constraint
FBumann Jan 24, 2026
ecbac85
Add batching to piecewise constraint
FBumann Jan 24, 2026
74cb0fe
Performance is even slightly better. Here's the final summary:
FBumann Jan 24, 2026
71cc538
Final Piecewise Code
FBumann Jan 24, 2026
92b510d
Summary
FBumann Jan 24, 2026
2b00946
Add fast_notnull method
FBumann Jan 24, 2026
57ff5ce
more masking, less sel()
FBumann Jan 24, 2026
6250530
Update the benchmark for super large system
FBumann Jan 24, 2026
ad8ceef
Add migration guide
FBumann Jan 24, 2026
8eeee22
Improve migration guide
FBumann Jan 24, 2026
76f676b
Merge main into feature/element-data-classes
FBumann Jan 24, 2026
c11275e
Summary of Fixes
FBumann Jan 25, 2026
41c164a
All 1059 tests pass with only 2 skipped. Here's a summary of the fixe…
FBumann Jan 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
582 changes: 582 additions & 0 deletions benchmarks/benchmark_model_build.py

Large diffs are not rendered by default.

969 changes: 969 additions & 0 deletions docs/architecture/batched_modeling.md

Large diffs are not rendered by default.

164 changes: 164 additions & 0 deletions docs/migration_guide_v7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Migration Guide: flixopt v7

## What's New

### Performance

| System | v6 | v7 | Speedup |
|--------|-----|-----|---------|
| Medium (720h, 30 components) | 5,278ms | 388ms | **13.6x** |
| Large (720h, 65 components) | 13,364ms | 478ms | **28.0x** |
| XL (2000h, 355 components) | 59,684ms | 5,978ms | **10.0x** |

LP file writing is also 4-13x faster.

### Fewer Variables, Same Model

v7 uses batched variables with element coordinates instead of individual variables per element:

```
v6: 859 variables, 997 constraints (720h, 50 converters)
v7: 21 variables, 30 constraints (same model!)
```

| v6 | v7 |
|----|-----|
| `Boiler(Q_th)\|rate` | `flow\|rate` with coord `flow='Boiler(Q_th)'` |
| `Boiler(Q_th)\|size` | `flow\|size` with coord `flow='Boiler(Q_th)'` |
| `HeatStorage\|charge_state` | `storage\|charge_state` with coord `storage='HeatStorage'` |

### Native xarray Access

After solving, results are xarray DataArrays with full analytical capabilities:

```python
solution = model.solution
rates = solution['flow|rate'] # (flow, time, ...)

# Select elements
rates.sel(flow='Boiler(Q_th)')
rates.sel(flow=['Boiler(Q_th)', 'CHP(Q_th)'])

# Aggregations
rates.sum('flow')
rates.mean('time')

# Time series operations
rates.resample(time='1D').mean()
rates.groupby('time.hour').mean()

# Export
rates.to_dataframe()
```

---

## Breaking Changes

### Solution Variable Names

The main breaking change is how variables are named in `model.solution`:

```python
solution = model.solution

# v6 style - NO LONGER EXISTS
solution['Boiler(Q_th)|rate'] # KeyError!
solution['Boiler(Q_th)|size'] # KeyError!

# v7 style - Use batched name + .sel()
solution['flow|rate'].sel(flow='Boiler(Q_th)')
solution['flow|size'].sel(flow='Boiler(Q_th)')
```

#### Variable Name Mapping

| v6 Name | v7 Name |
|---------|---------|
| `{flow}\|rate` | `flow\|rate` with `.sel(flow='{flow}')` |
| `{flow}\|size` | `flow\|size` with `.sel(flow='{flow}')` |
| `{flow}\|status` | `flow\|status` with `.sel(flow='{flow}')` |
| `{storage}\|charge_state` | `storage\|charge_state` with `.sel(storage='{storage}')` |
| `{storage}\|size` | `storage\|size` with `.sel(storage='{storage}')` |

#### Migration Pattern

```python
# v6
def get_flow_rate(solution, flow_name):
return solution[f'{flow_name}|rate']

# v7
def get_flow_rate(solution, flow_name):
return solution['flow|rate'].sel(flow=flow_name)
```

### Iterating Over Results

```python
# v6 - iterate over individual variable names
for flow_name in flow_names:
rate = solution[f'{flow_name}|rate']
process(rate)

# v7 - use xarray iteration or vectorized operations
rates = solution['flow|rate']

# Option 1: Vectorized (preferred)
total = rates.sum('flow')

# Option 2: Iterate if needed
for flow_name in rates.coords['flow'].values:
rate = rates.sel(flow=flow_name)
process(rate)
```

### Getting All Flow/Storage Names

```python
# v7 - get element names from coordinates
flow_names = list(solution['flow|rate'].coords['flow'].values)
storage_names = list(solution['storage|charge_state'].coords['storage'].values)
```

---

## Quick Reference

### Available Batched Variables

| Variable | Dimensions |
|----------|------------|
| `flow\|rate` | (flow, time, period?, scenario?) |
| `flow\|size` | (flow, period?, scenario?) |
| `flow\|status` | (flow, time, ...) |
| `storage\|charge_state` | (storage, time, ...) |
| `storage\|size` | (storage, period?, scenario?) |
| `bus\|balance` | (bus, time, ...) |

### Common Operations

```python
solution = model.solution

# Get all rates
rates = solution['flow|rate']

# Select one element
boiler = rates.sel(flow='Boiler(Q_th)')

# Select multiple
selected = rates.sel(flow=['Boiler(Q_th)', 'CHP(Q_th)'])

# Filter by pattern
heat_flows = [f for f in rates.coords['flow'].values if 'Q_th' in f]
heat_rates = rates.sel(flow=heat_flows)

# Aggregate
total_by_time = rates.sum('flow')
total_by_flow = rates.sum('time')

# Time operations
daily = rates.resample(time='1D').mean()
hourly_pattern = rates.groupby('time.hour').mean()
```
Loading
Loading