# An Imitation Learning Method with Multi Virtual Agents for Microgrid Energy Optimization under Interrupted Periods
We propose a multi-virtual-agent imitation learning approach to learn the dispatch policy of the microgrid energy system under different power supply interrupted periods. Multi-virtual agents are used for exploring the relationship of uncertainties and corresponding actions in different microgrid environments in parallel. For more details, please see our paper:
[An Imitation Learning Method with Multi Virtual Agents for Microgrid Energy Optimization under Interrupted Periods.pdf](https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/files/14512270/An.Imitation.Learning.Method.with.Multi.virtual.Agents.for.Microgrid.Energy.Optimization.under.Interrupted.Periods.pdf)
## **Citation**
**If you find this research useful, please cite these papers when you use this code.**
```
@INPROCEEDINGS{Lin_MAIL,
author={Lin, Yanbin and Ni, Zhen and Tang, Yufei},
booktitle={2024 IEEE Power & Energy Society General Meeting (PESGM)},
title={An Imitation Learning Method with Multi-Virtual Agents for Microgrid Energy Optimization under Interrupted Periods},
year={2024},
pages={1-5},
keywords={Imitation learning, interrupted power supply, deep neural networks, machine learning, multi-virtual agents, and microgrid energy scheduling},
doi={}}
```
For detailed system model description, please see this paper: [A Modified Maximum Entropy Inverse Reinforcement Learning Approach for Microgrid Energy Scheduling.pdf](https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/files/14559667/A.Modified.Maximum.Entropy.Inverse.Reinforcement.Learning.Approach.for.Microgrid.Energy.Scheduling.pdf).
```
@INPROCEEDINGS{10252933,
author={Lin, Yanbin and Das, Avijit and Ni, Zhen},
booktitle={2023 IEEE Power & Energy Society General Meeting (PESGM)},
title={A Modified Maximum Entropy Inverse Reinforcement Learning Approach for Microgrid Energy Scheduling},
year={2023},
volume={},
number={},
pages={1-5},
keywords={Learning systems;Q-learning;Processor scheduling;Microgrids;Feature extraction;Entropy;Scheduling;Distributed energy resources;reinforcement learning;maximum entropy inverse reinforcement learning;microgrid energy scheduling;and operation optimization},
doi={10.1109/PESGM52003.2023.10252933}}
```
## **Set Up**
**This code requires:**
• MATLAB
• Python
• sklearn/tensorflow/keras/numpy/xlrd/pandas libraries
## **Data Preparation**
To investigate the impact of power supply interruptions on the microgrid operations, **we assume during extreme weather-related events, the utility grid goes down for a certain period, and the microgrid operates in an isolated mode during this period**. The **RG outputs** are taken from the system advisory model by **the National Renewable Energy Laboratory for the city of Phoenix, AZ (https://sam.nrel.gov/)**. For the load-demand, **a small residential community load-demand data** is collected from **https://openei.org/wiki/Data**.
### Example of Data Generation
Here is an example to generate data for the latter implementation of our proposed **MAIL** method.
Assume we discrete the SOC state into 51 sizes, and the interrupted time is from $10^{th}$ to $13^{th}$ hour (T=24, a day for 24 hours).
```Run MAIL/GM 2024_Matlab/mainDP_Interrupted.m```
Then you will get a **interrupt10-13_dp51.xls** file and some output figures. This is one expert demonstration generated by the Dynamic Programming method in the scenario that extreme weather-related events happen at time $10^{th}-13^{th}$ (total 4 hours).
<img src="https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/assets/97860537/0fecf82d-a24e-4fe4-83ba-39a8898d6d29" width="600" height="400">
<br/><br/>
To implement our proposed MAIL method, you still need to generate other scenarios' expert demonstrations, since there will be several virtual agents to solve different cases in the MAIL method.
For example, we consider three virtual environments that the power supply interruptions happen at the time-period $10^{th}-13^{th}$ hours, $11^{th}-14^{th}$ hours, and $12^{th}-15^{th}$ hours. Three local virtual agents are applied to imitate the corresponding virtual environment's actions. So you need to change **fault_time = [10 11 12 13]** to **fault_time = [11 12 13 14]** in the **mainDP_Interrupted.m** file to generate **interrupt11-14_dp51.xls**, and change **fault_time = [10 11 12 13]** to **fault_time = [12 13 14 15]** to generate **interrupt12-15_dp51.xls**.
These files are already included in the MAIL/GM 2024_Python file folder now.
## **Implementation of the Proposed Method**
In our paper, we consider a grid-connected microgrid consisting of four units from the perspective of energy generation and load demand shown as below. The four units are the battery energy storage system (BESS), the distributed generations, including diesel generator (DG) and renewable generations (RG), the main grid, and the residential load. The optimization problem is to make hourly dispatch decisions over a time period of T(24 hours).
<img src="https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/assets/97860537/198a398a-e800-4e95-8e21-92594a006782" width="600" height="400">
This is the framework of our proposed multi-virtual-agent imitation learning approach for the microgrid system.
![framework](https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/assets/97860537/bc17c283-cefc-4fe4-bd39-f40418d531ec)
Several virtual environments' expert demonstrations are used to imitate actions in parallel, and the maximum crossover discriminators are calculated as the loss function.
### Generation of Learner Policy and Results
Once you have the expert demonstrations for different cases, you can implement the MAIL method in the MAIL/GM 2024_Python file folder.
```Python3 main.py```
You will get the result of the MAIL method: policy10-15_max3_dp11.csv. This is a policy learned for the scenario that extreme weather-related events happen at time $10^{th}-15^{th}$ (total 6 hours), which is different from expert scenarios.
```Run the calculate_cost.py file```
You will get the cost of this learned policy and a "result_of_interruption10-15_max_dp51.csv" file including 7 rows of output results: Battery_soc, power from grid, power to grid, battery discharged power, battery charged power, and dg output.
### Generation of Figures
Copy "result_of_interruption10-15_max_dp51.csv" to MAIL/GM 2024_Matlab filefolder.
```Run the plot_result.m file```
You will get the output figure of the proposed MAIL method.
<img src="https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/assets/97860537/ef855c07-7db0-4040-b697-fc4d2c7a38af" width="600" height="400">
<br/><br/>
You can also use plot_batt_pol.m and plot_cost.m files to compare the results of different methods: such as the Aggregated Q-learning method and DP method (These two methods' implementations are also included in our MAIL/GM 2024_Matlab filefolder: Cooperative_system.m and mainDP_Interrupted.m). If you want to compare different methods' results, you need to copy their result to comparative_batt_pol_soc51.csv and comparative_cost_soc51.csv before you run plot_batt_pol.m and plot_cost.m files (They are already included in the file folders now).
The figures are shown below.
<br/><br/>
<img src="https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/assets/97860537/e5dc3739-8739-403d-b87e-29c29e7e24e5" width="600" height="400">
<br/><br/>
<img src="https://github.com/YanbinLin94/Multi-virtual-agent-Imitation-Learning-for-Microgrid-Energy-Scheduling/assets/97860537/42bc5a23-9c6c-4361-8ce3-6759c
没有合适的资源?快使用搜索试试~ 我知道了~
中断周期下微电网能量优化的多虚拟代理模拟学习方法matlab代码.zip
共37个文件
xls:13个
m:9个
csv:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 29 浏览量
2024-03-18
16:19:18
上传
评论
收藏 498KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
收起资源包目录
中断周期下微电网能量优化的多虚拟代理模拟学习方法matlab代码.zip (37个子文件)
中断周期下微电网能量优化的多虚拟代理模拟学习方法matlab代码
An-Imitation-Learning-Method-with-Multi-Virtual-Agents-for-Microgrid-Energy-Optimization-main
MAIL_code
GM 2024_Matlab
mainDP_Interrupted.m 4KB
interrupt10-15_dp51.xls 10KB
interrupt12-15_dp51.xls 10KB
init.m 2KB
interrupt11-14_dp51.xls 10KB
comparative_cost_soc51.csv 1KB
F_costval_RL_FLT.m 4KB
cost_calculation.m 3KB
desktop.ini 244B
result_of_interruption10-15_max_dp51.csv 4KB
plot_cost.m 1005B
F_costval_DP_FLT.m 5KB
comparative_batt_pol_soc51.csv 535B
interrupt10-13_dp51.xls 10KB
Cooperative_system.m 5KB
price.xlsx 181KB
plot_results.m 701B
2.png 27KB
plot_batt_pol.m 1KB
GM2024_Python
result_of_interruption10-15_max_dp51_meaning.csv 1KB
calculate_cost.py 4KB
interrupt10-15_dp51.xls 30KB
interrupt12-15_dp51.xls 29KB
interrupt11-14_dp51.xls 29KB
main.py 4KB
interrupt12-15_dp11.xls 30KB
interrupt11-14_dp11.xls 29KB
interrupt10-13_dp11.xls 29KB
interrupt10-13_dp51_meaning.xls 42KB
result_of_interruption10-15_max3_dp11.csv 4KB
policy10-15_max3_dp51.csv 624B
result_of_interruption10-15_max_dp51.csv 4KB
interrupt10-15_dp11.xls 30KB
interrupt10-13_dp51.xls 29KB
price.xlsx 181KB
policy10-15_max3_dp11.csv 624B
README.md 10KB
共 37 条
- 1
资源评论
matlab科研助手
- 粉丝: 1w+
- 资源: 2054
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功