File Exchange

image thumbnail

Microgrid Energy Management System (EMS) using Optimization

version 19.1.0 (1.13 MB) by Jonathan LeSage
Online optimization of energy storage actions in a microgrid given system constraints and pricing


Updated 17 Apr 2020

From GitHub

View Version History

View license on GitHub

Energy management systems (EMS) help to optimize the usages of distributed energy resources (DERs) in microgrids, particularly when variable pricing and generation are involved. This example walks through the process of developing an optimization routine that uses forecast pricing and loading conditions to optimally store/sell energy from a grid-scale battery system. Two approaches are demonstrated: a heuristic state machine strategy and the linear program-based optimization approach.

The main example uses a full microgrid simulation for validation of the EMS optimization algorithm. However, there is a purely MATLAB/Optimization Toolbox example that shows the formulation of the optimization without the validation study.

Cite As

Jonathan LeSage (2021). Microgrid Energy Management System (EMS) using Optimization (, GitHub. Retrieved .

Comments and Ratings (24)

Khaled Chehab

Such great work. Would you please send me the file or the report that you have made for this work to

I need to see some equations of the battery, since I am working on developing a smart algorithm

I hopet o hear from you. Thanks in advance

静茹 侯

Muhammad Kashif

Good work, Can you please share the paper you worked on,

Huang titan

Good design!! But if possible could you share the Simulink files. MATLAB 2015a.

Much more appreciated. Thanks for your help!!

Ananta nafis afifandi

Great work. If possible could you share the Simulink files. MATLAB 2018b.

Much appreciated. Thank you.

Jack Zhang

Robert Bate

Robert Bate

Great work. If possible could you share the Simulink files. MATLAB 2017a.

Much appreciated. Thank you.

Omar Alvarez

Excellent work sir, could you send me the file in the Matab2019a version,
Thanks in advance.


Can you provide the simulation file in Matlab 2013b, please? email:-

Ferahtia Sidali

Great work sir, can you send me in a previous version (2016a)

L. Ortiz



anyone help me to understand the code ..

Jigar Sarda


how can i know codes written in detail ?

Jigar Sarda

Respected sir,

Sir can you provide the model in lower version?

mira daher

Thank you for sharing this .. Can you please attach the paper you worked on ?

Ziyao Wang

ali al-khayyat

Can you provide the simulation file in Matlab 2019a, please?


Thank you for sharing

sajid ali

Mr LeSage, can you provide the simulink file in ver 2019a?

Tan Yong Shen

Dear sir, thank you for the amazing stuffs and references. However the pv irradiance combo box, slider switch block and the call back button block was unrecognized when loading the simulink model.

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!