Originally posted by: AndyHam
Thanks!
I have successfully modified the sched_jobshopflex.cpp to change the format into OPL.
tuple t_mode {
int o; //oper id
int j; //job id
int mch; //machine id
int pt; //processing time
int isFirst; //1 if it is the first operation of job j
};
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
for (int r = 1; r <= 40; r++) {
string line, s, t;
s = to_string(r) + ".fjs";
t = to_string(r) + ".dat";
if (r <= 9) {
s = "0" + to_string(r) + ".fjs";
t = "0" + to_string(r) + ".dat";
}
s = "C:/Codes/OPL/IntegratingMTS2Production/instances_FJSP/Hurink_Data/Text/sdata/la" + s;
t = "C:/Codes/OPL/IntegratingMTS2Production/instances_FJSP/Hurink_Data/Text/sdata/la" + t;
ifstream file(s);
ofstream oFile;
oFile.open(t);
int nbJobs, nbMachines;
float nTemp;
file >> nbJobs;
file >> nbMachines;
file >> nTemp;
int o; o = 1;
bool f;
oFile << "nj =" << nbJobs << ";" << '\n';
oFile << "nm =" << nbMachines << ";" << '\n';
oFile << "Modes ={" << '\n';
for (int i = 1; i <= nbJobs; i++) {
f = 1;
int nbOperations;
file >> nbOperations;
for (int j = 0; j < nbOperations; j++) {
int nbOpMachines, k;
file >> nbOpMachines;
for (k = 0; k < nbOpMachines; k++) {
int m, d;
file >> m;
file >> d;
oFile << "<" << o << "\t" << i << "\t" << m << "\t" << d << "\t" << f << ">" << '\n';
}
o++;
f = 0;
}
oFile << "};";
}
return 0;
}
#DecisionOptimization#OPLusingCPOptimizer