01: // --------------------------------------------------------------------------
02: // Licensed Materials - Property of IBM
03: //
04: // 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55
05: // Copyright IBM Corporation 1998, 2013. All Rights Reserved.
06: //
07: // Note to U.S. Government Users Restricted Rights:
08: // Use, duplication or disclosure restricted by GSA ADP Schedule
09: // Contract with IBM Corp.
10: // --------------------------------------------------------------------------
11: 
12: using CP;
13: 
14: int nbJobs = ...;
15: int nbMchs = ...;
16: 
17: range Jobs = 0..nbJobs-1;
18: range Mchs = 0..nbMchs-1; 
19: // Mchs is used both to index machines and operation position in job
20: 
21: tuple Operation {
22:   int mch; // Machine
23:   int pt;  // Processing time
24: };
25: 
26: Operation Ops[j in Jobs][m in Mchs] = ...;
27: 
28: dvar interval itvs[j in Jobs][o in Mchs] size Ops[j][o].pt;
29: dvar sequence mchs[m in Mchs] in all(j in Jobs, o in Mchs : Ops[j][o].mch == m) itvs[j][o];
30: 
31: execute {
32:                 cp.param.FailLimit = 10000;
33: }
34: 
35: minimize max(j in Jobs) endOf(itvs[j][nbMchs-1]);
36: subject to {
37:   forall (m in Mchs)
38:     noOverlap(mchs[m]);
39:   forall (j in Jobs, o in 0..nbMchs-2)
40:     endBeforeStart(itvs[j][o], itvs[j][o+1]);
41: }
42: 
43: execute {
44:   for (var j = 0; j <= nbJobs-1; j++) {
45:     for (var o = 0; o <= nbMchs-1; o++) {
46:       write(itvs[j][o].start + " ");
47:     }
48:     writeln("");
49:   }
50: }