Originally posted by: 4XFR_giorgio_galassi
I 'm new to cplex so perphas my question could be banal for most .
I'm able to call from java the solver (opall.jar ilog.cp.jar that are inside ibm ilog studio 12.4) passing an external model and data and solve the problem.
IloOplFactory.setDebugMode(false);
IloOplFactory oplF = new IloOplFactory();
IloOplErrorHandler errHandler = oplF.createOplErrorHandler(System.out);
//IloOplModelSource modelSource = oplF.createOplModelSource("Progetto_LOCALIZZAZIONE.mod");
IloOplModelSource modelSource = oplF.createOplModelSource("SingolaAzienda.mod");
IloCplex cplex = oplF.createCplex();
IloOplSettings settings = oplF.createOplSettings(errHandler);
IloOplModelDefinition def = oplF.createOplModelDefinition(modelSource, settings);
IloOplModel opl = oplF.createOplModel(def, cplex);
String inDataFile = "data_prototipo.dat";
IloOplDataSource dataSource = oplF.createOplDataSource(inDataFile);
opl.addDataSource(dataSource);
opl.generate();
opl.convertAllIntVars(); // converts integer bounds into LP compatible format
if (cplex.solve()) {
} else {
System.out.println("Solution could not be achieved, probably insufficient memory or some other weird problem.");
}
My problem is that I don't know how to access a decision variable defined in "data_prototipo.dat" defined as follow :
dvar float+ em_ch4_stoc_l[particelle][trattamenti];
particelle = {
<"Particella 1">
};
trattamenti = {
<"Alternativa 0","",175000>
<"Alternativa 1","",175000>
<"Alternativa 2","",175000>
};
tuple Particella {
key string nome;
};
tuple Trattamento {
key string nome;
string modello;
float capacita_max;
}
{Particella} particelle = ... ;
{Trattamento} trattamenti = ... ;
em_ch4_stoc_l is bidimensional array made of tuples but how to iterate on it ?
I have seen iterators.java but I don't find solution
The only thing that I have done is to catch the element :
IloOplElement ch4 = opl.getElement("em_ch4_stoc_l");
//get it as arrays of float
IloNumVarMap ch4mappa = ch4.asNumVarMap();
//but when i do the following i have a the error:Type schema type expected for element "Particella".
IloSymbolSet ids = opl.getElement("Particella").asSymbolSet();
Thanks in advance
#DecisionOptimization#OPLusingCPLEXOptimizer