‘The aim of FLEXINet is a system that accelerates the energy transition. We hope to make a substantial contribution to reaching climate targets by cleverly combining various techniques – think of blending recycled batteries with flexible heat pumps and the charging of electric cars.’
This repository contains the code for reproducing the Case Studies presented in Sequential Operation of Residential Energy Hubs using Physics-Based Economic Nonlinear MPC. The code is based on the EMSmodule library, JuMP.jl and InfiniteOpt.jl.
First, clone this repository and Pkg.instantiate() to install the dependencies.
The functions to run the EMS are in the files:
runFlex_cs1.jl # Script to run the Case Study 1: Residential Energy Hub under Sequential market operation with a perfect forecast
runFlex_cs2.jl # Script to run the Case Study 2: Residential Energy Hub under Seq. market operation with forecast errors
runFlex_cs3.jl # Script to run the Case Study 3: eFlex setup sensitivity under different tunning weight combinations.The plotting and analysis is done in the files:
cs1_flexAnalysis.jl # Script to analyze and plot the results of Case Study 1
notebooks/CS0_marketOp.ipynb
notebooks/CS1_flexAnalysis.ipynb
notebooks/CS2_flexAnalysis_monteCarlo.ipynb
notebooks/CS3_DegControl.ipynb
notebooks/priceAnalysis.ipynb # Price analysis to see the different market pricesFollowing the Universal Modelling Framework (UMF) this package implements Direct Lookahead (DLA) Policies. The DLA is a model-based policy that uses a model of the system to predict the future and optimize the control actions. The available DLAs are a day-ahead (DA) planner and a Model Predictive Controller (MPC). The basic algorithm is depicted in the following figure:
The DA planner uses a model of the system to predict the future and optimize the control actions for the next 24 hours. The MPC uses a model of the system to predict the future and optimize the control actions for the next 24 hours, but it also uses the actual measurements to update the model and the optimization problem every hour. The MPC is an economic non-linear MPC (NLP-eMPC) receding horizon controller.
The main function to run the sequential market operation is seqMarketLoop() in the runFlex_cs1.jl file. This function implements the sequential operation of the DA and MPC policies. The DA policy is solved first, and its results are used to initialize the MPC policy. The MPC policy is then solved, and its results are used to update the system state. This process is repeated for the entire simulation horizon.
This repository contains the work produced for the FLEXINET project by the DCE&S group, Electrical Sustainable Energy Dept. of the TU Delft. The work belongs to Dario Slaifstein, Gautam Rituraj, and Joel Alpizar.
MIT License
Cite as:
@article{Slaifstein2026,
author = {Darío Slaifstein and Gautham Ram Chandra Mouli and Laura Ramirez-Elizondo and Pavol Bauer},
doi = {10.1016/J.APENERGY.2026.127402},
issn = {0306-2619},
journal = {Applied Energy},
month = {4},
pages = {127402},
publisher = {Elsevier},
title = {Sequential operation of residential energy hubs using physics-based economic nonlinear MPC},
volume = {408},
url = {https://linkinghub.elsevier.com/retrieve/pii/S0306261926000541},
year = {2026}
}


