MathProg max() function complains about wrong arguments

467 views Asked by At

I'm trying to make a model for the Due Date schedulling Problem. The mathematical solution is well known and can be found here: http://www.stomp9.fr/master/benchmarc.pdf

My code is looking good already, but I've got an error on line 20, saying that the arguments for max() are invalid. I've read the manual and lookead at examples, but it looks ok.

Does someone have a clue about this problem?

# $ 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;
1

There are 1 answers

0
fkrahe On

some friend helped me to spot the error: I couldn't use max with variables. He pointed out that max shouldn't be necessary, once I had already defined that T[t] and E[t] were both >= 0.

So I just removed max() and fixed other little errors that I had introduced while searching for errors (well, thats the life we chose ;) and its running. The working example goes bellow (I changed the due date)

# $ 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;