用R语言中lpSolve包求解简单的电能与备用联合优化问题

最近在读《电力系统经济学原理》的系统安全与辅助服务部分,将112页例5-6求解一个小规模电力市场在不要求单独对备用供应进行报价情况下的电能与备用联合出清的问题,使用 R 语言中的 lpSolve 包做了一个简单的线性规划算例。

设该小规模电力市场中电力需求为 420 MW(原例是 300~720 MW 之间变化的负荷),最小备用需求为 250 MW. 系统中有 4 台发电机,参数如下表:

发电机序号 电能边际生产成本($/ MWh) 最大出力(MW) 最大备用容量(MW)
1 2 250 0
2 17 230 160
3 20 240 90
4 28 250 0

在满足负荷和备用需求以及机组物理约束的前提下,实现最小化生产成本的调度问题可以转化为一个简单的线性规划模型。

使用R语言中的lpSovle来求解该问题,实现方式如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#introduce lpSolve
library(lpSolve)
#See example at page 113 of "FUNDAMENTALS of POWER SYSTEM ECONOMICS"
#Objective Function
f.obj <- c(2, 17, 20, 28, 0, 0, 0, 0)
#Constraints
f.con <- matrix(c(1, 1, 1, 1, 0, 0, 0, 0, #Demand Balance Constraint
0, 0, 0, 0, 1, 1, 1, 1, #Least Reserve Demand Constraint
1, 0, 0, 0, 0, 0, 0, 0, #Output Constraint of G1
1, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, #Output Constraint of G2
0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, #Output Constraint of G3
0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, #Output Constraint of G4
0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, #Reserve Constraint of G1
0, 0, 0, 0, 0, 1, 0, 0, #Reserve Constraint of G2
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, #Reserve Constraint of G3
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 1, #Reserve Constraint of G4
1, 0, 0, 0, 1, 0, 0, 0, #Capacity Constraint of G1
0, 1, 0, 0, 0, 1, 0, 0, #Capacity Constraint of G2
0, 0, 1, 0, 0, 0, 1, 0, #Capacity Constraint of G3
0, 0, 0, 1, 0, 0, 0, 1), #Capacity Constraint of G4
nrow = 20, byrow = TRUE)
f.dir <- c("=", ">=", ">=", "<=", ">=", "<=", ">=", "<=", ">=", "<=", "=", ">=", "<=", ">=", "<=", "=", "<", "<", "<", "<")
f.rhs <- c(420, 250, 0, 250, 0, 230, 0, 240, 0, 250, 0, 0, 160, 0, 190, 0, 250, 230, 240, 250)
#Construct LP Optimization
lp.result <- lp("min", f.obj, f.con, f.dir, f.rhs)
#Output Objective Function Value
lp.result
#Success: the objective function is 3390
#Output Solution
lp.result$solution
#250 170 0 0 0 60 190 0

由计算结果可见,系统整体的生产成本为 $3390 ,各机组需提供的电能与备用服务分别为:

发电机序号 出力 (MW) 备用(MW)
1 250 0
2 170 60
3 0 190
4 0 0