• 改进的多目标差分进化算法在电力系统环境经济调度中的应用(Python代码实现)【电气期刊论文复现】


    🎁专栏目录链接:

     目录

     1 电力系统环境经济调度数学模型

    2  改进的多目标差分进化算法

    3 Python代码实现

    3.1 结果

    3.2 Python代码 


       改进的多目标差分进化算法不仅可以应用在电力系统环境经济调度,换其他多目标函数和约束条件依然适用。主要是把这个工具用好,用在其他多目标经典问题上,然后就可以写一篇期刊论文。

    下面是运行结果:

    迭代一千次: 

     1 电力系统环境经济调度数学模型

     

    2  改进的多目标差分进化算法

       

            

    3 Python代码实现

    3.1 结果

    迭代500次: 

                          

                     

    迭代一千次: 

                              

                   

                         

    3.2 Python代码 

     (1)数据

                                   

    (2)读取数据然后书写目标函数和约束条件

    1. #!/usr/bin/env python
    2. # coding:utf-8
    3. import numpy as np
    4. import math
    5. # from DE.initial import create_child, initialize
    6. from constraint import constraints
    7. """=============读取data.txt数据==================="""
    8. def inital_model(file): #filedata.txt这个文件
    9. data = open(file, 'r').readlines() #读取整个文件所有行,保存在一个列表(list)变量中,每行作为一个元素
    10. num = int(data[0].split()[-1]) #切割字符串,结果返回由字符串元素组成的一个列表,得到num=6(机组个数)
    11. C = np.zeros([num, 5]) #存放煤耗特性系数
    12. E = np.zeros([num, 5]) #存放排放特性系数
    13. P = np.zeros([num, 2]) #存放机组最大出力与最小出力
    14. B = np.zeros([num, num]) #存放B矩阵
    15. parameters = len(data[3].split()) - 3 #第3行开始,到3+6=9行(Python从0开始计数)
    16. for i in range(2, 2 + num):
    17. raw_data = data[i].split()[1:]
    18. for j in range(parameters):
    19. C[i - 2][j] = float(raw_data[j]) #读取煤耗特性系数
    20. P[i - 2][0] = float(raw_data[-2]) #读取机组下限
    21. P[i - 2][1] = float(raw_data[-1]) #读取机组上限
    22. length = len(data[2 + num].split()) - 1
    23. for i in range(3 + num, 3 + 2 * num): #读取排放特性系数
    24. raw_data = data[i].split()[1:]
    25. for j in range(length):
    26. E[i - 3 - num][j] = float(raw_data[j]) #排放特性系数
    27. for i in range(4 + 2 * num, 4 + 3 * num): #读取B矩阵
    28. raw_data = data[i].split()
    29. B[i - 4 - 2 * num] = np.array(list(map(float, raw_data)))
    30. B_0 = np.array(list(map(float, data[5 + 3 * num].split())))
    31. B_00 = float(data[7 + 3 * num])
    32. return num, C, E, P, B, B_0, B_00
    33. """=====总燃料成本==========="""
    34. def costfun(uid, load, C, P=None):
    35. if P is not None: #如果满足机组上下限
    36. return load * (C[uid][2] * load + C[uid][1]) + C[uid][0] + math.fabs(C[uid][3] *
    37. math.sin(C[uid][4] * (P[uid][0] - load)))
    38. return load * (C[uid][2] * load + C[uid][1]) + C[uid][0]
    39. """======总污染排放量=========="""
    40. def emission(uid, load, E, flag=True):
    41. if E[0][3] != 0 and flag:
    42. return (E[uid][0] + (E[uid][1] + E[uid][2] * load) * load) + E[uid][3] * math.exp(E[uid][4] * load)
    43. else:
    44. return load * (E[uid][2] * load + E[uid][1]) + E[uid][0]
    45. class Model:
    46. def __init__(self, file):
    47. self.nGen, self.C, self.E, self.P, self.B, self.B_0, self.B_00 = inital_model(file)
    48. def constraint(self):
    49. return constraints
    50. ""'======运行===================='
    51. if __name__ == '__main__':
    52. demand = 2.834 #负荷需求
    53. model = Model('../data.txt')
    54. print("===============排放系数===============")
    55. print(model.E)
    56. exit(0)
    57. pop = np.array([0.1917, 0.3804, 0.5603, 0.7154, 0.6009, 0.3804]) #六个机组出力
    58. fuel = 0
    59. emis = 0
    60. for i in range(len(pop)): #遍历六个机组
    61. fuel += costfun(i, pop[i], model.C, model.P)
    62. emis += emission(i, pop[i], model.E, flag=True)
    63. print(fuel, emis)
    64. print(constraints(pop, model, demand))
    65. exit(0)

    (3)主函数,运行 

    1. """========开始运行============="""
    2. if __name__ == '__main__':
    3. demand = 2.834
    4. model = Model('../data.txt')
    5. arguments = {'nIter': 1000, 'nPop': 200, 'nArc': 100, 'nGen': 6, 'F': 0.6, 'CR': 0, 'init': 1, 'mutation': 0}
    6. DE = MMODE(model=model, **arguments)
    7. DE.solve(demand)
    8. print(DE.finalY.shape)
    9. n = range(DE.nIter)
    10. fig, ax1 = plt.subplots()
    11. color = 'tab:red'
    12. ax1.set_xlabel('迭代次数')
    13. ax1.set_ylabel('最佳燃料成本($/h)', color=color)
    14. ax1.plot(n, DE.bestC, color=color)
    15. ax1.tick_params(axis='y', labelcolor=color)
    16. ax2 = ax1.twinx() # second y axis
    17. color = 'tab:blue'
    18. ax2.set_ylabel('最佳污染排放量(t/h)', color=color)
    19. ax2.plot(n, DE.bestE, color=color)
    20. ax2.tick_params(axis='y', labelcolor=color)
    21. plt.title('最佳成本和排放')
    22. fig.tight_layout()
    23. plt.show()

  • 相关阅读:
    Windows11安装Maven
    OpenCV16-图像连通域分析
    【附源码】Python计算机毕业设计全国生鲜溯源平台
    最新微信小程序反编译方法
    基于VC++的WEB浏览器的实现
    Unity3D 多人战场Animation优化详解
    WIFI产品使用指导说明
    08: value too great for base (error token is “08“)
    【OFDM系列6】MIMO-OFDM系统模型、迫零(ZF)均衡检测和最小均方误差(MMSE)均衡检测原理和公式推导
    Bonree ONE 2.0重磅发布,中国IT运维迈入数智融合3.0时代
  • 原文地址:https://blog.csdn.net/weixin_61181717/article/details/127966793