Originally posted by: SystemAdmin
[aroso said:]
Hi,
I'm trying to run a program that calls CPLEX multiple times. The program structure is something like this:
declare variables, load model, etc.
...
IloIntVarMap TVar();
...
while (some condition is met) {
...
for (IloInt i = 0;i<N;i++) {<br /> for (IloInt j = 0;j<N;j++) {<br /> for (IloInt t = 0;t<T;t++) {<br /> IloMapIndexArray indices(env);
indices.add(i+1);
indices.add(j+1);
indices.add(t+1);
IloNumVar TVarElement = TVar.getAt(indices);
TVarElement.setLB(T[i][j][t]);
TVarElement.setUB(T[i][j][t]);
}
}
}
cplex.solve();
IloIntVarMap XVar = opl.getElement("X").asIntVarMap();
for (IloInt i = 0;i<iNProdutos;i++) {<br /> IloIntVarMap subX = XVar.getSub(i+1);
for (IloInt t = 0;t<iNPeriodos;t++) {<br /> X[i][t] = (int) cplex.getValue(subX.get(t+1));
}
}
...
}
After a while, I get
terminate called after throwing an instance of 'IloMemoryException'
I think this can be avoided using the endAll method. However, I want to do it only when necessary, i.e., I don't want to do it every iteration because loading everything again takes too much time. Is there any way to automatically clean all memory when a certain level is reached? Or is there any improvement that can be made to the code to avoid this problem?
#DecisionOptimization#OPLusingCPLEXOptimizer