Hello Patrik,
You need to add the target declaration in your test.dat file like this for instance: target = [[0,1],[1,0]];. Normally you should be able to run the test.mod file.
Regarding the main_test.mod file, I updated/simplified your code (in green).
main {
var data = new IloOplDataSource("test.dat");
var def = new IloOplModelDefinition(new IloOplModelSource("test.mod"));
var cplex = new IloCplex();
var opl = new IloOplModel(def, cplex);
opl.addDataSource(data);
//var loop = new IloOplDataElements();
data = opl.dataElements;
//var newTarget = new Array();
for (var a = 0; a <= 1; a++) {
//newTarget[a] = new Array();
for (var b = 0; b <= 1; b++) {
//newTarget[a][b] = 1;
data.target[a][b] = 1;
}
}
//loop.target = newTarget;
//opl.addDataSource(loop);
opl.addDataSource(data);
opl.generate();
cplex.solve()
writeln(cplex.getObjValue());
writeln(opl.value);
writeln(opl.target);
opl.end();
}
Best regards,
------------------------------
Thierry Sola
------------------------------