You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run the example given for cbcModel, but adding a PreProcessing cut generator (full context: I was trying to solve a much bigger problem and running into the same issue as below). However, this is causing a segfault, and I have no idea how to start debugging this. I've encountered this with two separate builds of Cbc (one via conda, and one via coinbrew, all on Linux running within WSL). Here's the exact code:
import numpy as np
from cylp.cy import CyCbcModel, CyClpSimplex
from cylp.cy.CyCgl import CyCglPreProcess
from cylp.py.modeling.CyLPModel import CyLPModel, CyLPArray
model = CyLPModel()
x = model.addVariable('x', 3, isInt=True)
y = model.addVariable('y', 2)
A = np.matrix([[1., 2., 0],[1., 0, 1.]])
B = np.matrix([[1., 0, 0], [0, 0, 1.]])
D = np.matrix([[1., 2.],[0, 1]])
a = CyLPArray([5, 2.5])
b = CyLPArray([4.2, 3])
x_u= CyLPArray([2., 3.5])
model += A*x <= a
model += 2 <= B * x + D * y <= b
model += y >= 0
model += 1.1 <= x[1:3] <= x_u
c = CyLPArray([1., -2., 3.])
model.objective = c * x + 2 * y.sum()
s = CyClpSimplex(model)
cbcModel = s.getCbcModel()
cbcModel.addCutGenerator(CyCglPreProcess())
Result:
Segmentation fault (core dumped)
I hope that I'm just doing something really ignorant, but other cut generators don't cause the same issue. And from solving my problem using PuLP previously, I can see that the PreProcessing step substantially reduced the size of the problem before Cbc found the ultimate solution. Just throwing the model at Cbc without preprocessing definitely is not working.
The text was updated successfully, but these errors were encountered:
Although it lives in the Cgl package, CglPreprocess is not a standard cut generator, i.e., it is not derived from the CglCutGenerator base class and does not support the same API. I guess the original authors of CyLP threw it in with all the others by mistake. I'm not 100% sure how this actually compiles, but I guess the seg fault occurs when it tries to do something using the base class API, which isn't going to work. This should probably just be removed, as I don't think there's probably any easy way to use this preprocessor dynamically like you're trying to do.
However, when you call Cbc from CyLP, it should actually call the preprocessor internally by default, just as when you call it through PuLP. You shouldn't need to do anything special. So I'm not sure what you're trying to do exactly. If you can explain a little further, maybe I can make a suggestion.
You are right! Turns out initial model for my specific problem (not the demo model) was not specified correctly, so all sorts of bad things were happening. When I specified it correctly, CBC indeed called the cut generator. The issue with calling cbcModel.addCutGenerator(CyCglPreProcess()) was a red herring. I don't need anything else here - you can close this issue if you wish.
I'm trying to run the example given for cbcModel, but adding a PreProcessing cut generator (full context: I was trying to solve a much bigger problem and running into the same issue as below). However, this is causing a segfault, and I have no idea how to start debugging this. I've encountered this with two separate builds of Cbc (one via
conda
, and one viacoinbrew
, all on Linux running within WSL). Here's the exact code:Result:
I hope that I'm just doing something really ignorant, but other cut generators don't cause the same issue. And from solving my problem using PuLP previously, I can see that the PreProcessing step substantially reduced the size of the problem before Cbc found the ultimate solution. Just throwing the model at Cbc without preprocessing definitely is not working.
The text was updated successfully, but these errors were encountered: