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.
flixOpt was developed by 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.
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.
Install flixOpt directly into your environment using pip. Thanks to HiGHS, flixOpt can be used without further setup.
pip install git+https://github.com/flixOpt/flixOpt.git
We recommend installing flixOpt with additional dependencies for visualizing network graphs using pyvis:
pip install "flixOpt[visualization] @ git+https://github.com/flixOpt/flixOpt.git"
- 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.
- 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
- Modeling On/Off-Variables and their constraints.
- 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
-
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.
-
flixOpt offers three calculation modes, tailored to different performance and accuracy needs:
-
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.
- Balances speed and accuracy, making it ideal for large-scale simulations.
-
Minimal coupling to Pyomo
-
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.
By default, flixOpt uses the open-source solver HiGHS which is installed by default. However, it is compatible with additional solvers such as:
Executables can be found for example here for CBC and here for GLPK (Windows: You have to put solver-executables to the PATH-variable)
For detailed licensing and installation instructions, refer to the respective solver documentation.
If you use flixOpt in your research or project, please cite the following:
- Main Citation: DOI:10.18086/eurosun.2022.04.07
- Short Overview: DOI:10.13140/RG.2.2.14948.24969
Run the tests using:
python -m unittest discover -s tests