我正试图为截止日期调度问题建立一个模型。数学解决方案是众所周知的,可以在这里找到:http://www.stomp9.fr/master/benchmarc.pdf
我的代码看起来已经很好了,但在第20行出现了一个错误,说max()的参数无效。我已经阅读了手册和示例,但看起来还可以
有人知道这个问题的线索吗?
# $ glpsol -m file.mod [-d arquivo-dados] -o file.mod.out.txt
param d; # Due Date
param R; # "BigR"
param n; # n-1 tasks
param N; # n tasks
set TASKS;
param p{ TASKS };
param a{ TASKS };
param b{ TASKS };
# Contraint 6
var s{ TASKS } >= 0;
var E{ TASKS } >= 0;
var T{ TASKS } >= 0;
# Contraints 2 and 3
# Payoff {s in STATES[nPeriods]} : C[nPeriods,s] >= max(0, S[nPeriods,s] - Kstrike);
EARLYS { t in TASKS } : E[t] = max(0, d - (s[t] + p[t]) );
TARDIS { t in TASKS } : T[t] = max(0, (s[t] + p[t]) - d);
# Constraint 7
var X{ TASKS, TASKS } binary;
# Constraints 4 and 5
s.t. iB4k { i in 1..n, k in n+1..N }: s[i] + p[i] <= s[k] + R * (1 - X[i,k]);
s.t. kB4i { i in 1..n, k in n+1..N }: s[k] + p[k] <= s[1] + R * X[i,k];
minimize penaltyes: sum{ t in TASKS } ( a[t]*E[t] + b[t]*T[t]);
solve;
printf "DueDate = %4dn", d;
printf "BigR = %4dn", R;
printf { t in TASKS } "p[%2d] a[%2d] b[%2d]n", p[t], a[t], b[t];
data;
param d := 23; # Due Date
param R := 117; # "BigR" => Whole schedule time + 1
param n := 9; # n-1 tasks
param N := 10; # n tasks
param: TASKS : p a b :=
1 20 4 5
2 6 1 15
3 13 5 13
4 13 2 13
5 12 7 6
6 12 9 8
7 12 5 15
8 3 6 1
9 12 6 8
10 13 10 1;
end;
一位朋友帮我发现了错误:我不能将max与变量一起使用。他指出,max不应该是必要的,因为我已经定义了t[t]和E[t]都>=0。
所以我删除了max(),并修复了我在搜索错误时引入的其他小错误(好吧,这就是我们选择的生活;)及其运行。工作示例如下(我更改了截止日期)
# $ glpsol -m file.mod [-d arquivo-dados] -o file.mod.out.txt
# mathematical formulation: http://www.stomp9.fr/master/benchmarc.pdf
param d; # Due Date
set TASKS;
param p{ TASKS }; # Processing time
param a{ TASKS }; # earlyness penalty
param b{ TASKS }; # tardiness penalty
param R := sum{ t in TASKS } p[t]; # "BigR"
# Contraint 6
var s{ TASKS } >= 0; # start
var E{ TASKS } >= 0; # Earliness
var T{ TASKS } >= 0; # Tardiness
# Constraint 7
var X{ TASKS, TASKS } binary;
# Constraints 4 and 5
s.t. iB4k { i in TASKS, k in TASKS : i < k } : s[i] + p[i] <= s[k] + R * (1 - X[i,k]);
s.t. kB4i { i in TASKS, k in TASKS : i < k } : s[k] + p[k] <= s[i] + R * X[i,k];
# Contraints 2 and 3
s.t. EARLYS { t in TASKS } : E[t] >= d - (s[t] + p[t]) ;
s.t. TARDIS { t in TASKS } : T[t] >= (s[t] + p[t]) - d;
minimize penaltyes: sum{ t in TASKS } ( a[t]*E[t] + b[t]*T[t]);
solve;
printf "DueDate = %4dn", d;
printf "BigR = %4dn", R;
printf { t in TASKS } "p[%2d] a[%2d] b[%2d]n", p[t], a[t], b[t];
data;
param d := 92; # Due Date
param: TASKS : p a b :=
1 20 4 5
2 6 1 15
3 13 5 13
4 13 2 13
5 12 7 6
6 12 9 8
7 12 5 15
8 3 6 1
9 12 6 8
10 13 10 1;
end;