SETS:
jobs/1..20/:r,p,d;
 
time/1..60/;
 
patt(time,jobs):x,c;
 
ENDSETS
 
DATA:
 r =
1 3 6 3 8   12 10 10 11 11   21 15 23 21 10  31 21 26 32 38;
p=
3 2 4 4 2    1 3   2 3  2     3  4  2  4  2   3  4  2  1  3;
d=
12 8 10 13 10 20 15 17 25 30  30 30 36 36 40  40 45 50 50 45
;
 
ENDDATA
 
@FOR(patt(tt,j):c(tt,j) =  @ABS( tt+p(j)-d(j) )+tt+p(j)-d(j);@GIN(x(tt,j)) );
min=@SUM(jobs(j):
         @SUM(time(tt):  x(tt,j)* c(tt,j)  )
 );
 
@FOR(time(t):
  @SUM(jobs(j):
    @SUM(time(tt)|(tt#GE#r(j))#AND#
                  (t#LT#(tt+p(j)))#AND#
                  (t#GE#tt): x(tt,j)
         )
  )  < 1
);
 
@FOR(jobs(j):
    @SUM(time(tt)|(tt#GE#r(j)): x(tt,j) ) =1 
);