GLPK Hydro Storage - 不可行性
GLPK Hydro Storage - Infeasibility
我正在尝试 fiddle 使用 GLPK 和 mathprog 语言。我正在尝试为水力存储实现一个简单的模型(只是涡轮机,没有泵)。但是我越来越不可行了。
浇灌过初始条件,这个应该是可行的。
代码如下:
set T;
#========================================================
# Time Series
# Price
param price{i in T};
# Inflow
param inflow{i in T};
#========================================================
# Unit description
param release_max>=0;
param release_min>=0;
param fill_max>=0;
param fill_min>=0;
param fill_start>=0;
param fill_end>=0;
#========================================================
# optimization variables
var release{i in T}>=0;
var fill{i in T}, >=fill_min, <=fill_max;
# objective: Maximize profit
maximize obj: sum{i in T} price[i] * release[i];
s.t. fill_current {i in T: i>1}:
fill[i] = fill[i-1] - release[i] + inflow[i];
s.t. fill_con_start {i in T: i=1}:
fill[i] = fill_start;
s.t. fill_con_end {i in T: i=card(T)}:
fill[i]>=fill_end;
solve;
data;
param release_max:=100;
param release_min:=0;
param fill_max:=10000;
param fill_min:=0;
param fill_start:=5000;
param fill_end:=5000;
param : T : price inflow :=
0 15 150
1 17 170
2 18 180
3 22 220
4 55 550
5 40 400
6 65 650
7 10 100
8 12 120
9 4 40
;
end;
这是输出:
GLPSOL: GLPK LP/MIP Solver, v4.55
Parameter(s) specified in the command line:
--cover --clique --gomory --mir -m Hydro_test.mod
Reading model section from Hydro_test.mod...
Reading data section from Hydro_test.mod...
58 lines were read
Generating obj...
Generating fill_current...
Generating fill_con_start...
Generating fill_con_end...
Model has been successfully generated
GLPK Simplex Optimizer, v4.55
10 rows, 19 columns, 35 non-zeros
Preprocessing...
PROBLEM HAS NO DUAL FEASIBLE SOLUTION
Time used: 0.0 secs
Memory used: 0.1 Mb (102683 bytes)
>Exit code: 0 Time: 0.316
有人可以帮我吗?
傻就是傻:
我忘记限制释放参数并且索引有一些问题(例如初始填充级别分配得太晚等)。因此问题是无界的
objective 应该是这样的(见最后一行):
# objective: Maximize profit
maximize obj: sum{i in T} price[i] * release[i];
s.t. fill_current {i in T: i>0}:
fill[i] = fill[i-1] - release[i] + inflow[i];
s.t. fill_con_start {i in T: i=0}:
fill[i] = fill_start;
s.t. fill_con_end {i in T: i=card(T)-1}:
fill[i]>=fill_end;
s.t. release_current {i in T}:
release_max>=release[i]>=release_min;
我正在尝试 fiddle 使用 GLPK 和 mathprog 语言。我正在尝试为水力存储实现一个简单的模型(只是涡轮机,没有泵)。但是我越来越不可行了。
浇灌过初始条件,这个应该是可行的。
代码如下:
set T;
#========================================================
# Time Series
# Price
param price{i in T};
# Inflow
param inflow{i in T};
#========================================================
# Unit description
param release_max>=0;
param release_min>=0;
param fill_max>=0;
param fill_min>=0;
param fill_start>=0;
param fill_end>=0;
#========================================================
# optimization variables
var release{i in T}>=0;
var fill{i in T}, >=fill_min, <=fill_max;
# objective: Maximize profit
maximize obj: sum{i in T} price[i] * release[i];
s.t. fill_current {i in T: i>1}:
fill[i] = fill[i-1] - release[i] + inflow[i];
s.t. fill_con_start {i in T: i=1}:
fill[i] = fill_start;
s.t. fill_con_end {i in T: i=card(T)}:
fill[i]>=fill_end;
solve;
data;
param release_max:=100;
param release_min:=0;
param fill_max:=10000;
param fill_min:=0;
param fill_start:=5000;
param fill_end:=5000;
param : T : price inflow :=
0 15 150
1 17 170
2 18 180
3 22 220
4 55 550
5 40 400
6 65 650
7 10 100
8 12 120
9 4 40
;
end;
这是输出:
GLPSOL: GLPK LP/MIP Solver, v4.55
Parameter(s) specified in the command line:
--cover --clique --gomory --mir -m Hydro_test.mod
Reading model section from Hydro_test.mod...
Reading data section from Hydro_test.mod...
58 lines were read
Generating obj...
Generating fill_current...
Generating fill_con_start...
Generating fill_con_end...
Model has been successfully generated
GLPK Simplex Optimizer, v4.55
10 rows, 19 columns, 35 non-zeros
Preprocessing...
PROBLEM HAS NO DUAL FEASIBLE SOLUTION
Time used: 0.0 secs
Memory used: 0.1 Mb (102683 bytes)
>Exit code: 0 Time: 0.316
有人可以帮我吗?
傻就是傻:
我忘记限制释放参数并且索引有一些问题(例如初始填充级别分配得太晚等)。因此问题是无界的
objective 应该是这样的(见最后一行):
# objective: Maximize profit
maximize obj: sum{i in T} price[i] * release[i];
s.t. fill_current {i in T: i>0}:
fill[i] = fill[i-1] - release[i] + inflow[i];
s.t. fill_con_start {i in T: i=0}:
fill[i] = fill_start;
s.t. fill_con_end {i in T: i=card(T)-1}:
fill[i]>=fill_end;
s.t. release_current {i in T}:
release_max>=release[i]>=release_min;