I'm encountering "The kernel appears to have died. It will restart automatically" error while solving MIQP
OngoingI have a quadratic optimization problem with linear constraints, I tried solving the problem with Gurobipy (using python (3.7.5) Jupyter notebook on Windows 10). While the code is giving a solution for few values (not sure if it is correct), but most of the times it gives "The kernel appears to have died. It will restart automatically" error. I'm facing this error even when I'm calling the optimisation problem just once (when I tried calling the optimisation in a for loop, I'm facing the same even after cleaning the model using 'model.dispose()' at the end of the loop each time).
All the constraints are linear, I've added them using addConstrs(), below is the code written to add constraints.
m1 = gp.Model()
m1.addConstrs((x_1[i, k] == sum(f_solo_1[j, i, k] for j in range(2)) for i in range(2) for k in range(2)), name = 'c1')
m1.addConstrs((x_1[i, k] == sum(f_solo_1[i, j, k] for j in range(2)) for i in range(2) for k in range(2)), name = 'c2')
m1.addConstrs((sum(x_1[i, j] for i in range(2)) <= s[j] for j in range(2)), name = 'c3')
m1.addConstrs(((f_solo_1[i,j, 0] + f_solo_1[i, j, 1])  (theta* alpha[i,j]* (1  p_solo_1[i,j])) == 0 for i in range(2) for j in range(2)), name = "c4")
(f_solo_1, p_solo_1, x_1, y_1, s) are variables (theta and alpha are constants). These variables are initialised like given below,
p_solo_1 = m1.addVars(2, 2, lb = 0, ub = 1, vtype = gp.GRB.CONTINUOUS, name = 'p_solo_1')
f_solo_1 = m1.addVars(2, 2, 2, lb = 0, ub = 5, vtype = gp.GRB.INTEGER, name = 'f_solo_1')
x_1 = m1.addVars(2, 2, lb = 0, ub = 5, vtype = gp.GRB.INTEGER, name = 'x_1')
y_1 = m1.addVars(2, 2, 2, lb = 0, ub = 5, vtype = gp.GRB.INTEGER, name = 'y_1')
s = m1.addVars(2, lb = 0, ub = gp.GRB.INFINITY, vtype = gp.GRB.INTEGER, name = 's')
I converted it into .py file (just in case the error is due to jupyter notebook), but the code exits without giving any solution (it doesn't even give an error in this case) Please see the image attached
I hope I've implemented the vars and constraints correctly. Please let me know if I've done anything wrong.

Hi Sarath,
Could you post your definitions of \( \texttt{alpha} \), \( \texttt{theta} \), and the objective function?
Thanks,
Eli
0 
Hi Eli,
alpha and theta are constants. alpha = np.full((2,2), 0.5), theta = 12, this is how i defined them. Regarding the objective function, I have defined a function which returns an equation, which is assigned to a variable (obj1), then used it in
m1.setObjective(obj1, GRB.MAXIMIZE)
Here's the function defined:
def revenue(w=40, delta=0.99, k=3):
W = w*(1delta)
I = 0.2*W
#income
a = gp.quicksum(p_solo_1[i,j] * gp.quicksum(f_solo_1[i, j, k] for k in range(2)) for i in range(2) for j in range(2))
#costs
b = sum((W)* x_1[i,j] for i in range(2) for j in range(2))
c = sum(I * x_1[i,i] for i in range(2))
return ((a+b+c))obj1 = revenue()
m1.setObjective(obj1, gp.GRB.MAXIMIZE)
I have set the NonConvex parameter to 2 (m1.params.NonConvex = 2)
I don't know if the problem is my code or the jupyter notebook version mismatch. The code is giving solution for some values of (theta) but for other, it is giving the error.
I also have a doubt, is there a difference in (m1.setObjective(obj1, gp.GRB.MAXIMIZE)) and (m1.setObjective(obj1)) i.e., explicitly using "gp.GRB.MAXIMIZE" seems to give different results compared to when it is not called. Thanks!
0 
Hi Sarath,
By default, Gurobi will try to minimize the objective function. So the solution/behavior will be different if you tell Gurobi to maximize with \( \texttt{gp.GRB.MAXIMIZE} \).
I could reproduce this issue. I will open a ticket for you in our support portal so we can investigate this further. Thanks!
Eli
0 
Hi Sarath,
Thanks for letting us know about this. This behavior will be fixed in the next major/minor release of Gurobi.
Best,
Eli
0 
Hi, I was hoping to jump on this thread as well, as I am having a similar issue. I am running Gurobi 9.1.2, Python 3.8.5, and Jupyter notebook on Windows 10, and solving a blending optimization problem similar to the Food Manufacture I example. I have the model running in a for loop so I can observe solution changes as input parameters (e.g. prices or minimum recycled content) change. For most values the model runs fine, but for others it does not and I get the same "Kernel has died unexpectedly" issue as above. As an example, the kernel died when using prices 90% of baseline, but was fine at 80% or 91%. I have no way to know which input parameters could cause the issue.
In my understanding it appears to be a memory issue, and I have tried to limit memory usage using the model.dispose() function at the end of each call. The model output when the kernel survives is:
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 2 physical cores, 4 logical processors, using up to 4 threads
Optimize a model with 126516 rows, 116899 columns and 1594970 nonzeros
Model fingerprint: 0x0b6969b9
Model has 278 piecewiselinear objective terms
Variable types: 116899 continuous, 0 integer (0 binary)
Coefficient statistics:
Matrix range [5e03, 1e+02]
Objective range [0e+00, 0e+00]
Bounds range [0e+00, 0e+00]
RHS range [5e06, 1e+06]
Presolve removed 124121 rows and 103915 columns
Presolve time: 0.84s
Presolved: 2541 rows, 13322 columns, 101337 nonzeros
Variable types: 13256 continuous, 66 integer (66 binary)
Root relaxation: objective 2.039568e+08, 5602 iterations, 0.26 seconds
Nodes  Current Node  Objective Bounds  Work
Expl Unexpl  Obj Depth IntInf  Incumbent BestBd Gap  It/Node Time
0 0 2.0396e+08 0 66  2.0396e+08   1s
H 0 0 2.909430e+08 2.0396e+08 29.9%  1s
0 0 2.0424e+08 0 33 2.9094e+08 2.0424e+08 29.8%  1s
0 0 2.0951e+08 0 31 2.9094e+08 2.0951e+08 28.0%  2s
0 0 2.0951e+08 0 30 2.9094e+08 2.0951e+08 28.0%  2s
0 0 2.0951e+08 0 26 2.9094e+08 2.0951e+08 28.0%  2s
0 0 2.0951e+08 0 24 2.9094e+08 2.0951e+08 28.0%  2s
H 0 0 2.095149e+08 2.0951e+08 0.00%  2s
0 0 2.0951e+08 0 23 2.0951e+08 2.0951e+08 0.00%  2s
Cutting planes:
Implied bound: 5
Relaxandlift: 9
Explored 1 nodes (5928 simplex iterations) in 2.55 seconds
Thread count was 4 (of 4 available processors)
Solution count 2: 2.09515e+08 2.90943e+08
Optimal solution found (tolerance 1.00e04)
Best objective 2.095149096507e+08, best bound 2.095149096507e+08, gap 0.0000%And below is what I get when the kernel dies:Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64)
Thread count: 2 physical cores, 4 logical processors, using up to 4 threads
Optimize a model with 126516 rows, 116899 columns and 1594970 nonzeros
Model fingerprint: 0x28958759
Model has 278 piecewiselinear objective terms
Variable types: 116899 continuous, 0 integer (0 binary)
Coefficient statistics:
Matrix range [5e03, 1e+02]
Objective range [0e+00, 0e+00]
Bounds range [0e+00, 0e+00]
RHS range [5e06, 1e+06]Please let me know if there is anything I can do!0 
I'll open a ticket for you in our online support portal so we can take a closer look at this model.
0 
Thanks for reporting this issue, John. The issue will be fixed in the next Gurobi release.
0 
Hey
I encountered a similar problem while solving a quadratic optimization problem (facility location problem) with linear constraints using gurobipy matrices. Main parameters of the problem are 2208 no_clusters, 1120 no_pot_sites and 259 ambulances, k=2. The objective is to maximize the demand across the demand sites (2208) and across 8 scenarios. A screenshot of the entire model is below:
When I try to optimize, even though the memory is not fully utilized, it gives a kernel restart error.
In addition I have tried reducing the thread count and NodefileStart parameter.
Kindly help with this!!!
0 
Thanks for the report, Shayesta. We will investigate this further in our online support portal.
0 
Thanks for the help Eli. I upgraded the software to version 9.1.2, ran in Interactive Shell and the window closed automatically. Below is the snap of the result.
0 
Hi Shayesta,
Gurobi 9.5 was recently released. Included in this release is a fix for the bug you observed when solving a large MIQP with ~1.5B quadratic nonzero objective terms. Please note that Gurobi does not support solving quadratic programming problems with more than 2B quadratic nonzeros objective terms.
We hope this fix works well for you. Thanks for reporting this bug and please let us know if you see any other issues in the future.
Best regards,
Maliheh
0 
Hi John,
Gurobi 9.5 was recently released. Included in this release is a fix for the bug you observed when solving a model containing piecewiselinear functions and when Gurobi internally separates the model into connected components. There is no need to set any parameter and this works fine now under the default setting.
We hope this fix works well for you. Thank you for reporting this bug and please let us know if you see any other issues in the future.
Best regards,
Maliheh
0
Please sign in to leave a comment.
Comments
12 comments