# [AMPL 24638] Flexible Job Shop model - Help

I need help with this model of Flexible Job Shop in AMPL please, i know that “oper” its a subset of “trab”, and his original index it’s [J_i] and o it’s t_i, but i don’t know how to model it.

this params are used in R4 and R5.

#.mod

param t; #numero total de trabajos
param m; #numero total de maquinas
param o; #numero total de operaciones
param q; #numero total de posiciones

set trab := 1…t; #Conjunto de trabajos
set oper := 1…o; #subconjunto de operaciones
set maquin := 1…m; #Conjunto de Maquinas
set pos := 1…q; #posicion

param a{maquin,trab,oper} binary; #1 si la operacion del trabajo se hace en k
param p{trab,oper}; #tiempo de proceso de la operacion j del trabajo i
param M >= 0; #limitacion
param d{trab}; # fecha de entrega

var x{i in trab, j in oper, k in maquin, l in pos} binary;#si la op del trab se hace en la maquin, en la posicion
var v{i in trab, j in oper, k in maquin} binary; #1 si la op del trab se hace en la maquina
var TM{k in maquin, l in pos} >= 0;#tiempo de inicio de la maquina y la posicion
var ti{i in trab, j in oper} >= 0;#tiempo de inicio de la operacion en el trabajo
var C{i in trab} >= 0; #tiempo requerido para completar el trabajo
var T{i in trab} >=0; #tardanza del trabajo
var U {i in trab} binary; #if c{i in trab} - d{i in trab} > 0 then 1 else 0;

minimize z: sum{i in trab} U[i]; #funcion Objetivo

subj to r1{i in trab}: C[i] >= sum{j in oper}(ti[i,j] + p[i,j]);
subj to r2{i in trab}: T[i] >= C[i] - d[i];
subj to r3{i in trab}: T[i] <= U[i] * M;
subj to r4{i in trab, j in 1…o-1}: ti[i,o] + p[i,j] <= ti[i,j+1];

subj to r5{i in trab, j in oper, k in maquin, l in 1…q-1}: TM[k,l] + p[i,j] * x[i,j,k,l] <= TM[k,l+1];
subj to r6{i in trab, j in oper, k in maquin, l in pos}: TM[k,l] <= ti[i,j] + (1-x[i,j,k,l]) * M;
subj to r7{i in trab, j in oper, k in maquin, l in pos}: TM[k,l] + (1-x[i,j,k,l]) * M >= ti[i,j];
subj to r8{i in trab, j in oper, k in maquin}: v[i,j,k] <= a[k,i,j];

subj to r9{k in maquin, l in pos}: sum{i in trab, j in oper}x[i,j,k,l] = 1;
subj to r10{i in trab, j in oper}: sum{k in maquin}v[i,j,k] = 1;
subj to r11{i in trab, j in oper, k in maquin}: sum{l in pos}x[i,j,k,l] = v[i,j,k];

#.dat
param t := 3;
param m := 3;
param o := 3;
param q := 2;

param a :=

1 1 1 1
1 1 2 0
1 1 3 0
1 2 1 0
1 2 2 0
1 2 3 0
1 3 1 0
1 3 2 0
1 3 3 0
2 1 1 1
2 1 2 0
2 1 3 0
2 2 1 0
2 2 2 0
2 2 3 0
2 3 1 0
2 3 2 0
2 3 3 0
3 1 1 0
3 1 2 0
3 1 3 1
3 2 1 0
3 2 2 0
3 2 3 0
3 3 1 0
3 3 2 0
3 3 3 0
;

param p:
1 2 3 :=
1 16 16 16
2 40 20 36
3 30 30 24
;

param M := 100;

param d:=
1 160
2 240
3 130
;

There aren’t any syntax errors or other obvious mistakes in your model and data. Maybe you are not writing constraints r4 and r5 correctly, but your question does not have enough information for me to tell what the correct form might be. Do you have a mathematical formulation for these constraints – and also the sets, parameters, and variables that appear in tham?

This formulation would be very helpful, but unfortunately the resolution of the picture is too low. I cannot clearly read the mathematical symbols – especially the subscripts. Can you provide a copy with higher resolution? If it’s in a file, you can try attaching the file.

the model is taken from this paper, from what I understand “oper” should be something like “oper[j]”

(Attachment Dialnet-ModeloDeProgramacionLinealEnteraMixtaParaLaProgram-6046313 (2).pdf is missing)

There seem to be some mistakes in the paper’s statement of the model, such as listing sk as a variable. The following is my best guess as to what the authors intended to write.

It appears that the oper set is supposed to be different for each member of trab. As far as I can tell, the paper is trying to express constraint r4 like:

``````param t;
param o {1..t};

set trab := 1..t;
set oper {i in trab} := 1..o[i];

param p {i in trab, oper[i]};
var ti {i in trab, oper[i]};

subj to r4 {i in trab, j in 1..o[i]-1}: ti[i,j] + p[i,j] <= ti[i,j+1];
``````

Similarly, it appears that the pos set is supposed to be different for each member of maquin:

``````param m;
param q {1..m};

set maquin := 1..m;
set pos {k in maquin} := 1..q[k];

var TM {k in maquin, pos[k]};
var x {i in trab, oper[i], k in maquin, pos[k]};

subj to r5 {i in trab, j in oper[i], k in maquin, l in 1..q[k]-1}:
TM[k,l] + p[i,j] * x[i,j,k,l] <= TM[k,l+1];
``````