1

我正在尝试为到期日期调度问题制作模型。数学解决方案是众所周知的,可以在这里找到: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 = %4d\n", d;
printf "BigR    = %4d\n", 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;
4

1 回答 1

2

一些朋友帮我发现了错误:我不能将 max 与变量一起使用。他指出,一旦我已经定义 T[t] 和 E[t] 都 >= 0,就不需要 max 了。

所以我只是删除了 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 = %4d\n", d;
printf "BigR    = %4d\n", 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;
于 2015-06-22T00:55:59.490 回答