Originally posted by: open_ball
Hi,
I am trying to create a model in Java API, but facing an out of memory issue. After my trials, I get two different errors. The first one was:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
The second was:
java.lang.OutOfMemoryError: GC overhead limit exceeded
I am sharing a minimal example where I face with the issue. I tried to add all the possible information in the code block which only contains the creation of two variable types and a simple constraint.
IloNumVar[][][] x = new IloNumVar[numNodes][numNodes][time+1];
IloIntVar[][][] y = new IloIntVar[numNodes][numNodes][time+1];
IloLinearNumExpr expr = cplex.linearNumExpr();
IloLinearNumExpr myExpr = cplex.linearNumExpr();
for (int i = 0; i < numNodes; i++) { // numNodes =1800
for(int j =1 ; j <= time ; j++ ) { // time =50
int from = i;
int t = j;
if(adjencyList.containsKey(i)) {
//adjencyList => TreeMap<Integer,TreeSet<Integer>>
adjencyList.get(i).forEach((to) -> {
try {
Arc instance = new Arc(from, to); //get the arc
x[from][to][t] = cplex.numVar(0.0, UpperBound.get(instance));
//upperBound => TreeMap<Arc,Integer>
cplex.add(x[from][to][t]);
if(special.get(instance)){
//special => TreeMap<Arc,Integer>
y[from][to][t] = cplex.boolVar("y_"+ from+"."+ to+"."+ t );
cplex.add(y[from][to][t]);
boolean flag = false;
if(t <= initialTime.get(instance)-1){
// initialTime => TreeMap<Arc,Integer>
myExpr.addTerm(y[from][to][t], 1);
flag =true;
}
expr.addTerm(Capacity.get(instance), y[from][to][t]);
// Capacity => TreeMap<Arc,Integer>
cplex.addLe(x[from][to][t],expr);
expr.clear();
}
}catch (IloException e) {
e.printStackTrace();
}
});
}
}
}
cplex.addEq(myExpr, 0);
cplex.addMaximize(objExpr);
expr.clear();
myExpr.clear();
I was wondering if someone could help me out and give me an advice on how to solve this issue. As CPLEX settings, I have added the following changes.
cplex.setParam( IloCplex.Param.MIP.Strategy.File, 3);
cplex.setParam( IloCplex.Param.WorkMem, 15000);
cplex.setParam(IloCplex.Param.MIP.Limits.TreeMemory, 15000);
#CPLEXOptimizers#DecisionOptimization