基于Transformer的短期电价预测软件的设计与优化
Design and Optimization of Transformer-Based Short-Term Electricity Price Forecasting Software
摘要: 针对电力市场化改革背景下短期电价强波动性、非线性、时序性的核心特征,以及现有预测模型在长时序依赖捕捉不足、工程化落地脱节等问题,本文设计并优化了一款基于Transformer的短期电价预测软件。首先,系统梳理短期电价的多维度影响因素,通过相关性分析与互信息法组合筛选关键特征,构建高质量输入特征集;其次,从输入特征、超参数、模型结构三个维度进行协同优化,引入粒子群优化(PSO)算法优化Transformer超参数,结合时序位置编码增强模型时序感知能力,构建PSO-Transformer混合预测模型;然后,基于前端–后端–数据库三层架构,整合数据预处理、模型训练、预测输出、结果可视化等全流程功能,实现模型的工程化落地;最后,采用PJM电力市场数据集与我国某区域电力现货市场数据集进行实验验证。结果表明,优化后的模型预测精度较传统LSTM模型提升23.5%,MAE、RMSE、MAPE分别降至0.028、0.039、2.42%;开发的软件运行稳定、交互友好,可高效实现小时级、日前级短期电价精准预测,为电力市场参与主体提供可靠的决策支持。
Abstract: Against the backdrop of electricity market-oriented reform, short-term electricity prices exhibit core characteristics of strong volatility, nonlinearity and time series dependence. Meanwhile, existing forecasting models suffer from insufficient capture of long time series dependencies and disconnection with engineering implementation. To address these issues, this paper designs and optimizes a Transformer-based short-term electricity price forecasting software. Firstly, the multi-dimensional influencing factors of short-term electricity prices are systematically sorted out, and key features are screened through a combination of correlation analysis and mutual information method to construct a high-quality input feature set. Secondly, collaborative optimization is carried out from three dimensions: input features, hyperparameters and model structure. The Particle Swarm Optimization (PSO) algorithm is introduced to optimize Transformer hyperparameters, and time series position encoding is integrated to enhance the model’s temporal perception capability, so as to construct a PSO-Transformer hybrid forecasting model. Thirdly, based on the three-tier architecture of front-end, back-end and database, the whole process functions including data preprocessing, model training, prediction output and result visualization are integrated to realize the engineering implementation of the model. Finally, experimental verification is performed using the dataset from the PJM electricity market and that from a regional electricity spot market in China. The results show that compared with the traditional LSTM model, the forecasting accuracy of the optimized model is improved by 23.5%, with the MAE, RMSE and MAPE reduced to 0.028, 0.039 and 2.42% respectively. The developed software features stable operation and friendly interaction, enabling efficient and accurate hour-ahead and day-ahead short-term electricity price forecasting, providing reliable decision support for participants in the electricity market.
文章引用:王雅琦, 杨光, 李文杰, 郑丰奎. 基于Transformer的短期电价预测软件的设计与优化[J]. 智能电网, 2026, 16(2): 40-50. https://doi.org/10.12677/sg.2026.162005

参考文献

[1] 国家发展改革委, 国家能源局. 关于加快建设全国统一电力市场体系的指导意见[Z]. 2022. https://zfxxgk.ndrc.gov.cn/web/iteminfo.jsp?id=18646
[2] 苏娟, 杜松怀, 周兴华. 电力市场现货电价预测方法研究状况综述[J]. 继电器, 2005(16): 78-84.
[3] 朱文忠, 罗鹏阳. 深度学习在时序预测中的应用研究综述[J/OL]. 四川轻化工大学学报(自然科学版): 1-13.
https://link.cnki.net/urlid/51.1792.N.20260305.1729.002, 2026-04-26.
[4] 赵晶. 电力市场中电价预测方法综述[J]. 企业技术开发, 2013, 32(18): 118-119.
[5] Vaswani, A,. Shazeer, N,. Parmar, N., et al. (2017) Attention Is All You Need. Proceedings of the 31st International Conference on Neural Information Processing Systems (NeurIPS 2017), Long Beach, 4-9 December 2017, 5998-6008.
[6] 郑志勇, 陈田原, 胡哲, 等. 短期电价预测的机器学习方法现状、挑战与展望[J]. 河南科学, 2025, 43(1): 90-98.
[7] 李增伟, 王娅云, 张容福, 等. 基于SE-CNN-BiLSTM与改进Transformer的光伏功率多时间尺度预测方法[J]. 浙江电力, 2026, 45(3): 120-130.
[8] Llorente, O. and Portela, J. (2024) A Transformer Approach for Electricity Price Forecasting. arXiv: 2403.16108.
[9] Jiang, H., Pan, S., Dong, Y. and Wang, J. (2024) Probabilistic Electricity Price Forecasting Based on Penalized Temporal Fusion Transformer. Journal of Forecasting, 43, 1465-1491. [Google Scholar] [CrossRef
[10] 陈诗乐, 王笑, 周昌军. 基于GA-Transformer模型的多因子股票预测[J]. 广州大学学报(自然科学版), 2021, 20(1): 44-55.
[11] 孙欣, 王思敏, 谢敬东, 等. 考虑多维影响因素的改进Transformer-PSO短期电价预测方法[J]. 上海交通大学学报, 2024, 58(9): 1420-1431.
[12] 张鹏飞, 胡博, 胡展硕, 等. 基于STD-ST-Former的现货电价长步时空预测[J]. 中国电机工程学报, 2025, 45(19): 7456-7468.
[13] 郭瑛, 曹蕃, 宋寅, 等. 电力市场价格预测的综述与展望[J]. 分布式能源, 2025, 10(4): 1-12.
[14] 于昌海. 电力市场电价预测模型及算法研究[D]: [硕士学位论文]. 北京: 华北电力大学(北京), 2011.
[15] 彭彪, 于惠钧, 赵文川. 基于PKO算法与IAPO算法的短期电力负荷预测模型[J]. 现代电子技术, 2026, 49(8): 84-92.
[16] 王珂珂. 计及新能源的电力现货市场交易优化研究[D]: [博士学位论文]. 北京: 华北电力大学(北京), 2021.
[17] 王瑞庆, 李渝曾. 含误差校正的粒子群优化GM(1,2)短期电价预测方法[J]. 电力系统保护与控制, 2011, 39(13): 41-45, 52.