几个月来,我正在尝试在Mac上使用glpk解决一个运筹学模型。事实是,我已经在整个互联网上进行了搜索,也试图在位于希腊雅典的大学中寻求帮助,但似乎没有人对具体计划有所了解。因此,我的模型如下:
#PARAMETERS
#
param P;
param D;
param S;
param R;
param B;
param LS;
param CLNGs;
param Tp;
param H;
param Frest;
param MA;
param f;
param Cvr {1..B};
param Cvf {1..B};
param Vv {1..B};
param Qv {1..B};
param Demand {1..R};
param d {1..P, 1..D};
# VARIABLES
#
var z{1..B} >=0, integer;
var x{1..P,1..R,1..B,1..S,1..D} >=0, continuous;
var y{1..P,1..B,1..R,1..S,1..D} >=0, integer;
# OBJECTIVE FUNCTION
#
minimize F {p<>m}: sum {p in 1..P} sum {m in 1..D}
sum {v in 1..B}Cf[v]*d[p,m]*y[p,m,v] + H* sum {v in 1..B} Cr[v]*z[v] +
sum {s in 1..S} sum {r in 1..R} sum {v in 1..B} CLNG[s]*Q[v]*x[s,r,v];
# CONSTRAINTS
#
s.t. constr1 {r in 1..R, r<>p, r<>m }: sum {p in 1..P}
sum {v in 1..B}Q[v]*x[p,r,v] - sum{m in 1..D}
sum{v in 1..B}Q[v]*x[r,m,v] >=Demand[r];
s.t. constr2 {p in 1..P, r in 1..R, v in 1..B}: y[p,r,v] >= x[p,r,v];
s.t. constr3 { r in 1..R, v in 1..B}:
sum {p in 1..P} x[p,r,v] >= sum {m in 1..D} x[r,m,v];
s.t. constr4 { p in 1..P, v in 1..B, p<>m}:
sum {m in 1..D} y[m,p,v] = sum {m in 1..D} y[p,m,v];
s.t. constr5 {v in 1..B, p<>m}: H*z[v] >= 1/V[v] *sum{p in 1..P}
sum{m in 1..D} d[p,m]*y[p,m,v] +
sum{p in 1..P}*(T[p]*sum{m in 1..D}y[p,m,v]);
s.t. constr6 {p in 1..P, r in 1..R, v in 1..B}:
Q[v]*y[p,r,v] <= Frest*y[p,r,v];
s.t. constr7 {v in 1..LS, i<>j}: sum {i in 1..R}
sum {j in 1..R} x[i,j,v] = 0;
s.t. constr8 {s in 1..S}: sum {r in 1..R}
sum {v in 1..V} Q[v]*x[s,r,v] <= MA[s];
s.t. constr9 {s in 1..S, r in 1..R}: x[s,r,v] >= f*y[s,r,v];
end;
还有我的数据:
#test comments
param P := 7;
param D := 7;
param S := 3;
param R := 4;
param B := 4;
param LS := 2;
param CLNGs := 200;
param Tp := 24;
param H := 30;
param Frest := 1000000000
param MA := 10000000000
param f :=0.8
param Cvr : 1 :=
1 510000
2 600000
3 700000
4 900000
;
param Cvf : 1 :=
1 22
2 26
3 32
4 42
;
param Vv : 1 :=
1 24
2 26
3 28
4 30
;
param Qv : 1 :=
1 5000
2 7500
3 10000
4 15000
;
param Demand : 1 :=
1 2595.9
2 3781.2
3 1668
4 372.9
;
param d: 1 2 3 4 5 6 7:=
1 0 1663 996 306 291 333 372
2 1663 0 2413 1867 1905 1856 2050
3 996 2413 0 924 938 761 1103
4 306 1867 924 0 107 202 110
5 291 1905 938 107 0 122 184
6 333 1856 761 202 122 0 302
7 372 1050 1103 110 184 302 0
;
end;
当我尝试运行此程序时,总是出现以下错误:
thesis.mod:29: syntax error in variable statement
Context: ..... P , 1 .. R , 1 .. B , 1 .. S , 1 .. D } >= 0 ,continuous
MathProg model processing error
您对如何解决此问题有任何想法吗?
答案 0 :(得分:0)
在GMPL语言的var语句中没有定义“连续”属性。默认情况下,变量是连续的。
请阅读GLPK随附的doc / gmpl.pdf。