Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
535 commits
Select commit Hold shift + click to select a range
3c0cabe
ruff checks
FBumann Mar 4, 2025
7641587
Update example to use labels
FBumann Mar 4, 2025
47e2f70
Handle numpy scalars in DataConverter
FBumann Mar 4, 2025
0591512
Improve dataset creation for export, minimizing filesize
FBumann Mar 4, 2025
fcc966a
Reorder classes in FlowSystem
FBumann Mar 4, 2025
9ee6163
Bugfix in io
FBumann Mar 4, 2025
1eb6f3e
Add to and from netcdf to the FlowSystem
FBumann Mar 4, 2025
cf6de0b
First step in updating test_integration.py to pytest
FBumann Mar 4, 2025
deb09c8
Connect the Network before storing start values in Segmented Calculation
FBumann Mar 4, 2025
415b547
Prevent warnings in tests
FBumann Mar 4, 2025
c7f91fd
Read TestComponents
FBumann Mar 4, 2025
c31e688
First try to add TestComplex back
FBumann Mar 4, 2025
a7b43d0
Bugfixes in test updates
FBumann Mar 5, 2025
788d9fb
Updated type hint
FBumann Mar 5, 2025
56b48b8
Move flow_systems from Test to conftest.py
FBumann Mar 5, 2025
d0ac83b
Improve conftest.py
FBumann Mar 5, 2025
c9214ec
Use common fucntion to create a nd solve a FlowSystem
FBumann Mar 5, 2025
a3163f7
Add tests for io
FBumann Mar 5, 2025
cea6b0a
Unified test fixtures
FBumann Mar 6, 2025
f4eaa1a
ruff checks
FBumann Mar 6, 2025
fcb5656
Add description for conftest.py
FBumann Mar 6, 2025
6005758
Merge pull request #172 from flixOpt/feature/linopy/io-testing
FBumann Mar 6, 2025
fab9368
Merge pull request #171 from flixOpt/next/patch
PStange Mar 7, 2025
36e5edd
Improve how to save the FlowSystem
FBumann Mar 7, 2025
4787535
create another fixture
FBumann Mar 7, 2025
d0a8a55
Update tests
FBumann Mar 7, 2025
6fe0b27
Update examples
FBumann Mar 7, 2025
5f3b454
Add long flow_system to test_io.py
FBumann Mar 7, 2025
980ed30
ruff check
FBumann Mar 7, 2025
b56d8f0
Merge pull request #170 from flixOpt/feature/linopy/io
FBumann Mar 7, 2025
7c5159a
Remove periods
FBumann Mar 8, 2025
1f42844
Simplify the DataConverter to only use timesteps, not periods
FBumann Mar 8, 2025
3658eed
Remove periods from TimeSeries
FBumann Mar 8, 2025
99f7ff5
Remove periods everywere
FBumann Mar 8, 2025
71c1798
Bugfix in DataConverter
FBumann Mar 9, 2025
42c2a88
Update DataCOnverter tests
FBumann Mar 9, 2025
f9759d5
Remove period artifacts
FBumann Mar 9, 2025
9f64ebe
Update TImeSeries tests and bugfix in TimeSeries
FBumann Mar 9, 2025
0a03c32
Improve TimeSeries class
FBumann Mar 9, 2025
be90859
Update tests
FBumann Mar 9, 2025
0c42e3f
Update TimeSeriesCollection
FBumann Mar 9, 2025
21dfbe7
Updated names in other places
FBumann Mar 9, 2025
3b31895
Removed coords from TimeSeriesCollection
FBumann Mar 9, 2025
2adcbe5
Merge pull request #175 from flixOpt/next/patch
FBumann Mar 10, 2025
e2f390b
Remove caching from TimeSeriesCollection
FBumann Mar 10, 2025
b37fafa
First test for TimeSeriesCollection
FBumann Mar 10, 2025
a8a5a98
Remove caching from tests
FBumann Mar 10, 2025
977a9fc
Bugfix test
FBumann Mar 10, 2025
0fd49cd
Bugfix TimeSeriesCollection
FBumann Mar 11, 2025
5dff805
Simplify to_dataset and handle slicing in to_dataframe()
FBumann Mar 11, 2025
72fc667
bugfix prevent_simultaneous_flows in SourceAndSink
Mar 11, 2025
88ccc7e
Improve to_dataset()
FBumann Mar 11, 2025
808616d
Merge pull request #176 from flixOpt/feature/linopy/bugfix_prevent_si…
FBumann Mar 11, 2025
fdf85c2
Add flag in FlowSystem to prevent multiple iterations of connecting t…
FBumann Mar 11, 2025
2839e11
Add additional test for io of FlowSystem
FBumann Mar 11, 2025
59192ec
Merge branch 'feature/linopy/main' into feature/linopy/no-periods-merge
FBumann Mar 11, 2025
f6394a7
Merge remote-tracking branch 'origin/next/major' into feature/linopy/…
FBumann Mar 11, 2025
7b9795e
Remove fixed_relative_profile from the FlowModel
FBumann Mar 11, 2025
8f1c9f2
Improve modeling of fixed flow_rate
FBumann Mar 11, 2025
065f7c0
Move plausibility checks to create_model() method
FBumann Mar 11, 2025
f8a4ff9
Bugfix in parameters of Highs
FBumann Mar 11, 2025
3ed81e9
ruff check and bugfixes
FBumann Mar 11, 2025
451005d
Change linopy dependency to use github instead of current latest release
FBumann Mar 11, 2025
2a65b9b
Bugfix i import
FBumann Mar 11, 2025
24a361f
ruff check
FBumann Mar 11, 2025
4b0e9f2
Missing dev dependencies
FBumann Mar 11, 2025
2404da9
Unify solver usage in tests
FBumann Mar 11, 2025
c5265e0
Remove fixture imports
FBumann Mar 11, 2025
d1d268b
Add timing to saving process of Calculation
FBumann Mar 13, 2025
4f9d80f
Improve code quality
FBumann Mar 13, 2025
ccd44fd
Rename flow_rates() to node_balance()
FBumann Mar 13, 2025
7ac0c59
Add property to access variables and constraints easier in Calculatio…
FBumann Mar 13, 2025
3136c63
Add Docstring to method
FBumann Mar 13, 2025
f0a0765
Merge pull request #178 from flixOpt/feature/linopy/no-periods-discuss
baumbude Mar 14, 2025
6c94930
changing Model._model to Model._sys_model
Mar 14, 2025
3993f6f
Revert "changing Model._model to Model._sys_model"
Mar 14, 2025
879a2c5
error-handling for unsolvable parameter combinations of initial_state…
Mar 16, 2025
090905b
check extended for InvestParameters
Mar 16, 2025
8800391
Move validation from Model to Element
FBumann Mar 17, 2025
5eba750
bugfix in max/min
Mar 17, 2025
9b0df10
Merge pull request #182 from flixOpt/feature/linopy/no-periods_initia…
baumbude Mar 17, 2025
e806d31
Merge pull request #181 from flixOpt/feature/linopy/no-periods_initia…
FBumann Mar 17, 2025
cea5d4d
Change saving routine
FBumann Mar 17, 2025
17ca855
Make saving of model optional
FBumann Mar 17, 2025
3501753
Add compression to results saving
FBumann Mar 17, 2025
be04e1f
Improve logic of wether to compress or not
FBumann Mar 17, 2025
3db0d9a
Update tests
FBumann Mar 17, 2025
a3d4d79
add .log to .gitignore
FBumann Mar 17, 2025
8c6c522
Bugfix saving the model
FBumann Mar 17, 2025
ee348f0
Improve
FBumann Mar 17, 2025
2ef329b
Remove save_model function from Calculation.
FBumann Mar 18, 2025
95c75d6
Include flow_system in results saving
FBumann Mar 18, 2025
5fc9147
Update all saving in examples and tests
FBumann Mar 18, 2025
8fa68df
Update results loading and saving
FBumann Mar 18, 2025
a13a5bf
Add special handling to previous values for saving to work
FBumann Mar 18, 2025
e9ec92e
Merge pull request #187 from flixOpt/next/patch
FBumann Mar 18, 2025
0477510
Add verbose flag to workflow
FBumann Mar 18, 2025
d87f460
Bugfix in import in workflow
FBumann Mar 18, 2025
e565670
Add release to pypi
FBumann Mar 18, 2025
0b6e257
Update project name
FBumann Mar 18, 2025
6bf55c2
Split to and from netcdf from as dataset for flow_system
FBumann Mar 18, 2025
c8557e2
Improve saving and loading
FBumann Mar 18, 2025
83bba92
Feature/docs (#189)
FBumann Mar 19, 2025
3befb87
Update docs dependencies
FBumann Mar 19, 2025
1a76684
Update workflow to run docs without release
FBumann Mar 19, 2025
33af58b
separate documentation workflow
FBumann Mar 19, 2025
b4a290b
separate documentation workflow
FBumann Mar 19, 2025
f061b2e
Add docs to Readme and pyproject.toml
FBumann Mar 19, 2025
4b96230
Bugfix docs
FBumann Mar 19, 2025
6b096e3
Fix formating
FBumann Mar 19, 2025
6971535
Update workflow to work without release
FBumann Mar 19, 2025
1e161d6
Update pip install commands to install from pypi
FBumann Mar 19, 2025
8595534
Make the docs more readable
FBumann Mar 19, 2025
699a219
Bugfix in docs
FBumann Mar 19, 2025
78827e0
Add possibilities to filter the solution.
FBumann Mar 19, 2025
acf0f1c
Update the filtering
FBumann Mar 19, 2025
4e6fb89
Make .variabes and .constraints to properties, that raise an error if…
FBumann Mar 19, 2025
55bedd7
Rename function
FBumann Mar 19, 2025
620f0aa
Add variables and constraints back to CalculationResults
FBumann Mar 19, 2025
e791e3b
Ensure to_dataset contains no views (copy data)
FBumann Mar 20, 2025
9f2d5f5
Reorder class
FBumann Mar 20, 2025
0aec66e
Reorder classes
FBumann Mar 20, 2025
29db677
Reorder classes
FBumann Mar 20, 2025
1ccbbcf
rename variable
FBumann Mar 20, 2025
9abdc43
Revert "Reorder classes"
FBumann Mar 20, 2025
8615864
Improve model documentation
FBumann Mar 20, 2025
acaf7d8
Add improved handling for infeasible models
FBumann Mar 20, 2025
a623079
Add improved handling for infeasible models
FBumann Mar 20, 2025
acbcb8a
Change filter key word
FBumann Mar 20, 2025
71a39f5
Change filter key word
FBumann Mar 20, 2025
edb8f76
Merge pull request #190 from flixOpt/feature/linopy/no-periods-save-w…
baumbude Mar 20, 2025
364a380
Move netcdf saving routine to io.py
FBumann Mar 21, 2025
16b4ded
Make loading the linopy model from file not break the code
FBumann Mar 21, 2025
8296bc2
Improve docstrings
FBumann Mar 21, 2025
7459fb1
Remove som io functions and move results structure into SystemModel
FBumann Mar 21, 2025
745d0df
Improve how results are saved
FBumann Mar 21, 2025
7640f0b
Update filenames of export
FBumann Mar 21, 2025
20ac5e2
Update test to load from correct path
FBumann Mar 21, 2025
1acd000
ruff check
FBumann Mar 23, 2025
9ce3ec9
Improve filenames and switch to .nc4
FBumann Mar 23, 2025
5f1ba64
Use an object to store the paths for saving
FBumann Mar 23, 2025
b701f99
Enable to change the name and folder of the Paths object
FBumann Mar 23, 2025
56d3813
rename path
FBumann Mar 23, 2025
1309dc1
improve CalculationPaths
FBumann Mar 23, 2025
40a443d
Update linopy dependency
FBumann Mar 23, 2025
8d6a926
Merge remote-tracking branch 'origin/main' into feature/linopy/no-per…
FBumann Mar 23, 2025
24deb11
Feature/linopy/docs (#180)
FBumann Mar 23, 2025
b783c0d
Merge branch 'feature/linopy/no-periods' into feature/linopy/no-perio…
FBumann Mar 23, 2025
78870ff
Merge remote-tracking branch 'origin/feature/linopy/no-periods' into …
FBumann Mar 23, 2025
568d07c
ruff check
FBumann Mar 23, 2025
e98a3fe
Update flixOpt architecture
FBumann Mar 23, 2025
9acc78e
Update the flix opt architecture png
FBumann Mar 23, 2025
c8712df
Update the README.md
FBumann Mar 23, 2025
6563058
Update landing page
FBumann Mar 23, 2025
4687f70
Update readme and landing page
FBumann Mar 23, 2025
cead481
Update docs
FBumann Mar 23, 2025
25fb343
Update docs
FBumann Mar 23, 2025
ca17378
Update docs
FBumann Mar 23, 2025
9449862
Add versioning to docs
FBumann Mar 23, 2025
6eba050
Add versioning to docs
FBumann Mar 23, 2025
ec78983
Improve docs
FBumann Mar 24, 2025
524e77b
Merge pull request #191 from flixOpt/feature/linopy/no-periods-io
baumbude Mar 24, 2025
6eedd53
Remove network infos from results and from export files
FBumann Mar 24, 2025
7ae77ae
Update example
FBumann Mar 24, 2025
a2981cb
ruff check
FBumann Mar 24, 2025
03a5c75
ruff check
FBumann Mar 24, 2025
66c8291
Create copy to ensure no changes in the original data
FBumann Mar 24, 2025
7d2b04e
Merge pull request #194 from flixOpt/feature/linopy/no-periods-remove…
baumbude Mar 24, 2025
791e9d7
Add pie plots
FBumann Mar 24, 2025
d583ec2
Improve santize_dataset() to be able to set certain values to 0 if be…
FBumann Mar 24, 2025
72c8a03
Improve pie plot
FBumann Mar 24, 2025
7ac2827
Improve pie plot
FBumann Mar 24, 2025
4f8972e
Update pie plot to show flow hours
FBumann Mar 25, 2025
9a97439
Improve grouping of pie plot
FBumann Mar 25, 2025
e38ef5e
Improve grouping of pie plot
FBumann Mar 25, 2025
0311942
Improve grouping of pie plot
FBumann Mar 25, 2025
b9b2e64
Add options to pie plot and add pie plots to examples
FBumann Mar 25, 2025
5be3fdd
BUGFIX: Always use timesteps_extra as the time index of the solution
FBumann Mar 25, 2025
ee850bf
BUGFIX: Treat nan as 0 when deciding which columns to drop in sanitiz…
FBumann Mar 25, 2025
11ace5e
Improve Exception
FBumann Mar 25, 2025
b9e3645
Improves Exception types all over the place
FBumann Mar 25, 2025
4ad50c8
ruff check
FBumann Mar 25, 2025
b8d7430
Improve docstring
FBumann Mar 26, 2025
a472e1c
Improve options for matplotlib
FBumann Mar 26, 2025
50b04f2
Add options to plot with matplotlib
FBumann Mar 26, 2025
97a5815
Merge branch 'feature/linopy/no-periods' into feature/linopy/no-perio…
FBumann Mar 26, 2025
557c273
Bugfix png export
FBumann Mar 26, 2025
914a122
Rename colormap in case of matplotlib
FBumann Mar 26, 2025
13ed095
Add engine options but raise Exceptions
FBumann Mar 26, 2025
0b30ff3
Add tests
FBumann Mar 26, 2025
2b87e8f
ruff check
FBumann Mar 26, 2025
7c81f93
Add custom colormap for "portland"
FBumann Mar 26, 2025
17bb2ab
Feature/linopy/no periods plotting (#197)
FBumann Mar 26, 2025
6bb4d79
Moving functions from results to plotting.py
FBumann Mar 26, 2025
69dcff9
formating
FBumann Mar 26, 2025
3a96fff
Remove save and show options from plotting methods.
FBumann Mar 26, 2025
cea9a45
Unify export of figures for both plotly and matplotlib
FBumann Mar 26, 2025
2b9f2fc
Improve path and filetype hanldling in export
FBumann Mar 26, 2025
50983cb
Use unified export possibilities for figures
FBumann Mar 26, 2025
0eb4764
improve test
FBumann Mar 26, 2025
21ec33d
Adjust pie_with_matplotlib()
FBumann Mar 26, 2025
fe604ce
Add dual pie with matplotlib method
FBumann Mar 26, 2025
6a4917d
plot pie with matplotlib
FBumann Mar 26, 2025
79fcf63
Fix title
FBumann Mar 26, 2025
bc3f6e3
Merge branch 'feature/linopy/no-periods' into feature/linopy/no-perio…
FBumann Mar 26, 2025
e7fc586
ruff check
FBumann Mar 26, 2025
dbaefa6
Merge pull request #200 from flixOpt/feature/linopy/no-periods-plotting
FBumann Mar 26, 2025
98a3410
Update example_calculation_types.py
FBumann Mar 26, 2025
80a62b8
Improve io of aggregation.py
FBumann Mar 26, 2025
e409281
ruff check
FBumann Mar 26, 2025
18b76b6
Improved color handling in plots
FBumann Mar 27, 2025
b25f9bc
ruff check
FBumann Mar 27, 2025
1a8652c
Bugfix in plotting.with_matplotlib() colors
FBumann Mar 27, 2025
ecf0079
Merge pull request #177 from flixOpt/feature/linopy/no-periods
FBumann Mar 27, 2025
8e26aca
Add netcdf to dependencies
FBumann Mar 27, 2025
f1e6c21
Improve Documentation (#195)
FBumann Mar 27, 2025
3a7121e
Piecewise fully remake (#204)
FBumann Mar 28, 2025
363807c
Bugfix in document_linopy_model
FBumann Mar 29, 2025
c9ed886
Feature/docs2 (#207)
FBumann Mar 29, 2025
e53b047
Update release notes (#205)
FBumann Mar 29, 2025
87a3ff0
Feature/rename to flixopt (#208)
FBumann Mar 29, 2025
796f7ad
Feature/format (#209)
FBumann Mar 29, 2025
e7f2053
Merge pull request #202 from flixOpt/next/major
FBumann Mar 29, 2025
3253d70
Bugfix release date
FBumann Mar 29, 2025
3ac8f93
Update release notes
FBumann Mar 29, 2025
6cac04c
Update workflow for docs
FBumann Mar 29, 2025
c35f553
Bugfixing docs buildt
FBumann Mar 29, 2025
228116f
Make workflow not depend on Testpy to work
FBumann Mar 29, 2025
fdd9e44
Update docs to use latest docs
FBumann Mar 29, 2025
963fc66
Update docs to use latest docs
FBumann Mar 29, 2025
2f12851
Add a check to prevent errors when reimporting the package
FBumann Mar 29, 2025
516096d
Replace "|" with "__" when Saving plots to file (#225)
PStange Apr 8, 2025
db1f7d8
Add warning if relative_minimum is used without on_off_parameters
FBumann Apr 8, 2025
b094b9e
Add more __ methods to TimeSeries to support comparisions
FBumann Apr 8, 2025
4a36f14
Fix comparison
FBumann Apr 8, 2025
15fdd33
Bugfix plausibility in Bus
FBumann Apr 8, 2025
3822a96
Bugfix of load_factor?
FBumann Apr 10, 2025
98bfea3
Change to object comparison instead of equality
FBumann Apr 10, 2025
45eff82
Update tests
FBumann Apr 10, 2025
74d0e04
Merge pull request #226 from flixOpt/fixes/relative_minimum
baumbude Apr 10, 2025
8f15e4e
Merge pull request #231 from flixOpt/fixes/load-factor
baumbude Apr 10, 2025
1c56813
Add release notes
FBumann Apr 10, 2025
c77ea75
Allow Python 3.13 (#217)
FBumann Apr 11, 2025
61d37ee
Fixes/tests (#234)
FBumann Apr 11, 2025
f9e2f04
Fixes/tests more (#239)
FBumann Apr 11, 2025
9ed6656
Feature/binary models (#235)
FBumann Apr 11, 2025
d240a0b
Update release notes and badges in README.md
FBumann Apr 11, 2025
7ad1bf3
Fix tests and docstrings (#242)
FBumann Apr 11, 2025
a49f53a
BUGFIX:Typo in _ElementResults.constraints
FBumann Apr 25, 2025
97a1aeb
Release notes
FBumann May 8, 2025
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
33 changes: 33 additions & 0 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Documentation

on:
release:
types: [created] # Automatically deploy docs on release
workflow_dispatch: # Allow manual triggering

jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install documentation dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"

- name: Deploy docs
run: |
VERSION=${GITHUB_REF#refs/tags/v}
mike deploy --push --update-aliases $VERSION latest
29 changes: 25 additions & 4 deletions .github/workflows/python-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
strategy:
fail-fast: false # Continue testing other Python versions if one fails
matrix:
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12', '3.13']

steps:
- name: Check out code
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

- name: Upload to TestPyPI
run: |
twine upload --repository testpypi dist/*
twine upload --repository testpypi dist/* --verbose
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
Expand All @@ -99,12 +99,12 @@ jobs:
(sleep 30 && pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ $PACKAGE_NAME) || \
(sleep 60 && pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ $PACKAGE_NAME)
# Basic import test
python -c "import $PACKAGE_NAME; print('Installation successful!')"
python -c "import flixopt; print('Installation successful!')"

publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-22.04
needs: [publish-testpypi] # Only run after TestPyPI publish succeeds
needs: [test] # Only run after TestPyPI publish succeeds
if: github.event_name == 'release' && github.event.action == 'created' # Only on release creation

steps:
Expand All @@ -124,3 +124,24 @@ jobs:
- name: Build the distribution
run: |
python -m build

- name: Upload to PyPI
run: |
twine upload dist/* --verbose
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

- name: Verify PyPI installation
run: |
# Create a temporary environment to test installation
python -m venv prod_test_env
source prod_test_env/bin/activate
# Get the package name from the built distribution
PACKAGE_NAME=$(ls dist/*.tar.gz | head -n 1 | sed 's/dist\///' | sed 's/-[0-9].*$//')
# Wait for PyPI to index the package
sleep 60
# Install from PyPI
pip install $PACKAGE_NAME
# Basic import test
python -c "import flixopt; print('PyPI installation successful!')"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
*.log
results/
.idea/
.venv/
Expand Down
138 changes: 45 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,134 +1,86 @@
# flixOpt: Energy and Material Flow Optimization Framework
# FlixOpt: Energy and Material Flow Optimization Framework

**flixOpt** is a Python-based optimization framework designed to tackle energy and material flow problems using mixed-integer linear programming (MILP). Combining flexibility and efficiency, it provides a powerful platform for both dispatch and investment optimization challenges.
[![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://flixopt.github.io/flixopt/latest/)
[![Build Status](https://github.com/flixOpt/flixopt/actions/workflows/python-app.yaml/badge.svg)](https://github.com/flixOpt/flixopt/actions/workflows/python-app.yaml)
[![PyPI version](https://img.shields.io/pypi/v/flixopt)](https://pypi.org/project/flixopt/)
[![Python Versions](https://img.shields.io/pypi/pyversions/flixopt.svg)](https://pypi.org/project/flixopt/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

---

## 🚀 Introduction
## 🚀 Purpose

flixOpt was developed by [TU Dresden](https://github.com/gewv-tu-dresden) as part of the SMARTBIOGRID project, funded by the German Federal Ministry for Economic Affairs and Energy (FKZ: 03KB159B). Building on the Matlab-based flixOptMat framework (developed in the FAKS project), flixOpt also incorporates concepts from [oemof/solph](https://github.com/oemof/oemof-solph).
**flixopt** is a Python-based optimization framework designed to tackle energy and material flow problems using mixed-integer linear programming (MILP).

Although flixOpt is in its early stages, it is fully functional and ready for experimentation. It is used for investment and operation decisions by energy providing companys as well as research institutions. Feedback and collaboration are highly encouraged to help shape its future.
**flixopt** bridges the gap between high-level energy systems models like [FINE](https://github.com/FZJ-IEK3-VSA/FINE) used for design and (multi-period) investment decisions and low-level dispatch optimization tools used for operation decisions.

---

## 📦 Installation
**flixopt** leverages the fast and efficient [linopy](https://github.com/PyPSA/linopy/) for the mathematical modeling and [xarray](https://github.com/pydata/xarray) for data handling.

Install flixOpt directly into your environment using pip. Thanks to [HiGHS](https://github.com/ERGO-Code/HiGHS?tab=readme-ov-file), flixOpt can be used without further setup.
`pip install git+https://github.com/flixOpt/flixopt.git`
**flixopt** provides a user-friendly interface with options for advanced users.

We recommend installing flixOpt with all dependencies, which enables interactive network visualizations by [pyvis](https://github.com/WestHealth/pyvis) and time series aggregation by [tsam](https://github.com/FZJ-IEK3-VSA/tsam).
`pip install "flixOpt[full] @ git+https://github.com/flixOpt/flixopt.git"`
It was originally developed by [TU Dresden](https://github.com/gewv-tu-dresden) as part of the SMARTBIOGRID project, funded by the German Federal Ministry for Economic Affairs and Energy (FKZ: 03KB159B). Building on the Matlab-based flixOptMat framework (developed in the FAKS project), FlixOpt also incorporates concepts from [oemof/solph](https://github.com/oemof/oemof-solph).

---

## 🌟 Key Features and Concepts

### 💡 High-level Interface...
- flixOpt aims to provide a user-friendly interface for defining and solving energy systems, without sacrificing fine-grained control where necessary.
- This is achieved through a high-level interface with many optional or default parameters.
- The most important concepts are:
- **FlowSystem**: Represents the System that is modeled.
- **Flow**: A Flow represents a stream of matter or energy. In an Energy-System, it could be electricity [kW]
- **Bus**: A Bus represents a balancing node in the Energy-System, typically connecting a demand to a supply.
- **Component**: A Component is a physical entity that consumes or produces matter or energy. It can also transform matter or energy into other kinds of matter or energy.
- **Effect**: Flows and Components can have Effects, related to their usage (or size). Common effects are *costs*, *CO2-emissions*, *primary-energy-demand* or *area-demand*. One Effect is used as the optimization target. The others can be constrained.
- To simplify the modeling process, high-level **Components** (CHP, Boiler, Heat Pump, Cooling Tower, Storage, etc.) are availlable.

### 🎛️ ...with low-level control
- **Segmented Linear Correlations**
- Accurate modeling for efficiencies, investment effects, and sizes.
- **On/Off Variables**
- Modeling On/Off-Variables and their constraints.
- On-Hours/Off-Hours
- Consecutive On-Hours/ Off-Hours
- Switch On/Off

### 💰 Investment Optimization
- flixOpt combines dispatch optimization with investment optimization in one model.
- Size and/or discrete investment decisions can be modeled
- Investment decisions can be combined with Modeling On/Off-Variables and their constraints

### Further Features
- **Multiple Effects**
- Couple effects (e.g., specific CO2 costs) and set constraints (e.g., max CO2 emissions).
- Easily switch between optimization targets (e.g., minimize CO2 or costs).
- This allows to solve questions like "How much does it cost to reduce CO2 emissions by 20%?"

- **Advanced Time Handling**
- Non-equidistant timesteps supported.
- Energy prices or effects in general can always be defined per hour (or per MWh...)

- A variety of predefined constraints for operational and investment optimization can be applied.
- Many of these are optional and only applied when necessary, keeping the amount o variables and equations low.

---
## 🌟 Key Features

## 🖥️ Usage Example
![Usage Example](https://github.com/user-attachments/assets/fa0e12fa-2853-4f51-a9e2-804abbefe20c)
- **High-level Interface** with low-level control
- User-friendly interface for defining flow systems
- Pre-defined components like CHP, Heat Pump, Cooling Tower, etc.
- Fine-grained control for advanced configurations

**Plotting examples**:
![flixOpt plotting](/pics/flixOpt_plotting.jpg)
- **Investment Optimization**
- Combined dispatch and investment optimization
- Size optimization and discrete investment decisions
- Combined with On/Off variables and constraints

## ⚙️ Calculation Modes
- **Effects, not only Costs --> Multi-criteria Optimization**
- flixopt abstracts costs as so called 'Effects'. This allows to model costs, CO2-emissions, primary-energy-demand or area-demand at the same time.
- Effects can interact with each other(e.g., specific CO2 costs)
- Any of these `Effects` can be used as the optimization objective.
- A **Weigted Sum** of Effects can be used as the optimization objective.
- Every Effect can be constrained ($\epsilon$-constraint method).

flixOpt offers three calculation modes, tailored to different performance and accuracy needs:
- **Calculation Modes**
- **Full** - Solve the model with highest accuracy and computational requirements.
- **Segmented** - Speed up solving by using a rolling horizon.
- **Aggregated** - Speed up solving by identifying typical periods using [TSAM](https://github.com/FZJ-IEK3-VSA/tsam). Suitable for large models.

- **Full Mode**
- Provides exact solutions with high computational requirements.
- Recommended for detailed analyses and investment decision problems.

- **Segmented Mode**
- Solving a Model segmentwise, this mode can speed up the solving process for complex systems, while being fairly accurate.
- Utilizes variable time overlap to improve accuracy.
- Not suitable for large storage systems or investment decisions.
---

- **Aggregated Mode**
- Automatically generates typical periods using [TSAM](https://github.com/FZJ-IEK3-VSA/tsam).
- Balances speed and accuracy, making it ideal for large-scale simulations.
## 📦 Installation

Install FlixOpt via pip.
`pip install flixopt`
With [HiGHS](https://github.com/ERGO-Code/HiGHS?tab=readme-ov-file) included out of the box, flixopt is ready to use..

## 🏗️ Architecture
We recommend installing FlixOpt with all dependencies, which enables additional features like interactive network visualizations ([pyvis](https://github.com/WestHealth/pyvis)) and time series aggregation ([tsam](https://github.com/FZJ-IEK3-VSA/tsam)).
`pip install "flixopt[full]"`

- **Minimal coupling to Pyomo**
- Included independent module is used to organize variables and equations, independently of a specific modeling language.
- While currently only working with [Pyomo](http://www.pyomo.org/), flixOpt is designed to work with different modeling languages with minor modifications ([cvxpy](https://www.cvxpy.org)).
---

- **File-based Post-Processing Unit**
- Results are saved to .json and .yaml files for easy access and analysis anytime.
- Internal plotting functions utilizing matplotlib, plotly and pandas simplify results visualization and reporting.
## 📚 Documentation

![Architecture Diagram](/pics/architecture_flixOpt.png)
The documentation is available at [https://flixopt.github.io/flixopt/latest/](https://flixopt.github.io/flixopt/latest/)

---

## 🛠️ Solver Integration

By default, flixOpt uses the open-source solver [HiGHS](https://highs.dev/) which is installed by default. However, it is compatible with additional solvers such as:
By default, FlixOpt uses the open-source solver [HiGHS](https://highs.dev/) which is installed by default. However, it is compatible with additional solvers such as:

- [CBC](https://github.com/coin-or/Cbc)
- [GLPK](https://www.gnu.org/software/glpk/)
- [Gurobi](https://www.gurobi.com/)
- [CBC](https://github.com/coin-or/Cbc)
- [GLPK](https://www.gnu.org/software/glpk/)
- [CPLEX](https://www.ibm.com/analytics/cplex-optimizer)

Executables can be found for example [here for CBC](https://portal.ampl.com/dl/open/cbc/) and [here for GLPK](https://sourceforge.net/projects/winglpk/) (Windows: You have to put solver-executables to the PATH-variable)

For detailed licensing and installation instructions, refer to the respective solver documentation.

---

## 📖 Citation

If you use flixOpt in your research or project, please cite the following:
If you use FlixOpt in your research or project, please cite the following:

- **Main Citation:** [DOI:10.18086/eurosun.2022.04.07](https://doi.org/10.18086/eurosun.2022.04.07)
- **Short Overview:** [DOI:10.13140/RG.2.2.14948.24969](https://doi.org/10.13140/RG.2.2.14948.24969)

---

## 🔧 Development and Testing

Run the tests using:

```bash
python -m unittest discover -s tests
7 changes: 7 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- [Home](index.md)
- [Getting Started](getting-started.md)
- [User Guide](user-guide/)
- [Examples](examples/)
- [FAQ](faq/)
- [API-Reference](api-reference/)
- [Release Notes](release-notes/)
49 changes: 49 additions & 0 deletions docs/contribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Contributing to the Project

We warmly welcome contributions from the community! This guide will help you get started with contributing to our project.

## Development Setup
1. Clone the repository `git clone https://github.com/flixOpt/flixopt.git`
2. Install the development dependencies `pip install -editable .[dev, docs]`
3. Run `pytest` and `ruff check .` to ensure your code passes all tests

## Documentation
FlixOpt uses [mkdocs](https://www.mkdocs.org/) to generate documentation. To preview the documentation locally, run `mkdocs serve` in the root directory.

## Helpful Commands
- `mkdocs serve` to preview the documentation locally. Navigate to `http://127.0.0.1:8000/` to view the documentation.
- `pytest` to run the test suite (You can also run the provided python script `run_all_test.py`)
- `ruff check .` to run the linter
- `ruff check . --fix` to automatically fix linting issues

---
# Best practices

## Coding Guidelines

- Follow PEP 8 style guidelines
- Write clear, commented code
- Include type hints
- Create or update tests for new functionality
- Ensure 100% test coverage for new code

## Branches
As we start to think FlixOpt in **Releases**, we decided to introduce multiple **dev**-branches instead of only one:
Following the **Semantic Versioning** guidelines, we introduced:
- `next/patch`: This is where all pull requests for the next patch release (1.0.x) go.
- `next/minor`: This is where all pull requests for the next minor release (1.x.0) go.
- `next/major`: This is where all pull requests for the next major release (x.0.0) go.

Everything else remains in `feature/...`-branches.

## Pull requests
Every feature or bugfix should be merged into one of the 3 [release branches](#branches), using **Squash and merge** or a regular **single commit**.
At some point, `next/minor` or `next/major` will get merged into `main` using a regular **Merge** (not squash).
*This ensures that Features are kept separate, and the `next/...`branches stay in synch with ``main`.*

## Releases
As stated, we follow **Semantic Versioning**.
Right after one of the 3 [release branches](#branches) is merged into main, a **Tag** should be added to the merge commit and pushed to the main branch. The tag has the form `v1.2.3`.
With this tag, a release with **Release Notes** must be created.

*This is our current best practice*
5 changes: 5 additions & 0 deletions docs/examples/00-Minimal Example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Minimal Example

```python
{! ../examples/00_Minmal/minimal_example.py !}
```
5 changes: 5 additions & 0 deletions docs/examples/01-Basic Example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Simple example

```python
{! ../examples/01_Simple/simple_example.py !}
```
10 changes: 10 additions & 0 deletions docs/examples/02-Complex Example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Complex example
This saves the results of a calculation to file and reloads them to analyze the results
## Build the Model
```python
{! ../examples/02_Complex/complex_example.py !}
```
## Load the Results from file
```python
{! ../examples/02_Complex/complex_example_results.py !}
```
5 changes: 5 additions & 0 deletions docs/examples/03-Calculation Modes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Calculation Mode comparison
**Note:** This example relies on time series data. You can find it in the `examples` folder of the FlixOpt repository.
```python
{! ../examples/03_Calculation_types/example_calculation_types.py !}
```
5 changes: 5 additions & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Examples

Here you can find a collection of examples that demonstrate how to use FlixOpt.

We work on improving this gallery. If you have something to share, please contact us!
Loading
Loading