Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
294 commits
Select commit Hold shift + click to select a range
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
6fc3c74
Here's a summary of what was done:
FBumann Jan 30, 2026
1e01f8a
Summary of this change:
FBumann Jan 30, 2026
2a2180f
The refactoring is complete:
FBumann Jan 30, 2026
a69c3d4
Reuse more from TypeModel class
FBumann Jan 30, 2026
ecb32ff
Make code more compact
FBumann Jan 30, 2026
5e70f61
Make code more compact
FBumann Jan 30, 2026
78b3ad4
Make code more compact
FBumann Jan 30, 2026
b8a6d16
Move mask broadcasting to add_variables()
FBumann Jan 30, 2026
183b528
Makde reindexing obsolete by ensuring consistent flow order
FBumann Jan 30, 2026
5634f0b
Move masks to FLowsData
FBumann Jan 30, 2026
8f55c1a
Add some todos
FBumann Jan 30, 2026
027ab0b
Summary
FBumann Jan 30, 2026
822838b
Summary
FBumann Jan 30, 2026
f831989
The IDs are now derived from the expression's contributor coordinate…
FBumann Jan 30, 2026
5b98cc6
Eliminated the per-effect loop and mask pattern from add_share_temp…
FBumann Jan 30, 2026
80b6fa3
Update test files for batched variable access patterns
FBumann Jan 30, 2026
b1085d8
Allign expressions before summing
FBumann Jan 30, 2026
8f9d266
Allign expressions before summing
FBumann Jan 30, 2026
4f96273
Allign expressions before summing
FBumann Jan 30, 2026
a3faca8
Here's a summary of the changes:
FBumann Jan 30, 2026
a5f1342
flixopt/effects.py:
FBumann Jan 30, 2026
bd9c623
flixopt/effects.py:
FBumann Jan 30, 2026
048575a
flixopt/effects.py:
FBumann Jan 30, 2026
a780318
Make piecewise effects properly vectorized
FBumann Jan 30, 2026
ccb5e34
Improve pieceiwse shares
FBumann Jan 30, 2026
4add600
Improve pieceiwse shares
FBumann Jan 30, 2026
b08ef94
Renamed EffectCollection → EffectsData across all files:
FBumann Jan 30, 2026
e97c1db
What changed:
FBumann Jan 30, 2026
2a999f0
EffectsModel follows the same pattern as FlowsModel and others — dire…
FBumann Jan 30, 2026
42de1ff
Here's what moved:
FBumann Jan 30, 2026
dd0723b
- Component._propagate_status_parameters() — handles status_paramet…
FBumann Jan 30, 2026
74f15c9
do_modeling() is now a clean orchestrator:
FBumann Jan 30, 2026
d19f2ff
Every model class now has a do_modeling() method that owns its build…
FBumann Jan 30, 2026
25c8f30
rename to build_model
FBumann Jan 30, 2026
74efc74
1. StoragesModel (components.py): Merged build_model() into __init_…
FBumann Jan 30, 2026
f134b55
- Deleted PreventSimultaneousFlowsModel class from elements.py
FBumann Jan 30, 2026
6366f3a
- Added _add_prevent_simultaneous_constraints() helper function in …
FBumann Jan 30, 2026
0f79095
Changes Made
FBumann Jan 31, 2026
e714c95
StoragesData now contains:
FBumann Jan 31, 2026
1381a4c
Add variable_names.md to docs
FBumann Jan 31, 2026
5d85c95
All duplication is removed. The stacked data from StoragesData (eta_c…
FBumann Jan 31, 2026
10d30c6
Make variable name prefixing explicit and TypeModel subscriptable
FBumann Jan 31, 2026
b041d67
Replace variable name string literals with VarName constants
FBumann Jan 31, 2026
d5085e7
Use cached properties for variable creation in StoragesModel and Inte…
FBumann Jan 31, 2026
9559261
1. batched.py - StoragesData: Added timesteps_extra parameter and n…
FBumann Jan 31, 2026
b8b2b45
Replace VariableType/VariableCategory with ExpansionMode + NAME_TO_EX…
FBumann Jan 31, 2026
4bf4a86
Make ConvertersModel and TransmissionsModel inherit from TypeModel
FBumann Jan 31, 2026
0cc84eb
Summary of changes:
FBumann Jan 31, 2026
2ff2251
Refactor TypeModel to accept data objects instead of raw element lists
FBumann Jan 31, 2026
56697f8
use public .carriers instead of private
FBumann Jan 31, 2026
6ac93ed
Summary:
FBumann Jan 31, 2026
302413c
Summary of changes:
FBumann Jan 31, 2026
7dd56dd
Summary of changes:
FBumann Jan 31, 2026
f38f828
perf: use sparse groupby in conversion
FBumann Jan 31, 2026
2a94130
perf: use sparse groupby in piecewise_conversion
FBumann Jan 31, 2026
805bcc5
perf: replace xr.concat with numpy pre-allocation in stack_along_dim …
FBumann Jan 31, 2026
82e6998
fix: improve method signature of build_effects_array
FBumann Jan 31, 2026
9c2d3d3
Add sparse_weighted_sum method for faster constraint building
FBumann Jan 31, 2026
8277d5d
Add sparse_weighted_sum method for faster constraint building
FBumann Jan 31, 2026
c67a6a7
Add benchmark results
FBumann Jan 31, 2026
52a581f
Improve piecewise
FBumann Jan 31, 2026
8c8eb5c
Pre-combined xarray coefficients in storage energy balance (eta * dt…
FBumann Jan 31, 2026
3561a91
Fix test
FBumann Jan 31, 2026
502fbb7
Update benchmark_results.md
FBumann Jan 31, 2026
b05f63e
Fix cross effect shares
FBumann Jan 31, 2026
0d47027
perf: use sparse_weighted_sum in bus balance
FBumann Jan 31, 2026
03eb4ad
Ensure all share defs have canonical effect order before alignment
FBumann Jan 31, 2026
d2579b4
Update tests
FBumann Jan 31, 2026
3a16bc2
Merge main into feature/element-data-classes
FBumann Jan 31, 2026
a69c129
Finalize merge
FBumann Jan 31, 2026
7c0e12e
Finalize merge
FBumann Jan 31, 2026
978a4bc
flixopt/structure.py:
FBumann Jan 31, 2026
ac0d3fa
1. components.py — Fixed duplicate dimension bug in InterclusterSto…
FBumann Jan 31, 2026
17095ab
Use ModelCoordinates._update_*
FBumann Jan 31, 2026
701f7af
Fixed: batched.py:656 and batched.py:669 — removed float() conversio…
FBumann Jan 31, 2026
a6b7103
perf: reduce memory usage in build_model (sparse coefficients + per-e…
FBumann Feb 1, 2026
9e3c164
use linopy.merge()
FBumann Feb 1, 2026
5d231e6
Revert "use linopy.merge()"
FBumann Feb 1, 2026
fc42b97
fix statistics_accessor.py
FBumann Feb 1, 2026
a425ec2
fix: FlowsContainer
FBumann Feb 1, 2026
1223a30
fix: FlowsContainer
FBumann Feb 1, 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.

84 changes: 84 additions & 0 deletions benchmarks/benchmark_results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Benchmark Results: Model Build Performance

Benchmarked `build_model()` and LP file write across commits on branch `feature/element-data-classes`, starting from the main branch divergence point.

**Date:** 2026-01-31

## XL System (2000h, 300 converters, 50 storages)

| Commit | Description | Build (ms) | Build speedup | Write LP (ms) | Write speedup |
|--------|-------------|------------|---------------|---------------|---------------|
| `42f593e7` | **main branch (base)** | **113,360** | 1.00x | **44,815** | 1.00x |
| `302413c4` | Summary of changes | **7,718** | 14.69x | **15,369** | 2.92x |
| `7dd56dde` | Summary of changes | **9,572** | 11.84x | **15,780** | 2.84x |
| `f38f828f` | sparse groupby in conversion | **3,649** | 31.07x | **10,370** | 4.32x |
| `2a94130f` | sparse groupby in piecewise_conversion | **2,323** | 48.80x | **9,584** | 4.68x |
| `805bcc56` | xr.concat → numpy pre-alloc | **2,075** | 54.63x | **10,825** | 4.14x |
| `82e69989` | fix build_effects_array signature | **2,333** | 48.59x | **10,331** | 4.34x |
| `9c2d3d3b` | Add sparse_weighted_sum | **1,638** | 69.21x | **9,427** | 4.75x |
| `8277d5d3` | Add sparse_weighted_sum (2) | **2,785** | 40.70x | **9,129** | 4.91x |
| `c67a6a7e` | Clean up, revert piecewise | **2,616** | 43.33x | **9,574** | 4.68x |
| `52a581fe` | Improve piecewise | **1,743** | 65.04x | **9,763** | 4.59x |
| `8c8eb5c9` | Pre-combine xarray coeffs in storage | **1,676** | 67.64x | **8,868** | 5.05x |

## Complex System (72h, piecewise)

| Commit | Description | Build (ms) | Build speedup | Write LP (ms) | Write speedup |
|--------|-------------|------------|---------------|---------------|---------------|
| `42f593e7` | **main branch (base)** | **1,003** | 1.00x | **417** | 1.00x |
| `302413c4` | Summary of changes | **533** | 1.88x | **129** | 3.23x |
| `7dd56dde` | Summary of changes | **430** | 2.33x | **103** | 4.05x |
| `f38f828f` | sparse groupby in conversion | **452** | 2.22x | **136** | 3.07x |
| `2a94130f` | sparse groupby in piecewise_conversion | **440** | 2.28x | **112** | 3.72x |
| `805bcc56` | xr.concat → numpy pre-alloc | **475** | 2.11x | **132** | 3.16x |
| `82e69989` | fix build_effects_array signature | **391** | 2.57x | **99** | 4.21x |
| `9c2d3d3b` | Add sparse_weighted_sum | **404** | 2.48x | **96** | 4.34x |
| `8277d5d3` | Add sparse_weighted_sum (2) | **416** | 2.41x | **98** | 4.26x |
| `c67a6a7e` | Clean up, revert piecewise | **453** | 2.21x | **108** | 3.86x |
| `52a581fe` | Improve piecewise | **426** | 2.35x | **105** | 3.97x |
| `8c8eb5c9` | Pre-combine xarray coeffs in storage | **383** | 2.62x | **100** | 4.17x |

LP file size: 528.28 MB (XL, branch) vs 503.88 MB (XL, main), 0.21 MB (Complex) — unchanged.

## Key Takeaways

- **XL system: 67.6x build speedup** — from 113.4s down to 1.7s. LP write improved 5.1x (44.8s → 8.9s). The bulk of the gain came from the initial refactoring (`302413c4`, 14.7x), with sparse groupby and weighted sum optimizations adding further large improvements.

- **Complex system: 2.62x build speedup** — from 1,003ms down to 383ms. LP write improved 4.2x (417ms → 100ms). Gains are more modest since this system is small (72 timesteps, 14 flows) and dominated by per-operation linopy/xarray overhead.

## How to Run Benchmarks Across Commits

To benchmark `build_model()` across a range of commits, use the following approach:

```bash
# 1. Stash any uncommitted changes
git stash --include-untracked

# 2. Loop over commits and run the benchmark at each one
for SHA in 302413c4 7dd56dde f38f828f 2a94130f 805bcc56 82e69989 9c2d3d3b 8277d5d3 c67a6a7e 52a581fe 8c8eb5c9; do
echo "=== $SHA ==="
git checkout "$SHA" --force 2>/dev/null
python benchmarks/benchmark_model_build.py --system complex --iterations 3
done

# 3. Restore your branch and stash
git checkout feature/element-data-classes --force
git stash pop
```

To run specific system types:

```bash
# Single system
python benchmarks/benchmark_model_build.py --system complex
python benchmarks/benchmark_model_build.py --system synthetic --converters 300 --timesteps 2000

# All systems
python benchmarks/benchmark_model_build.py --all

# Custom iterations
python benchmarks/benchmark_model_build.py --all --iterations 5
```

Available `--system` options: `complex`, `district`, `multiperiod`, `seasonal`, `synthetic`.
For `synthetic`, use `--converters`, `--timesteps`, and `--periods` to configure the system size.
Loading
Loading