flixopt 3.0.1__py3-none-any.whl → 6.0.0rc7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. flixopt/__init__.py +57 -49
  2. flixopt/carrier.py +159 -0
  3. flixopt/clustering/__init__.py +51 -0
  4. flixopt/clustering/base.py +1746 -0
  5. flixopt/clustering/intercluster_helpers.py +201 -0
  6. flixopt/color_processing.py +372 -0
  7. flixopt/comparison.py +819 -0
  8. flixopt/components.py +848 -270
  9. flixopt/config.py +853 -496
  10. flixopt/core.py +111 -98
  11. flixopt/effects.py +294 -284
  12. flixopt/elements.py +484 -223
  13. flixopt/features.py +220 -118
  14. flixopt/flow_system.py +2026 -389
  15. flixopt/interface.py +504 -286
  16. flixopt/io.py +1718 -55
  17. flixopt/linear_converters.py +291 -230
  18. flixopt/modeling.py +304 -181
  19. flixopt/network_app.py +2 -1
  20. flixopt/optimization.py +788 -0
  21. flixopt/optimize_accessor.py +373 -0
  22. flixopt/plot_result.py +143 -0
  23. flixopt/plotting.py +1177 -1034
  24. flixopt/results.py +1331 -372
  25. flixopt/solvers.py +12 -4
  26. flixopt/statistics_accessor.py +2412 -0
  27. flixopt/stats_accessor.py +75 -0
  28. flixopt/structure.py +954 -120
  29. flixopt/topology_accessor.py +676 -0
  30. flixopt/transform_accessor.py +2277 -0
  31. flixopt/types.py +120 -0
  32. flixopt-6.0.0rc7.dist-info/METADATA +290 -0
  33. flixopt-6.0.0rc7.dist-info/RECORD +36 -0
  34. {flixopt-3.0.1.dist-info → flixopt-6.0.0rc7.dist-info}/WHEEL +1 -1
  35. flixopt/aggregation.py +0 -382
  36. flixopt/calculation.py +0 -672
  37. flixopt/commons.py +0 -51
  38. flixopt/utils.py +0 -86
  39. flixopt-3.0.1.dist-info/METADATA +0 -209
  40. flixopt-3.0.1.dist-info/RECORD +0 -26
  41. {flixopt-3.0.1.dist-info → flixopt-6.0.0rc7.dist-info}/licenses/LICENSE +0 -0
  42. {flixopt-3.0.1.dist-info → flixopt-6.0.0rc7.dist-info}/top_level.txt +0 -0
flixopt/commons.py DELETED
@@ -1,51 +0,0 @@
1
- """
2
- This module makes the commonly used classes and functions available in the flixopt framework.
3
- """
4
-
5
- from . import linear_converters, plotting, results, solvers
6
- from .aggregation import AggregationParameters
7
- from .calculation import AggregatedCalculation, FullCalculation, SegmentedCalculation
8
- from .components import (
9
- LinearConverter,
10
- Sink,
11
- Source,
12
- SourceAndSink,
13
- Storage,
14
- Transmission,
15
- )
16
- from .config import CONFIG, change_logging_level
17
- from .core import TimeSeriesData
18
- from .effects import Effect
19
- from .elements import Bus, Flow
20
- from .flow_system import FlowSystem
21
- from .interface import InvestParameters, OnOffParameters, Piece, Piecewise, PiecewiseConversion, PiecewiseEffects
22
-
23
- __all__ = [
24
- 'TimeSeriesData',
25
- 'CONFIG',
26
- 'change_logging_level',
27
- 'Flow',
28
- 'Bus',
29
- 'Effect',
30
- 'Source',
31
- 'Sink',
32
- 'SourceAndSink',
33
- 'Storage',
34
- 'LinearConverter',
35
- 'Transmission',
36
- 'FlowSystem',
37
- 'FullCalculation',
38
- 'SegmentedCalculation',
39
- 'AggregatedCalculation',
40
- 'InvestParameters',
41
- 'OnOffParameters',
42
- 'Piece',
43
- 'Piecewise',
44
- 'PiecewiseConversion',
45
- 'PiecewiseEffects',
46
- 'AggregationParameters',
47
- 'plotting',
48
- 'results',
49
- 'linear_converters',
50
- 'solvers',
51
- ]
flixopt/utils.py DELETED
@@ -1,86 +0,0 @@
1
- """
2
- This module contains several utility functions used throughout the flixopt framework.
3
- """
4
-
5
- from __future__ import annotations
6
-
7
- import logging
8
- from typing import Any, Literal
9
-
10
- import numpy as np
11
- import xarray as xr
12
-
13
- logger = logging.getLogger('flixopt')
14
-
15
-
16
- def round_nested_floats(obj: dict | list | float | int | Any, decimals: int = 2) -> dict | list | float | int | Any:
17
- """Recursively round floating point numbers in nested data structures.
18
-
19
- This function traverses nested data structures (dictionaries, lists) and rounds
20
- any floating point numbers to the specified number of decimal places. It handles
21
- various data types including NumPy arrays and xarray DataArrays by converting
22
- them to lists with rounded values.
23
-
24
- Args:
25
- obj: The object to process. Can be a dict, list, float, int, numpy.ndarray,
26
- xarray.DataArray, or any other type.
27
- decimals (int, optional): Number of decimal places to round to. Defaults to 2.
28
-
29
- Returns:
30
- The processed object with the same structure as the input, but with all floating point numbers rounded to the specified precision. NumPy arrays and xarray DataArrays are converted to lists.
31
-
32
- Examples:
33
- >>> data = {'a': 3.14159, 'b': [1.234, 2.678]}
34
- >>> round_nested_floats(data, decimals=2)
35
- {'a': 3.14, 'b': [1.23, 2.68]}
36
-
37
- >>> import numpy as np
38
- >>> arr = np.array([1.234, 5.678])
39
- >>> round_nested_floats(arr, decimals=1)
40
- [1.2, 5.7]
41
- """
42
- if isinstance(obj, dict):
43
- return {k: round_nested_floats(v, decimals) for k, v in obj.items()}
44
- elif isinstance(obj, list):
45
- return [round_nested_floats(v, decimals) for v in obj]
46
- elif isinstance(obj, float):
47
- return round(obj, decimals)
48
- elif isinstance(obj, int):
49
- return obj
50
- elif isinstance(obj, np.ndarray):
51
- return np.round(obj, decimals).tolist()
52
- elif isinstance(obj, xr.DataArray):
53
- return obj.round(decimals).values.tolist()
54
- return obj
55
-
56
-
57
- def convert_dataarray(
58
- data: xr.DataArray, mode: Literal['py', 'numpy', 'xarray', 'structure']
59
- ) -> list | np.ndarray | xr.DataArray | str:
60
- """
61
- Convert a DataArray to a different format.
62
-
63
- Args:
64
- data: The DataArray to convert.
65
- mode: The mode to convert to.
66
- - 'py': Convert to python native types (for json)
67
- - 'numpy': Convert to numpy array
68
- - 'xarray': Convert to xarray.DataArray
69
- - 'structure': Convert to strings (for structure, storing variable names)
70
-
71
- Returns:
72
- The converted data.
73
-
74
- Raises:
75
- ValueError: If the mode is unknown.
76
- """
77
- if mode == 'numpy':
78
- return data.values
79
- elif mode == 'py':
80
- return data.values.tolist()
81
- elif mode == 'xarray':
82
- return data
83
- elif mode == 'structure':
84
- return f':::{data.name}'
85
- else:
86
- raise ValueError(f'Unknown mode {mode}')
@@ -1,209 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: flixopt
3
- Version: 3.0.1
4
- Summary: Vector based energy and material flow optimization framework in Python.
5
- Author-email: "Chair of Building Energy Systems and Heat Supply, TU Dresden" <peter.stange@tu-dresden.de>, Felix Bumann <felixbumann387@gmail.com>, Felix Panitz <baumbude@googlemail.com>, Peter Stange <peter.stange@tu-dresden.de>
6
- Maintainer-email: Felix Bumann <felixbumann387@gmail.com>, Peter Stange <peter.stange@tu-dresden.de>
7
- License-Expression: MIT
8
- Project-URL: homepage, https://tu-dresden.de/ing/maschinenwesen/iet/gewv/forschung/forschungsprojekte/flixopt
9
- Project-URL: repository, https://github.com/flixOpt/flixopt
10
- Project-URL: documentation, https://flixopt.github.io/flixopt/
11
- Keywords: optimization,energy systems,numerical analysis
12
- Classifier: Development Status :: 3 - Alpha
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Classifier: Programming Language :: Python :: 3.13
17
- Classifier: Intended Audience :: Developers
18
- Classifier: Intended Audience :: Science/Research
19
- Classifier: Topic :: Scientific/Engineering
20
- Requires-Python: >=3.10
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: numpy<3,>=1.21.5
24
- Requires-Dist: pandas<3,>=2.0.0
25
- Requires-Dist: xarray<2026.0,>=2024.2.0
26
- Requires-Dist: linopy<0.6,>=0.5.1
27
- Requires-Dist: h5netcdf<2,>=1.0.0
28
- Requires-Dist: pyyaml<7,>=6.0.0
29
- Requires-Dist: rich<15,>=13.0.0
30
- Requires-Dist: tomli<3,>=2.0.1; python_version < "3.11"
31
- Requires-Dist: highspy<2,>=1.5.3
32
- Requires-Dist: matplotlib<4,>=3.5.2
33
- Requires-Dist: plotly<7,>=5.15.0
34
- Requires-Dist: numexpr<2.14,>=2.8.4; python_version < "3.11"
35
- Provides-Extra: network-viz
36
- Requires-Dist: dash<4,>=3.0.0; extra == "network-viz"
37
- Requires-Dist: dash-cytoscape<2,>=1.0.0; extra == "network-viz"
38
- Requires-Dist: dash-daq<1,>=0.6.0; extra == "network-viz"
39
- Requires-Dist: networkx<4,>=3.0.0; extra == "network-viz"
40
- Requires-Dist: werkzeug<4,>=3.0.0; extra == "network-viz"
41
- Requires-Dist: flask<4,>=3.0.0; extra == "network-viz"
42
- Provides-Extra: full
43
- Requires-Dist: pyvis==0.3.2; extra == "full"
44
- Requires-Dist: tsam<3,>=2.3.1; extra == "full"
45
- Requires-Dist: scipy<2,>=1.15.1; extra == "full"
46
- Requires-Dist: gurobipy<13,>=10.0.0; extra == "full"
47
- Requires-Dist: dash<4,>=3.0.0; extra == "full"
48
- Requires-Dist: dash-cytoscape<2,>=1.0.0; extra == "full"
49
- Requires-Dist: dash-daq<1,>=0.6.0; extra == "full"
50
- Requires-Dist: networkx<4,>=3.0.0; extra == "full"
51
- Requires-Dist: werkzeug<4,>=3.0.0; extra == "full"
52
- Requires-Dist: flask<4,>=3.0.0; extra == "full"
53
- Provides-Extra: dev
54
- Requires-Dist: pytest==8.4.2; extra == "dev"
55
- Requires-Dist: pytest-xdist==3.8.0; extra == "dev"
56
- Requires-Dist: nbformat==5.10.4; extra == "dev"
57
- Requires-Dist: ruff==0.13.3; extra == "dev"
58
- Requires-Dist: pre-commit==4.3.0; extra == "dev"
59
- Requires-Dist: pyvis==0.3.2; extra == "dev"
60
- Requires-Dist: tsam==2.3.9; extra == "dev"
61
- Requires-Dist: scipy==1.15.1; extra == "dev"
62
- Requires-Dist: gurobipy==12.0.3; extra == "dev"
63
- Requires-Dist: dash==3.0.0; extra == "dev"
64
- Requires-Dist: dash-cytoscape==1.0.2; extra == "dev"
65
- Requires-Dist: dash-daq==0.6.0; extra == "dev"
66
- Requires-Dist: networkx==3.0.0; extra == "dev"
67
- Requires-Dist: werkzeug==3.0.0; extra == "dev"
68
- Provides-Extra: docs
69
- Requires-Dist: mkdocs-material==9.6.21; extra == "docs"
70
- Requires-Dist: mkdocstrings-python==1.18.2; extra == "docs"
71
- Requires-Dist: mkdocs-table-reader-plugin==3.1.0; extra == "docs"
72
- Requires-Dist: mkdocs-gen-files==0.5.0; extra == "docs"
73
- Requires-Dist: mkdocs-include-markdown-plugin==7.1.7; extra == "docs"
74
- Requires-Dist: mkdocs-literate-nav==0.6.2; extra == "docs"
75
- Requires-Dist: markdown-include==0.8.1; extra == "docs"
76
- Requires-Dist: pymdown-extensions==10.16.1; extra == "docs"
77
- Requires-Dist: pygments==2.19.2; extra == "docs"
78
- Requires-Dist: mike==2.1.3; extra == "docs"
79
- Dynamic: license-file
80
-
81
- # FlixOpt: Energy and Material Flow Optimization Framework
82
-
83
- [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://flixopt.github.io/flixopt/latest/)
84
- [![Build Status](https://github.com/flixOpt/flixopt/actions/workflows/python-app.yaml/badge.svg)](https://github.com/flixOpt/flixopt/actions/workflows/python-app.yaml)
85
- [![PyPI version](https://img.shields.io/pypi/v/flixopt)](https://pypi.org/project/flixopt/)
86
- [![Python Versions](https://img.shields.io/pypi/pyversions/flixopt.svg)](https://pypi.org/project/flixopt/)
87
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
88
-
89
- ---
90
-
91
- ## 🎯 Vision
92
-
93
- **FlixOpt aims to be the most accessible and flexible Python framework for energy and material flow optimization.**
94
-
95
- We believe that optimization modeling should be **approachable for beginners** yet **powerful for experts**. Too often, frameworks force you to choose between ease of use and flexibility. FlixOpt refuses this compromise.
96
-
97
- ### Where We're Going
98
-
99
- **Short-term goals:**
100
- - **Multi-dimensional modeling**: Full support for multi-period investments and scenario-based stochastic optimization (periods and scenarios are in active development)
101
- - **Enhanced component library**: More pre-built, domain-specific components (sector coupling, hydrogen systems, thermal networks, demand-side management)
102
-
103
- **Medium-term vision:**
104
- - **Modeling to generate alternatives (MGA)**: Built-in support for exploring near-optimal solution spaces to produce more robust, diverse solutions under uncertainty
105
- - **Interactive tutorials**: Browser-based, reactive tutorials for learning FlixOpt without local installation
106
- - **Standardized cost calculations**: Align with industry standards (VDI 2067) for CAPEX/OPEX calculations
107
- - **Advanced result analysis**: Time-series aggregation, automated reporting, and rich visualization options
108
-
109
- **Long-term vision:**
110
- - **Showcase universal applicability**: FlixOpt already handles any flow-based system (supply chains, water networks, production planning, chemical processes) - we need more examples and domain-specific component libraries to demonstrate this
111
- - **Seamless integration**: First-class support for coupling with simulation tools, databases, existing energy system models, and GIS data
112
- - **Robust optimization**: Built-in uncertainty quantification and stochastic programming capabilities
113
- - **Community ecosystem**: Rich library of user-contributed components, examples, and domain-specific extensions
114
- - **Model validation tools**: Automated checks for physical plausibility, data consistency, and common modeling errors
115
-
116
- ### Why FlixOpt Exists
117
-
118
- FlixOpt is a **general-purpose framework for modeling any system involving flows and conversions** - energy, materials, fluids, goods, or data. While energy systems are our primary focus, the same mathematical foundation applies to supply chains, water networks, production lines, and more.
119
-
120
- We bridge the gap between high-level strategic models (like [FINE](https://github.com/FZJ-IEK3-VSA/FINE)) for long-term planning and low-level dispatch tools for operations. FlixOpt is the **sweet spot** for:
121
-
122
- - **Researchers** who need to prototype quickly but may require deep customization later
123
- - **Engineers** who want reliable, tested components without black-box abstractions
124
- - **Students** learning optimization who benefit from clear, Pythonic interfaces
125
- - **Practitioners** who need to move from model to production-ready results
126
- - **Domain experts** from any field where things flow, transform, and need optimizing
127
-
128
- Built on modern foundations ([linopy](https://github.com/PyPSA/linopy/) and [xarray](https://github.com/pydata/xarray)), FlixOpt delivers both **performance** and **transparency**. You can inspect everything, extend anything, and trust that your model does exactly what you designed.
129
-
130
- Originally developed at [TU Dresden](https://github.com/gewv-tu-dresden) for the SMARTBIOGRID project (funded by the German Federal Ministry for Economic Affairs and Energy, FKZ: 03KB159B), FlixOpt has evolved from the Matlab-based flixOptMat framework while incorporating the best ideas from [oemof/solph](https://github.com/oemof/oemof-solph).
131
-
132
- ---
133
-
134
- ## 🌟 What Makes FlixOpt Different
135
-
136
- ### Start Simple, Scale Complex
137
- Define a working model in minutes with high-level components, then drill down to fine-grained control when needed. No rewriting, no framework switching.
138
-
139
- ```python
140
- import flixopt as fx
141
-
142
- # Simple start
143
- boiler = fx.Boiler("Boiler", eta=0.9, ...)
144
-
145
- # Advanced control when needed - extend with native linopy
146
- boiler.model.add_constraints(custom_constraint, name="my_constraint")
147
- ```
148
-
149
- ### Multi-Criteria Optimization Done Right
150
- Model costs, emissions, resource use, and any custom metric simultaneously as **Effects**. Optimize any single Effect, use weighted combinations, or apply ε-constraints:
151
-
152
- ```python
153
- costs = fx.Effect('costs', '€', 'Total costs',
154
- share_from_temporal={'CO2': 180}) # 180 €/tCO2
155
- co2 = fx.Effect('CO2', 'kg', 'Emissions', maximum_periodic=50000)
156
- ```
157
-
158
- ### Performance at Any Scale
159
- Choose the right calculation mode for your problem:
160
- - **Full** - Maximum accuracy for smaller problems
161
- - **Segmented** - Rolling horizon for large time series
162
- - **Aggregated** - Typical periods using [TSAM](https://github.com/FZJ-IEK3-VSA/tsam) for massive models
163
-
164
- ### Built for Reproducibility
165
- Every result file is self-contained with complete model information. Load it months later and know exactly what you optimized. Export to NetCDF, share with colleagues, archive for compliance.
166
-
167
- ---
168
-
169
- ## 🚀 Quick Start
170
-
171
- ```bash
172
- pip install flixopt
173
- ```
174
-
175
- That's it. FlixOpt comes with the [HiGHS](https://highs.dev/) solver included - you're ready to optimize.
176
- Many more solvers are supported (gurobi, cplex, cbc, glpk, ...)
177
-
178
- For additional features (interactive network visualization, time series aggregation):
179
- ```bash
180
- pip install "flixopt[full]"
181
- ```
182
-
183
- **Next steps:**
184
- - 📚 [Full Documentation](https://flixopt.github.io/flixopt/latest/)
185
- - 💡 [Examples](https://flixopt.github.io/flixopt/latest/examples/)
186
- - 🔧 [API Reference](https://flixopt.github.io/flixopt/latest/api-reference/)
187
-
188
- ---
189
-
190
- ## 🤝 Contributing
191
-
192
- FlixOpt thrives on community input. Whether you're fixing bugs, adding components, improving docs, or sharing use cases - we welcome your contributions.
193
-
194
- See our [contribution guide](https://flixopt.github.io/flixopt/latest/contribute/) to get started.
195
-
196
- ---
197
-
198
- ## 📖 Citation
199
-
200
- If FlixOpt supports your research or project, please cite:
201
-
202
- - **Main Citation:** [DOI:10.18086/eurosun.2022.04.07](https://doi.org/10.18086/eurosun.2022.04.07)
203
- - **Short Overview:** [DOI:10.13140/RG.2.2.14948.24969](https://doi.org/10.13140/RG.2.2.14948.24969)
204
-
205
- ---
206
-
207
- ## 📄 License
208
-
209
- MIT License - See [LICENSE](https://github.com/flixopt/flixopt/blob/main/LICENSE) for details.
@@ -1,26 +0,0 @@
1
- flixopt/__init__.py,sha256=8F0MKV9GAsFSP5OCZgn1dwzGD7-bZpsmVnTVe56ZcU8,2204
2
- flixopt/aggregation.py,sha256=P374vIJc1ZcPxxG8dfCPgUKNLRNP2kf8Y-sc1JOA45U,16191
3
- flixopt/calculation.py,sha256=jeJzTazlG-KJh4M5VMlEqF-_nwIdtVYN3Z94CfKG8yI,29661
4
- flixopt/commons.py,sha256=ZNlUN1z-h9OGHPo-s-n5OLlJaoPZKVGcAdRyGKpMk4M,1256
5
- flixopt/components.py,sha256=bm76uCaXkeLuDBfsJ1kjfaHOl8zmow2JTaNPCK4Jknc,57757
6
- flixopt/config.py,sha256=kB-KyPKtmHoK1zwGp1HV8iJShVsjmi2d5SrGmL_uHxA,22000
7
- flixopt/core.py,sha256=OG789eUaS5Lu0CjJiMIdtaixqnV5ZtMiKfERjCPRTv8,26366
8
- flixopt/effects.py,sha256=iLVC4VdFTtZaF6B8BJiILRwe9ahj93og8JQSaAE_ocI,34063
9
- flixopt/elements.py,sha256=D4EkYZxqtyBhpTYf6C82pBRJf5fjyGXxZ8HMNiaHCuA,36156
10
- flixopt/features.py,sha256=kd-fMvADv8GXoKkrXObYjRJLN8toBG-5bOHTuh-59kk,25073
11
- flixopt/flow_system.py,sha256=D84MIkX5oA_4H55p9mOC7tstV96V5RN2qPeJ2exX1ks,40242
12
- flixopt/interface.py,sha256=iLc2-_adqSeljlJrX6tao8IxBCQcksq4S7HQDw9L_OM,57503
13
- flixopt/io.py,sha256=2ZnpoU4gVnKfv-FiwoYEA11wlqbdUU8PXJiofRSKl5M,11795
14
- flixopt/linear_converters.py,sha256=tcz5c1SI36hRFbCX-4NXced12ss9VETg5BE7zOdyeo4,22699
15
- flixopt/modeling.py,sha256=s0zipbblq-LJrSe7angKT3Imxgr3kIbprG98HUvmkzI,31322
16
- flixopt/network_app.py,sha256=LnVAlAgzL1BgMYLsJ20a62j6nQUmNccF1zo4ACUXzL4,29433
17
- flixopt/plotting.py,sha256=lHeSwfSaQCGP2w54S8CzSa7sWwCxMcWci1EU1TYqLWM,60909
18
- flixopt/results.py,sha256=rgyYJTcgF1DOxYSvKM__BTfVU13o13DwSBjvA4o4gdM,77773
19
- flixopt/solvers.py,sha256=m38Smc22MJfHYMiqfNf1MA3OmvbTRm5OWS9nECkDdQk,2355
20
- flixopt/structure.py,sha256=ntLoj--zTnaZwNYKw-WkJTNxY0ef4zDp4S0iiSxyyxE,47707
21
- flixopt/utils.py,sha256=CtCMBjvq31upz7i-_1nbPnSe-1CoRoOWlPkucwiSo5Q,2930
22
- flixopt-3.0.1.dist-info/licenses/LICENSE,sha256=HKsZnbrM_3Rvnr_u9cWSG90cBsj5_slaqI_z_qcxnGI,1118
23
- flixopt-3.0.1.dist-info/METADATA,sha256=TJLBIM5v232UVDWCn5Mrq0-HAfjTW0OBUNC8KbQQIPY,10776
24
- flixopt-3.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- flixopt-3.0.1.dist-info/top_level.txt,sha256=fanTzb9NylIXfv6Ic7spU97fVmRgGDPKvI_91tw4S3E,8
26
- flixopt-3.0.1.dist-info/RECORD,,