001: // -------------------------------------------------------------------------- 002: // Licensed Materials - Property of IBM 003: // 004: // 5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 005: // Copyright IBM Corporation 1998, 2013. All Rights Reserved. 006: // 007: // Note to U.S. Government Users Restricted Rights: 008: // Use, duplication or disclosure restricted by GSA ADP Schedule 009: // Contract with IBM Corp. 010: // -------------------------------------------------------------------------- 011: 012: /*********************************************************** 013: * 014: * This model is described in the documentation. 015: * See IDE and OPL > Language and Interfaces Examples. 016: * 017: * This model is greater than the size allowed in trial mode. 018: * You therefore need a commercial edition of CPLEX Studio to 019: * run this example. 020: * If you are a student or teacher, you can also get a full version 021: * through the IBM Academic Initiative. 022: ************************************************************/ 023: 024: /** This sample uses only 1 Worker because enumeration of solutions is faster using single worker with depth-first search. **/ 025: 026: include "common.mod"; 027: 028: tuple p 029: { 030: int v[1..nbRounds]; 031: } 032: 033: {p} patterns; 034: 035: tuple ps 036: { 037: int v[0..nbTeams]; 038: } 039: 040: {ps} patset; 041: 042: 043: main 044: { 045: writeln("* Note: This OPL model is not compliant with cloud execution"); 046: 047: var rc1 = new IloOplRunConfiguration( 048: "pattern.mod","pattern.dat"); 049: rc1.oplModel.generate(); 050: rc1.cp.startNewSearch(); 051: 052: while (rc1.cp.next()) { 053: thisOplModel.patterns.add(rc1.oplModel.pattern.solutionValue); 054: 055: } 056: 057: var f = new IloOplOutputFile(); 058: f.open("patset0.dat"); 059: f.writeln("patterns="); 060: f.writeln(thisOplModel.patterns); 061: f.writeln(";"); 062: f.close(); 063: 064: 065: 066: writeln("patterns"); 067: writeln(thisOplModel.patterns); 068: writeln("found ",thisOplModel.patterns.size," patterns"); 069: 070: var rc2 = new IloOplRunConfiguration( 071: "patset.mod","patset0.dat"); 072: 073: for(var i in thisOplModel.patterns) 074: rc2.oplModel.dataElements.patterns.add(i); 075: 076: 077: rc2.oplModel.generate(); 078: rc2.cp.startNewSearch(); 079: while (rc2.cp.next()) { 080: thisOplModel.patset.add(rc2.oplModel.patset.solutionValue); 081: } 082: //writeln("patset"); 083: //writeln(thisOplModel.patset); 084: writeln("found ",thisOplModel.patset.size," pattern sets"); 085: 086: f = new IloOplOutputFile(); 087: f.open("acc0.dat"); 088: f.writeln("patset="); 089: f.writeln(thisOplModel.patset); 090: f.writeln(";"); 091: f.close(); 092: 093: 094: var rc3 = new IloOplRunConfiguration( 095: "acc.mod","acc0.dat","weekend.dat","weekday.dat", 096: "pattern.dat","patset0.dat"); 097: 098: for(var j in thisOplModel.patterns) 099: rc3.oplModel.dataElements.patterns.add(j); 100: for(var k in thisOplModel.patset) 101: rc3.oplModel.dataElements.patset.add(k); 102: 103: rc3.oplModel.generate(); 104: if (rc3.cp.solve()){ 105: writeln("obj is ",rc3.cp.getObjValue()); 106: rc3.oplModel.postProcess(); 107: } 108: else{ 109: writeln("No solution"); 110: } 111: 112: 113: } 114: 115: 116: 117: 118: