我正试图摆弄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
有人可以帮帮我吗?
答案 0 :(得分:1)
愚蠢是愚蠢的做法:
我忘了限制发布参数,并且索引存在一些问题(例如,分配的初始填充级别太晚等)。因此问题是无限的
目标应如下所示(见最后一行):
# 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;