SETS:
jobs/1..5/:r,p,d;
 
time/1..30/;
 
patt(time,jobs):x,c;
 
ENDSETS
 
DATA:
 
r=3 ,5,1,8,4  ;
p=5,2, 3,5,  2;
d=15,12,16,15,10 ;
 
ENDDATA
 
@FOR(patt(tt,j):c(tt,j) =  @ABS( 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 
);