Originally posted by: LaylaM
Hello everyone!
I see an error whilst executing CPLEX+Java:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007fff6096c79d, pid=7256, tid=5548
#
# JRE version: Java(TM) SE Runtime Environment (10.0+46) (build 10+46)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10+46, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C [cplex1280remotejni.dll+0x39c79d]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Layla\IdeaProjects\metamodel\hs_err_pid7256.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
The problem occurs inside a Lazy Constraint Callback which contains a function with which I generate a schedule (s) from routing variables (x). The problem occurs during executing "model2.solve()".
private double[] setSFromX() {
double[] retArray = new double[noLocations];
try {
IloCplex model2 = new IloCplex();
IloNumVar[] sNew = new IloNumVar[noLocations];
for (int i = 0; i<noLocations; i++) {
sNew[i] = model2.numVar(0.0,tmax);
}
IloLinearNumExpr obj = model2.linearNumExpr();
for (int i = 0; i<noLocations; i++) {
obj.addTerm(sNew[i],1.0);
}
model2.addMinimize(obj);
for(int i = 0; i<noLocations; i++) {
for (int j = 0; j<noLocations; j++) {
double xij = this.getValue(x[i][j]);
if (xij > 0.9) {
IloLinearNumExpr expr = model2.linearNumExpr();
expr.addTerm(s[j],1.0);
expr.addTerm(s[i],-1.0);
model2.addGe(expr,1.0);
}
}
}
if (model2.solve()) {
retArray = model2.getValues(sNew);
}
} catch (IloException e) {
e.printStackTrace();
}
return retArray;
}
So my first question: Is it possible to nest a second model (model2) inside a lazy constraint of a first model (which is referenced as "this" in the callback)?
Second: How can I make this run? Or should I externalize the second model to another class?
Thank you :)
Layla
#CPLEXOptimizers#DecisionOptimization